mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Compare commits
65 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
7cecdcae07 | ||
![]() |
cf59edd364 | ||
![]() |
2b978915d8 | ||
![]() |
254a64ec30 | ||
![]() |
9eb25bd899 | ||
![]() |
8087a21d0a | ||
![]() |
2e5f296bfa | ||
![]() |
4266c75f40 | ||
![]() |
f451a4de09 | ||
![]() |
6aa47debba | ||
![]() |
3391bb98e3 | ||
![]() |
21895b05ab | ||
![]() |
be81ebe1a4 | ||
![]() |
edf46621f3 | ||
![]() |
5dc5937b30 | ||
![]() |
7084241c75 | ||
![]() |
640204280f | ||
![]() |
740366c32b | ||
![]() |
5d53dfd20c | ||
![]() |
5b62726ced | ||
![]() |
a5830bfcb1 | ||
![]() |
3bca02e274 | ||
![]() |
197bbfe0d5 | ||
![]() |
0cc6436ef5 | ||
![]() |
f04c457a51 | ||
![]() |
5631b9b952 | ||
![]() |
dc71f481ff | ||
![]() |
e2c1579816 | ||
![]() |
cff8620272 | ||
![]() |
5be32eb35c | ||
![]() |
611bf1016c | ||
![]() |
0e37c0b477 | ||
![]() |
7108843467 | ||
![]() |
2b0eb78656 | ||
![]() |
ffb8e8b26f | ||
![]() |
cc5ee6b213 | ||
![]() |
b4800bae33 | ||
![]() |
ea12796820 | ||
![]() |
643dbda7d6 | ||
![]() |
34e3f7a65b | ||
![]() |
3e67531078 | ||
![]() |
23bdc7a6c4 | ||
![]() |
69a3e5bfd1 | ||
![]() |
c90491724e | ||
![]() |
98448e372d | ||
![]() |
f2b0f5fe1c | ||
![]() |
7101a5569f | ||
![]() |
e046c0dc3b | ||
![]() |
34005e3d3d | ||
![]() |
44f97f08d7 | ||
![]() |
044536de92 | ||
![]() |
738f5e743c | ||
![]() |
f20e66aa93 | ||
![]() |
5d09501462 | ||
![]() |
872555f4ba | ||
![]() |
bb7e922914 | ||
![]() |
b20e6fb314 | ||
![]() |
5356b94169 | ||
![]() |
812c34c13c | ||
![]() |
68e090e700 | ||
![]() |
8c7ed2e3b2 | ||
![]() |
2519a03418 | ||
![]() |
c4b20d0a3a | ||
![]() |
a8242dd947 | ||
![]() |
171bdd3a6c |
@ -39,8 +39,8 @@ disabled_codes: [
|
||||
# re-enable the "invalid variable name XXX" messages.
|
||||
"C0103",
|
||||
|
||||
# A custom command with one output doesn't really need a comment because
|
||||
# the default "generating XXX" is a good message already.
|
||||
# TODO:
|
||||
# Add brief COMMENT arguments to the `add_custom_target` commands.
|
||||
"C0113",
|
||||
]
|
||||
|
||||
@ -82,10 +82,10 @@ keyword_pattern: "[A-Z][0-9A-Z_]+"
|
||||
# before considering the loop a parser
|
||||
max_conditionals_custom_parser: 2
|
||||
|
||||
# Require at least this many newlines between statements
|
||||
# Require at least this many newlines between statements;
|
||||
# require no more than this many newlines between statements;
|
||||
# etc.
|
||||
min_statement_spacing: 1
|
||||
|
||||
# Require no more than this many newlines between statements
|
||||
max_statement_spacing: 2
|
||||
max_returns: 6
|
||||
max_branches: 12
|
||||
|
2
.github/workflows/lint.yml
vendored
2
.github/workflows/lint.yml
vendored
@ -23,6 +23,8 @@ jobs:
|
||||
restore-keys: ${{ runner.os }}-pip-
|
||||
- name: Install yamllint
|
||||
run: pip install yamllint
|
||||
- name: Install editorconfig-checker
|
||||
uses: editorconfig-checker/action-editorconfig-checker@main
|
||||
- name: Check out the code
|
||||
uses: actions/checkout@v4
|
||||
- name: Run the linting script
|
||||
|
24
.gitignore
vendored
24
.gitignore
vendored
@ -122,6 +122,7 @@ ipch/
|
||||
*.out
|
||||
*out.png
|
||||
[._]deps/
|
||||
[._]libs/
|
||||
.dirstamp
|
||||
/Makefile
|
||||
/autom4te.cache/
|
||||
@ -143,13 +144,16 @@ pnglibconf.dfn
|
||||
pnglibconf.pre
|
||||
pngprefix.h
|
||||
|
||||
# Libpng test programs
|
||||
png-fix-itxt
|
||||
pngcp
|
||||
pngfix
|
||||
pngimage
|
||||
pngstest
|
||||
pngtest
|
||||
pngunknown
|
||||
pngvalid
|
||||
timepng
|
||||
# Libpng test programs, scripts and artifacts
|
||||
/test-suite.log
|
||||
/tests/*.log
|
||||
/tests/*.trs
|
||||
/png-fix-itxt
|
||||
/pngcp
|
||||
/pngfix
|
||||
/pngimage
|
||||
/pngstest
|
||||
/pngtest
|
||||
/pngunknown
|
||||
/pngvalid
|
||||
/timepng
|
||||
|
28
.travis.yml
28
.travis.yml
@ -1,28 +0,0 @@
|
||||
branches:
|
||||
except:
|
||||
- /libpng[0-1][0-8]/
|
||||
- /v[0-1][.][0-8][.][0-9]+/
|
||||
|
||||
language: c
|
||||
|
||||
os:
|
||||
- freebsd
|
||||
- linux
|
||||
- osx
|
||||
|
||||
env:
|
||||
- AUTOMATION=cmake
|
||||
- AUTOMATION=configure
|
||||
- AUTOMATION=makefiles
|
||||
|
||||
before_script:
|
||||
- 'if test "$TRAVIS_OS_NAME" = "linux"; then export CI_CC="gcc"; else export CI_CC="clang"; fi'
|
||||
- 'if test "$TRAVIS_OS_NAME" = "osx"; then export CI_CMAKE_GENERATOR="Xcode"; fi'
|
||||
- 'if test "$TRAVIS_OS_NAME" != "osx"; then export CI_SANITIZERS="address,undefined"; fi'
|
||||
- 'export CI_MAKEFILES="scripts/makefile.$CI_CC scripts/makefile.std"'
|
||||
- 'export CI_MAKE_FLAGS=-j2'
|
||||
- 'export CI_CMAKE_BUILD_FLAGS=-j2'
|
||||
- 'export CI_CTEST_FLAGS=-j2'
|
||||
|
||||
script:
|
||||
- './ci/ci_verify_$AUTOMATION.sh'
|
37
ANNOUNCE
37
ANNOUNCE
@ -1,5 +1,13 @@
|
||||
libpng 1.6.46 - January 23, 2025
|
||||
================================
|
||||
libpng 1.6.51.git
|
||||
=================
|
||||
|
||||
This is a development version, not intended to be a public release.
|
||||
It will be replaced by a public release, or by another development
|
||||
version, at a later time.
|
||||
|
||||
|
||||
libpng 1.6.50 - July 1, 2025
|
||||
============================
|
||||
|
||||
This is a public release of libpng, intended for use in production code.
|
||||
|
||||
@ -9,13 +17,13 @@ Files available for download
|
||||
|
||||
Source files with LF line endings (for Unix/Linux):
|
||||
|
||||
* libpng-1.6.46.tar.xz (LZMA-compressed, recommended)
|
||||
* libpng-1.6.46.tar.gz (deflate-compressed)
|
||||
* libpng-1.6.50.tar.xz (LZMA-compressed, recommended)
|
||||
* libpng-1.6.50.tar.gz (deflate-compressed)
|
||||
|
||||
Source files with CRLF line endings (for Windows):
|
||||
|
||||
* lpng1646.7z (LZMA-compressed, recommended)
|
||||
* lpng1646.zip (deflate-compressed)
|
||||
* lpng1650.7z (LZMA-compressed, recommended)
|
||||
* lpng1650.zip (deflate-compressed)
|
||||
|
||||
Other information:
|
||||
|
||||
@ -25,17 +33,18 @@ Other information:
|
||||
* TRADEMARK.md
|
||||
|
||||
|
||||
Changes from version 1.6.45 to version 1.6.46
|
||||
Changes from version 1.6.49 to version 1.6.50
|
||||
---------------------------------------------
|
||||
|
||||
* Added support for the mDCV and cLLI chunks.
|
||||
* Improved the detection of the RVV Extension on the RISC-V platform.
|
||||
(Contributed by Filip Wasil)
|
||||
* Replaced inline ASM with C intrinsics in the RVV code.
|
||||
(Contributed by Filip Wasil)
|
||||
* Fixed a decoder defect in which unknown chunks trailing IDAT, set
|
||||
to go through the unknown chunk handler, incorrectly triggered
|
||||
out-of-place IEND errors.
|
||||
(Contributed by John Bowler)
|
||||
* Fixed a build issue affecting C89 compilers.
|
||||
This was a regression introduced in libpng-1.6.45.
|
||||
(Contributed by John Bowler)
|
||||
* Added makefile.c89, specifically for testing C89 compilers.
|
||||
* Cleaned up contrib/pngminus: corrected an old typo, removed an old
|
||||
workaround, and updated the CMake file.
|
||||
* Fixed the CMake file for cross-platform builds that require `libm`.
|
||||
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net.
|
||||
|
6
AUTHORS
6
AUTHORS
@ -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
|
||||
|
41
CHANGES
41
CHANGES
@ -6239,6 +6239,47 @@ Version 1.6.46 [January 23, 2025]
|
||||
Cleaned up contrib/pngminus: corrected an old typo, removed an old
|
||||
workaround, and updated the CMake file.
|
||||
|
||||
Version 1.6.47 [February 18, 2025]
|
||||
Modified the behaviour of colorspace chunks in order to adhere
|
||||
to the new precedence rules formulated in the latest draft of
|
||||
the PNG Specification.
|
||||
(Contributed by John Bowler)
|
||||
Fixed a latent bug in `png_write_iCCP`.
|
||||
This would have been a read-beyond-end-of-malloc vulnerability,
|
||||
introduced early in the libpng-1.6.0 development, yet (fortunately!)
|
||||
it was inaccessible before the above-mentioned modification of the
|
||||
colorspace precedence rules, due to pre-existing colorspace checks.
|
||||
(Reported by Bob Friesenhahn; fixed by John Bowler)
|
||||
|
||||
Version 1.6.48 [April 30, 2025]
|
||||
Fixed the floating-point version of the mDCv setter `png_set_mDCv`.
|
||||
(Reported by Mohit Bakshi; fixed by John Bowler)
|
||||
Added #error directives to discourage the inclusion of private
|
||||
libpng implementation header files in PNG-supporting applications.
|
||||
Added the CMake build option `PNG_LIBCONF_HEADER`, to be used as an
|
||||
alternative to `DFA_XTRA`.
|
||||
Removed the Travis CI configuration files, with heartfelt thanks for
|
||||
their generous support of our project over the past five years!
|
||||
|
||||
Version 1.6.49 [June 12, 2025]
|
||||
Added SIMD-optimized code for the RISC-V Vector Extension (RVV).
|
||||
(Contributed by Manfred Schlaegl, Dragos Tiselice and Filip Wasil)
|
||||
Added various fixes and improvements to the build scripts and to
|
||||
the sample code.
|
||||
|
||||
Version 1.6.50 [July 1, 2025]
|
||||
Improved the detection of the RVV Extension on the RISC-V platform.
|
||||
(Contributed by Filip Wasil)
|
||||
Replaced inline ASM with C intrinsics in the RVV code.
|
||||
(Contributed by Filip Wasil)
|
||||
Fixed a decoder defect in which unknown chunks trailing IDAT, set
|
||||
to go through the unknown chunk handler, incorrectly triggered
|
||||
out-of-place IEND errors.
|
||||
(Contributed by John Bowler)
|
||||
Fixed the CMake file for cross-platform builds that require `libm`.
|
||||
|
||||
Version 1.6.51 [TODO]
|
||||
|
||||
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
|
||||
|
578
CMakeLists.txt
578
CMakeLists.txt
File diff suppressed because it is too large
Load Diff
10
INSTALL
10
INSTALL
@ -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
|
||||
|
||||
|
13
Makefile.am
13
Makefile.am
@ -134,13 +134,20 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += powerpc/powerpc_init.c\
|
||||
powerpc/filter_vsx_intrinsics.c
|
||||
endif
|
||||
|
||||
if PNG_RISCV_RVV
|
||||
noinst_LTLIBRARIES= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv.la
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_SOURCES = riscv/riscv_init.c\
|
||||
riscv/filter_rvv_intrinsics.c
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_CFLAGS = -march=rv64gv
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LIBADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv.la
|
||||
endif
|
||||
|
||||
if PNG_LOONGARCH_LSX
|
||||
noinst_LTLIBRARIES= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_SOURCES = loongarch/loongarch_lsx_init.c\
|
||||
loongarch/filter_lsx_intrinsics.c
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_CFLAGS = -mlsx
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LIBADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la
|
||||
# libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la
|
||||
endif
|
||||
|
||||
nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
|
||||
@ -163,6 +170,10 @@ else
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.sym
|
||||
endif
|
||||
|
||||
if PNG_RISCV_RVV
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES += libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv.la
|
||||
endif
|
||||
|
||||
if PNG_LOONGARCH_LSX
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES += libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la
|
||||
endif
|
||||
|
109
Makefile.in
109
Makefile.in
@ -1,7 +1,7 @@
|
||||
# Makefile.in generated by automake 1.17 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.18.1 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright (C) 1994-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1994-2025 Free Software Foundation, Inc.
|
||||
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -130,8 +130,9 @@ host_triplet = @host@
|
||||
@HAVE_LD_VERSION_SCRIPT_TRUE@@HAVE_SOLARIS_LD_FALSE@am__append_9 = -Wl,--version-script=libpng.vers
|
||||
# Only restricted exports when possible
|
||||
@HAVE_LD_VERSION_SCRIPT_FALSE@am__append_10 = -export-symbols libpng.sym
|
||||
@PNG_LOONGARCH_LSX_TRUE@am__append_11 = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la
|
||||
@DO_PNG_PREFIX_TRUE@am__append_12 = -DPNG_PREFIX='@PNG_PREFIX@'
|
||||
@PNG_RISCV_RVV_TRUE@am__append_11 = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv.la
|
||||
@PNG_LOONGARCH_LSX_TRUE@am__append_12 = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la
|
||||
@DO_PNG_PREFIX_TRUE@am__append_13 = -DPNG_PREFIX='@PNG_PREFIX@'
|
||||
subdir = .
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
am__aclocal_m4_deps = $(top_srcdir)/scripts/autoconf/libtool.m4 \
|
||||
@ -239,6 +240,18 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_LINK = $(LIBTOOL) $(AM_V_lt) \
|
||||
$(CCLD) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_CFLAGS) \
|
||||
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
@PNG_LOONGARCH_LSX_TRUE@am_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_rpath =
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_LIBADD =
|
||||
am__libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_SOURCES_DIST = \
|
||||
riscv/riscv_init.c riscv/filter_rvv_intrinsics.c
|
||||
@PNG_RISCV_RVV_TRUE@am_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_OBJECTS = riscv/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-riscv_init.lo \
|
||||
@PNG_RISCV_RVV_TRUE@ riscv/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-filter_rvv_intrinsics.lo
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_OBJECTS = \
|
||||
$(am_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_OBJECTS)
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_LINK = $(LIBTOOL) $(AM_V_lt) \
|
||||
--tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link \
|
||||
$(CCLD) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_CFLAGS) \
|
||||
$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
@PNG_RISCV_RVV_TRUE@am_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_rpath =
|
||||
am__png_fix_itxt_SOURCES_DIST = contrib/tools/png-fix-itxt.c
|
||||
@ENABLE_TOOLS_TRUE@am_png_fix_itxt_OBJECTS = \
|
||||
@ENABLE_TOOLS_TRUE@ contrib/tools/png-fix-itxt.$(OBJEXT)
|
||||
@ -332,7 +345,9 @@ am__depfiles_remade = ./$(DEPDIR)/png.Plo ./$(DEPDIR)/pngerror.Plo \
|
||||
mips/$(DEPDIR)/filter_msa_intrinsics.Plo \
|
||||
mips/$(DEPDIR)/mips_init.Plo \
|
||||
powerpc/$(DEPDIR)/filter_vsx_intrinsics.Plo \
|
||||
powerpc/$(DEPDIR)/powerpc_init.Plo
|
||||
powerpc/$(DEPDIR)/powerpc_init.Plo \
|
||||
riscv/$(DEPDIR)/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-filter_rvv_intrinsics.Plo \
|
||||
riscv/$(DEPDIR)/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-riscv_init.Plo
|
||||
am__mv = mv -f
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
@ -355,12 +370,14 @@ am__v_CCLD_1 =
|
||||
SOURCES = $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES) \
|
||||
$(nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES) \
|
||||
$(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_SOURCES) \
|
||||
$(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_SOURCES) \
|
||||
$(png_fix_itxt_SOURCES) $(pngcp_SOURCES) $(pngfix_SOURCES) \
|
||||
$(pngimage_SOURCES) $(pngstest_SOURCES) $(pngtest_SOURCES) \
|
||||
$(pngunknown_SOURCES) $(pngvalid_SOURCES) $(timepng_SOURCES)
|
||||
DIST_SOURCES = \
|
||||
$(am__libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES_DIST) \
|
||||
$(am__libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_SOURCES_DIST) \
|
||||
$(am__libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_SOURCES_DIST) \
|
||||
$(am__png_fix_itxt_SOURCES_DIST) $(am__pngcp_SOURCES_DIST) \
|
||||
$(am__pngfix_SOURCES_DIST) $(am__pngimage_SOURCES_DIST) \
|
||||
$(am__pngstest_SOURCES_DIST) $(am__pngtest_SOURCES_DIST) \
|
||||
@ -510,7 +527,7 @@ am__common_driver_flags = \
|
||||
# To be inserted before the command running the test. Creates the
|
||||
# directory for the log if needed. Stores in $dir the directory
|
||||
# containing $f, in $tst the test, in $log the log. Executes the
|
||||
# developer- defined test setup AM_TESTS_ENVIRONMENT (if any), and
|
||||
# developer-defined test setup AM_TESTS_ENVIRONMENT (if any), and
|
||||
# passes TESTS_ENVIRONMENT. Set up options for the wrapper that
|
||||
# will run the test scripts (or their associated LOG_COMPILER, if
|
||||
# thy have one).
|
||||
@ -827,21 +844,28 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c \
|
||||
$(am__append_4) $(am__append_5) $(am__append_6) \
|
||||
$(am__append_7)
|
||||
@PNG_LOONGARCH_LSX_TRUE@noinst_LTLIBRARIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la
|
||||
@PNG_RISCV_RVV_TRUE@noinst_LTLIBRARIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv.la
|
||||
@PNG_RISCV_RVV_TRUE@libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_SOURCES = riscv/riscv_init.c\
|
||||
@PNG_RISCV_RVV_TRUE@ riscv/filter_rvv_intrinsics.c
|
||||
|
||||
@PNG_RISCV_RVV_TRUE@libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_CFLAGS = -march=rv64gv
|
||||
@PNG_LOONGARCH_LSX_TRUE@libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LIBADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la
|
||||
@PNG_RISCV_RVV_TRUE@libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LIBADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv.la
|
||||
@PNG_LOONGARCH_LSX_TRUE@libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_SOURCES = loongarch/loongarch_lsx_init.c\
|
||||
@PNG_LOONGARCH_LSX_TRUE@ loongarch/filter_lsx_intrinsics.c
|
||||
|
||||
@PNG_LOONGARCH_LSX_TRUE@libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_CFLAGS = -mlsx
|
||||
@PNG_LOONGARCH_LSX_TRUE@libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LIBADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la
|
||||
# libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la
|
||||
nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS = -no-undefined \
|
||||
-export-dynamic -version-number \
|
||||
@PNGLIB_MAJOR@@PNGLIB_MINOR@:@PNGLIB_RELEASE@:0 \
|
||||
$(am__append_8) $(am__append_9) $(am__append_10)
|
||||
@HAVE_LD_VERSION_SCRIPT_FALSE@libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = \
|
||||
@HAVE_LD_VERSION_SCRIPT_FALSE@ libpng.sym $(am__append_11)
|
||||
@HAVE_LD_VERSION_SCRIPT_FALSE@ libpng.sym $(am__append_11) \
|
||||
@HAVE_LD_VERSION_SCRIPT_FALSE@ $(am__append_12)
|
||||
@HAVE_LD_VERSION_SCRIPT_TRUE@libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = \
|
||||
@HAVE_LD_VERSION_SCRIPT_TRUE@ libpng.vers $(am__append_11)
|
||||
@HAVE_LD_VERSION_SCRIPT_TRUE@ libpng.vers $(am__append_11) \
|
||||
@HAVE_LD_VERSION_SCRIPT_TRUE@ $(am__append_12)
|
||||
pkginclude_HEADERS = png.h pngconf.h
|
||||
nodist_pkginclude_HEADERS = pnglibconf.h
|
||||
pkgconfig_DATA = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc
|
||||
@ -875,7 +899,7 @@ SUFFIXES = .chk .out
|
||||
SYMBOL_CFLAGS = -DPNGLIB_LIBNAME='PNG@PNGLIB_MAJOR@@PNGLIB_MINOR@_0' \
|
||||
-DPNGLIB_VERSION='@PNGLIB_VERSION@' \
|
||||
-DSYMBOL_PREFIX='$(SYMBOL_PREFIX)' -DPNG_NO_USE_READ_MACROS \
|
||||
-DPNG_BUILDING_SYMBOL_TABLE $(am__append_12)
|
||||
-DPNG_BUILDING_SYMBOL_TABLE $(am__append_13)
|
||||
|
||||
# EXT_LIST is a list of the possibly library directory extensions, this exists
|
||||
# because we can't find a good way of discovering the file extensions that are
|
||||
@ -1087,6 +1111,19 @@ loongarch/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la-filter_lsx_intrinsics.lo: \
|
||||
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la: $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_OBJECTS) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_DEPENDENCIES) $(EXTRA_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_DEPENDENCIES)
|
||||
$(AM_V_CCLD)$(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_LINK) $(am_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_rpath) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_OBJECTS) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_LIBADD) $(LIBS)
|
||||
riscv/$(am__dirstamp):
|
||||
@$(MKDIR_P) riscv
|
||||
@: >>riscv/$(am__dirstamp)
|
||||
riscv/$(DEPDIR)/$(am__dirstamp):
|
||||
@$(MKDIR_P) riscv/$(DEPDIR)
|
||||
@: >>riscv/$(DEPDIR)/$(am__dirstamp)
|
||||
riscv/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-riscv_init.lo: \
|
||||
riscv/$(am__dirstamp) riscv/$(DEPDIR)/$(am__dirstamp)
|
||||
riscv/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-filter_rvv_intrinsics.lo: \
|
||||
riscv/$(am__dirstamp) riscv/$(DEPDIR)/$(am__dirstamp)
|
||||
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv.la: $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_OBJECTS) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_DEPENDENCIES) $(EXTRA_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_DEPENDENCIES)
|
||||
$(AM_V_CCLD)$(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_LINK) $(am_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_rpath) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_OBJECTS) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_LIBADD) $(LIBS)
|
||||
contrib/tools/$(am__dirstamp):
|
||||
@$(MKDIR_P) contrib/tools
|
||||
@: >>contrib/tools/$(am__dirstamp)
|
||||
@ -1202,6 +1239,8 @@ mostlyclean-compile:
|
||||
-rm -f mips/*.lo
|
||||
-rm -f powerpc/*.$(OBJEXT)
|
||||
-rm -f powerpc/*.lo
|
||||
-rm -f riscv/*.$(OBJEXT)
|
||||
-rm -f riscv/*.lo
|
||||
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
@ -1242,6 +1281,8 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@mips/$(DEPDIR)/mips_init.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@powerpc/$(DEPDIR)/filter_vsx_intrinsics.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@powerpc/$(DEPDIR)/powerpc_init.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@riscv/$(DEPDIR)/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-filter_rvv_intrinsics.Plo@am__quote@ # am--include-marker
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@riscv/$(DEPDIR)/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-riscv_init.Plo@am__quote@ # am--include-marker
|
||||
|
||||
$(am__depfiles_remade):
|
||||
@$(MKDIR_P) $(@D)
|
||||
@ -1287,6 +1328,20 @@ loongarch/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la-filter_lsx_intrinsics.lo: loo
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_CFLAGS) $(CFLAGS) -c -o loongarch/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la-filter_lsx_intrinsics.lo `test -f 'loongarch/filter_lsx_intrinsics.c' || echo '$(srcdir)/'`loongarch/filter_lsx_intrinsics.c
|
||||
|
||||
riscv/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-riscv_init.lo: riscv/riscv_init.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_CFLAGS) $(CFLAGS) -MT riscv/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-riscv_init.lo -MD -MP -MF riscv/$(DEPDIR)/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-riscv_init.Tpo -c -o riscv/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-riscv_init.lo `test -f 'riscv/riscv_init.c' || echo '$(srcdir)/'`riscv/riscv_init.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) riscv/$(DEPDIR)/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-riscv_init.Tpo riscv/$(DEPDIR)/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-riscv_init.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='riscv/riscv_init.c' object='riscv/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-riscv_init.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_CFLAGS) $(CFLAGS) -c -o riscv/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-riscv_init.lo `test -f 'riscv/riscv_init.c' || echo '$(srcdir)/'`riscv/riscv_init.c
|
||||
|
||||
riscv/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-filter_rvv_intrinsics.lo: riscv/filter_rvv_intrinsics.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_CFLAGS) $(CFLAGS) -MT riscv/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-filter_rvv_intrinsics.lo -MD -MP -MF riscv/$(DEPDIR)/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-filter_rvv_intrinsics.Tpo -c -o riscv/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-filter_rvv_intrinsics.lo `test -f 'riscv/filter_rvv_intrinsics.c' || echo '$(srcdir)/'`riscv/filter_rvv_intrinsics.c
|
||||
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) riscv/$(DEPDIR)/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-filter_rvv_intrinsics.Tpo riscv/$(DEPDIR)/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-filter_rvv_intrinsics.Plo
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='riscv/filter_rvv_intrinsics.c' object='riscv/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-filter_rvv_intrinsics.lo' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la_CFLAGS) $(CFLAGS) -c -o riscv/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-filter_rvv_intrinsics.lo `test -f 'riscv/filter_rvv_intrinsics.c' || echo '$(srcdir)/'`riscv/filter_rvv_intrinsics.c
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
@ -1297,6 +1352,7 @@ clean-libtool:
|
||||
-rm -rf loongarch/.libs loongarch/_libs
|
||||
-rm -rf mips/.libs mips/_libs
|
||||
-rm -rf powerpc/.libs powerpc/_libs
|
||||
-rm -rf riscv/.libs riscv/_libs
|
||||
|
||||
distclean-libtool:
|
||||
-rm -f libtool config.lt
|
||||
@ -1913,6 +1969,7 @@ tests/pngimage-full.log: tests/pngimage-full
|
||||
@am__EXEEXT_TRUE@ --log-file $$b.log --trs-file $$b.trs \
|
||||
@am__EXEEXT_TRUE@ $(am__common_driver_flags) $(AM_TEST_LOG_DRIVER_FLAGS) $(TEST_LOG_DRIVER_FLAGS) -- $(TEST_LOG_COMPILE) \
|
||||
@am__EXEEXT_TRUE@ "$$tst" $(AM_TESTS_FD_REDIRECT)
|
||||
|
||||
distdir: $(BUILT_SOURCES)
|
||||
$(MAKE) $(AM_MAKEFLAGS) distdir-am
|
||||
|
||||
@ -1966,6 +2023,10 @@ dist-bzip2: distdir
|
||||
tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist-bzip3: distdir
|
||||
tardir=$(distdir) && $(am__tar) | bzip3 -c >$(distdir).tar.bz3
|
||||
$(am__post_remove_distdir)
|
||||
|
||||
dist-lzip: distdir
|
||||
tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
|
||||
$(am__post_remove_distdir)
|
||||
@ -2009,6 +2070,8 @@ distcheck: dist
|
||||
eval GZIP= gzip -dc $(distdir).tar.gz | $(am__untar) ;;\
|
||||
*.tar.bz2*) \
|
||||
bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
|
||||
*.tar.bz3*) \
|
||||
bzip3 -dc $(distdir).tar.bz3 | $(am__untar) ;;\
|
||||
*.tar.lz*) \
|
||||
lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
|
||||
*.tar.xz*) \
|
||||
@ -2148,6 +2211,8 @@ distclean-generic:
|
||||
-$(am__rm_f) mips/$(am__dirstamp)
|
||||
-$(am__rm_f) powerpc/$(DEPDIR)/$(am__dirstamp)
|
||||
-$(am__rm_f) powerpc/$(am__dirstamp)
|
||||
-$(am__rm_f) riscv/$(DEPDIR)/$(am__dirstamp)
|
||||
-$(am__rm_f) riscv/$(am__dirstamp)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@ -2201,6 +2266,8 @@ distclean: distclean-am
|
||||
-rm -f mips/$(DEPDIR)/mips_init.Plo
|
||||
-rm -f powerpc/$(DEPDIR)/filter_vsx_intrinsics.Plo
|
||||
-rm -f powerpc/$(DEPDIR)/powerpc_init.Plo
|
||||
-rm -f riscv/$(DEPDIR)/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-filter_rvv_intrinsics.Plo
|
||||
-rm -f riscv/$(DEPDIR)/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-riscv_init.Plo
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-hdr distclean-libtool distclean-tags
|
||||
@ -2288,6 +2355,8 @@ maintainer-clean: maintainer-clean-am
|
||||
-rm -f mips/$(DEPDIR)/mips_init.Plo
|
||||
-rm -f powerpc/$(DEPDIR)/filter_vsx_intrinsics.Plo
|
||||
-rm -f powerpc/$(DEPDIR)/powerpc_init.Plo
|
||||
-rm -f riscv/$(DEPDIR)/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-filter_rvv_intrinsics.Plo
|
||||
-rm -f riscv/$(DEPDIR)/libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv_la-riscv_init.Plo
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
@ -2320,15 +2389,15 @@ uninstall-man: uninstall-man3 uninstall-man5
|
||||
clean-checkPROGRAMS clean-cscope clean-generic \
|
||||
clean-libLTLIBRARIES clean-libtool clean-noinstLTLIBRARIES \
|
||||
cscope cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \
|
||||
dist-gzip dist-hook dist-lzip dist-shar dist-tarZ dist-xz \
|
||||
dist-zip dist-zstd distcheck distclean distclean-compile \
|
||||
distclean-generic distclean-hdr distclean-libtool \
|
||||
distclean-tags distcleancheck distdir distuninstallcheck dvi \
|
||||
dvi-am html html-am info info-am install install-am \
|
||||
install-binPROGRAMS install-binSCRIPTS install-data \
|
||||
install-data-am install-data-hook install-dvi install-dvi-am \
|
||||
install-exec install-exec-am install-exec-hook install-html \
|
||||
install-html-am install-info install-info-am \
|
||||
dist-bzip3 dist-gzip dist-hook dist-lzip dist-shar dist-tarZ \
|
||||
dist-xz dist-zip dist-zstd distcheck distclean \
|
||||
distclean-compile distclean-generic distclean-hdr \
|
||||
distclean-libtool distclean-tags distcleancheck distdir \
|
||||
distuninstallcheck dvi dvi-am html html-am info info-am \
|
||||
install install-am install-binPROGRAMS install-binSCRIPTS \
|
||||
install-data install-data-am install-data-hook install-dvi \
|
||||
install-dvi-am install-exec install-exec-am install-exec-hook \
|
||||
install-html install-html-am install-info install-info-am \
|
||||
install-libLTLIBRARIES install-man install-man3 install-man5 \
|
||||
install-nodist_pkgincludeHEADERS install-pdf install-pdf-am \
|
||||
install-pkgconfigDATA install-pkgincludeHEADERS install-ps \
|
||||
|
6
README
6
README
@ -1,5 +1,5 @@
|
||||
README for libpng version 1.6.46
|
||||
================================
|
||||
README for libpng version 1.6.51.git
|
||||
====================================
|
||||
|
||||
See the note about version numbers near the top of `png.h`.
|
||||
See `INSTALL` for instructions on how to install libpng.
|
||||
@ -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
|
||||
|
72
aclocal.m4
vendored
72
aclocal.m4
vendored
@ -1,6 +1,6 @@
|
||||
# generated automatically by aclocal 1.17 -*- Autoconf -*-
|
||||
# generated automatically by aclocal 1.18.1 -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2025 Free Software Foundation, Inc.
|
||||
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -20,7 +20,7 @@ You have another version of autoconf. It may work, but is not guaranteed to.
|
||||
If you have problems, you may need to regenerate the build system entirely.
|
||||
To do so, use the procedure documented by the package, typically 'autoreconf'.])])
|
||||
|
||||
# Copyright (C) 2002-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2025 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -32,10 +32,10 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.])
|
||||
# generated from the m4 files accompanying Automake X.Y.
|
||||
# (This private macro should not be called outside this file.)
|
||||
AC_DEFUN([AM_AUTOMAKE_VERSION],
|
||||
[am__api_version='1.17'
|
||||
[am__api_version='1.18'
|
||||
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
|
||||
dnl require some minimum version. Point them to the right macro.
|
||||
m4_if([$1], [1.17], [],
|
||||
m4_if([$1], [1.18.1], [],
|
||||
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
|
||||
])
|
||||
|
||||
@ -51,14 +51,14 @@ m4_define([_AM_AUTOCONF_VERSION], [])
|
||||
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
|
||||
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
|
||||
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
|
||||
[AM_AUTOMAKE_VERSION([1.17])dnl
|
||||
[AM_AUTOMAKE_VERSION([1.18.1])dnl
|
||||
m4_ifndef([AC_AUTOCONF_VERSION],
|
||||
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
|
||||
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
|
||||
|
||||
# Figure out how to run the assembler. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2001-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2025 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -78,7 +78,7 @@ _AM_IF_OPTION([no-dependencies],, [_AM_DEPENDENCIES([CCAS])])dnl
|
||||
|
||||
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2001-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2025 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -130,7 +130,7 @@ am_aux_dir=`cd "$ac_aux_dir" && pwd`
|
||||
|
||||
# AM_CONDITIONAL -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1997-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1997-2025 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -161,7 +161,7 @@ AC_CONFIG_COMMANDS_PRE(
|
||||
Usually this means the macro was only invoked conditionally.]])
|
||||
fi])])
|
||||
|
||||
# Copyright (C) 1999-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999-2025 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -352,7 +352,7 @@ _AM_SUBST_NOTMAKE([am__nodep])dnl
|
||||
|
||||
# Generate code to set up dependency tracking. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1999-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999-2025 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -420,7 +420,7 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
|
||||
|
||||
# Do all the work for Automake. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2025 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -520,8 +520,9 @@ AC_REQUIRE([AC_PROG_AWK])dnl
|
||||
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
|
||||
AC_REQUIRE([AM_SET_LEADING_DOT])dnl
|
||||
_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
|
||||
[_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
|
||||
[_AM_PROG_TAR([v7])])])
|
||||
[_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
|
||||
[_AM_IF_OPTION([tar-v7], [_AM_PROG_TAR([v7])],
|
||||
[_AM_PROG_TAR([ustar])])])])
|
||||
_AM_IF_OPTION([no-dependencies],,
|
||||
[AC_PROVIDE_IFELSE([AC_PROG_CC],
|
||||
[_AM_DEPENDENCIES([CC])],
|
||||
@ -597,7 +598,7 @@ for _am_header in $config_headers :; do
|
||||
done
|
||||
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
|
||||
|
||||
# Copyright (C) 2001-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2025 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -618,7 +619,7 @@ if test x"${install_sh+set}" != xset; then
|
||||
fi
|
||||
AC_SUBST([install_sh])])
|
||||
|
||||
# Copyright (C) 2003-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003-2025 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -640,7 +641,7 @@ AC_SUBST([am__leading_dot])])
|
||||
# Add --enable-maintainer-mode option to configure. -*- Autoconf -*-
|
||||
# From Jim Meyering
|
||||
|
||||
# Copyright (C) 1996-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2025 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -675,7 +676,7 @@ AC_MSG_CHECKING([whether to enable maintainer-specific portions of Makefiles])
|
||||
|
||||
# Check to see how 'make' treats includes. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2001-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2025 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -718,7 +719,7 @@ AC_SUBST([am__quote])])
|
||||
|
||||
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1997-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1997-2025 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -752,7 +753,7 @@ fi
|
||||
|
||||
# Helper functions for option handling. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2001-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2025 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -781,7 +782,7 @@ AC_DEFUN([_AM_SET_OPTIONS],
|
||||
AC_DEFUN([_AM_IF_OPTION],
|
||||
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
|
||||
|
||||
# Copyright (C) 1999-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999-2025 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -813,7 +814,10 @@ AC_CACHE_CHECK(
|
||||
break
|
||||
fi
|
||||
done
|
||||
rm -f core conftest*
|
||||
# aligned with autoconf, so not including core; see bug#72225.
|
||||
rm -f -r a.out a.exe b.out conftest.$ac_ext conftest.$ac_objext \
|
||||
conftest.dSYM conftest1.$ac_ext conftest1.$ac_objext conftest1.dSYM \
|
||||
conftest2.$ac_ext conftest2.$ac_objext conftest2.dSYM
|
||||
unset am_i])
|
||||
if test "$am_cv_prog_cc_c_o" != yes; then
|
||||
# Losing compiler, so override with the script.
|
||||
@ -828,7 +832,7 @@ AC_LANG_POP([C])])
|
||||
# For backward compatibility.
|
||||
AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])])
|
||||
|
||||
# Copyright (C) 2022-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2022-2025 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -844,7 +848,7 @@ AS_IF([(rm -f && rm -fr && rm -rf) 2>/dev/null], [], [am__rm_f_notfound='""'])
|
||||
AC_SUBST(am__rm_f_notfound)
|
||||
])
|
||||
|
||||
# Copyright (C) 2001-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2025 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -863,7 +867,7 @@ AC_DEFUN([AM_RUN_LOG],
|
||||
|
||||
# Check to make sure that the build environment is sane. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2025 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -1032,10 +1036,12 @@ am_lf='
|
||||
'
|
||||
case `pwd` in
|
||||
*[[\\\"\#\$\&\'\`$am_lf]]*)
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_ERROR([unsafe absolute working directory name]);;
|
||||
esac
|
||||
case $srcdir in
|
||||
*[[\\\"\#\$\&\'\`$am_lf\ \ ]]*)
|
||||
AC_MSG_RESULT([no])
|
||||
AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);;
|
||||
esac
|
||||
|
||||
@ -1088,7 +1094,7 @@ AC_CONFIG_COMMANDS_PRE(
|
||||
rm -f conftest.file
|
||||
])
|
||||
|
||||
# Copyright (C) 2009-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2009-2025 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -1157,9 +1163,13 @@ fi
|
||||
# empty being verbose).
|
||||
AC_DEFUN([AM_SILENT_RULES],
|
||||
[AC_REQUIRE([_AM_SILENT_RULES])
|
||||
AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1])])
|
||||
AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1])m4_newline
|
||||
dnl We intentionally force a newline after the assignment, since a) nothing
|
||||
dnl good can come of more text following, and b) that was the behavior
|
||||
dnl before 1.17. See https://bugs.gnu.org/72267.
|
||||
])
|
||||
|
||||
# Copyright (C) 2001-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2025 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -1187,7 +1197,7 @@ fi
|
||||
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
|
||||
AC_SUBST([INSTALL_STRIP_PROGRAM])])
|
||||
|
||||
# Copyright (C) 2006-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2006-2025 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -1206,7 +1216,7 @@ AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
|
||||
|
||||
# Check how to create a tarball. -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 2004-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2004-2025 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -1341,7 +1351,7 @@ AC_SUBST([am__tar])
|
||||
AC_SUBST([am__untar])
|
||||
]) # _AM_PROG_TAR
|
||||
|
||||
# Copyright (C) 2022-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2022-2025 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
|
@ -35,14 +35,14 @@
|
||||
#ifndef PNG_ARM_NEON_FILE
|
||||
# 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"
|
||||
# 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"
|
||||
# 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"
|
||||
# error No support for run-time ARM Neon checking; use compile-time options
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@ -53,7 +53,7 @@ static int png_have_neon(png_structp png_ptr);
|
||||
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
|
||||
|
||||
#ifndef PNG_ALIGNED_MEMORY_SUPPORTED
|
||||
# error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED"
|
||||
# error ALIGNED_MEMORY is required; please define PNG_ALIGNED_MEMORY_SUPPORTED
|
||||
#endif
|
||||
|
||||
void
|
||||
|
@ -4,7 +4,7 @@ Scripts for the Continuous Integration of the PNG Reference Library
|
||||
Copyright Notice
|
||||
----------------
|
||||
|
||||
Copyright (c) 2019-2024 Cosmin Truta.
|
||||
Copyright (c) 2019-2025 Cosmin Truta.
|
||||
|
||||
Use, modification and distribution are subject to the MIT License.
|
||||
Please see the accompanying file `LICENSE_MIT.txt` or visit
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit -o pipefail -o posix
|
||||
|
||||
# Copyright (c) 2019-2024 Cosmin Truta.
|
||||
# Copyright (c) 2019-2025 Cosmin Truta.
|
||||
#
|
||||
# Use, modification and distribution are subject to the MIT License.
|
||||
# Please see the accompanying file LICENSE_MIT.txt
|
||||
@ -61,7 +61,7 @@ function ci_lint_ci_scripts {
|
||||
}
|
||||
ci_info "## LINTING: CI scripts ##"
|
||||
ci_spawn "$CI_SHELLCHECK" --version
|
||||
find ./ci -maxdepth 1 -name "*.sh" | {
|
||||
find ./ci -name "ci_*.sh" -not -name "ci_env.*.sh" | {
|
||||
local my_file
|
||||
while IFS="" read -r my_file
|
||||
do
|
||||
|
@ -1,92 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit -o pipefail -o posix
|
||||
|
||||
# Copyright (c) 2019-2024 Cosmin Truta.
|
||||
#
|
||||
# Use, modification and distribution are subject to the MIT License.
|
||||
# Please see the accompanying file LICENSE_MIT.txt
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
# shellcheck source=ci/lib/ci.lib.sh
|
||||
source "$(dirname "$0")/lib/ci.lib.sh"
|
||||
cd "$CI_TOPLEVEL_DIR"
|
||||
|
||||
function ci_shellify_c {
|
||||
# Convert C preprocessor text, specifically originating
|
||||
# from png.h, to shell scripting text.
|
||||
# Select only the easy-to-parse definitions of PNG_LIBPNG_*.
|
||||
sed -n -e '/^\# *define * PNG_LIBPNG_[^ ]* * ["0-9A-Za-z_]/ p' |
|
||||
sed -e 's/^\# *define * PNG\([^ ]*\) * \([^ ]*\)/PNG\1=\2/' \
|
||||
-e 's/=PNG\([0-9A-Za-z_]*\)/=\${PNG\1}/' \
|
||||
-e 's/^\([^ ]*=[^ ]*\).*$/export \1;/'
|
||||
}
|
||||
|
||||
function ci_shellify_autoconf {
|
||||
# Convert autoconf (M4) text, specifically originating
|
||||
# from configure.ac, to shell scripting text.
|
||||
# Select only the easy-to-parse definitions of PNGLIB_*.
|
||||
sed -n -e '/^ *PNGLIB_[^ ]*=[$"0-9A-Za-z_]/ p' |
|
||||
sed -e 's/^ *PNG\([0-9A-Za-z_]*\)=\([^# ]*\).*$/PNG\1=\2/' \
|
||||
-e 's/^\([^ ]*=[^ ]*\).*$/export \1;/'
|
||||
}
|
||||
|
||||
function ci_shellify_cmake {
|
||||
# Convert CMake lists text, specifically originating
|
||||
# from CMakeLists.txt, to shell scripting text.
|
||||
# Select only the easy-to-parse definitions of PNGLIB_*.
|
||||
sed -n -e '/^ *set *(PNGLIB_[^ ]* * [$"0-9A-Za-z_].*)/ p' |
|
||||
sed -e 's/^ *set *(PNG\([^ ]*\) * \([^() ]*\)).*$/PNG\1=\2/' \
|
||||
-e 's/^\([^ ]*=[^ ]*\).*$/export \1;/'
|
||||
}
|
||||
|
||||
function ci_shellify {
|
||||
local arg filename
|
||||
for arg in "$@"
|
||||
do
|
||||
test -f "$arg" || ci_err "no such file: '$arg'"
|
||||
filename="$(basename -- "$arg")"
|
||||
case "$filename" in
|
||||
( *.[ch] )
|
||||
[[ $filename == png.h ]] || {
|
||||
ci_err "unable to shellify: '$filename' (expecting: 'png.h')"
|
||||
}
|
||||
ci_shellify_c <"$arg" ;;
|
||||
( config* | *.ac )
|
||||
[[ $filename == configure.ac ]] || {
|
||||
ci_err "unable to shellify: '$filename' (expecting: 'configure.ac')"
|
||||
}
|
||||
ci_shellify_autoconf <"$arg" ;;
|
||||
( *CMake* | *cmake* | *.txt )
|
||||
[[ $filename == [Cc][Mm]ake[Ll]ists.txt ]] || {
|
||||
ci_err "unable to shellify: '$filename' (expecting: 'CMakeLists.txt')"
|
||||
}
|
||||
ci_shellify_cmake <"$arg" ;;
|
||||
( * )
|
||||
ci_err "unable to shellify: '$arg'" ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
function usage {
|
||||
echo "usage: $CI_SCRIPT_NAME [<options>] <files>..."
|
||||
echo "options: -?|-h|--help"
|
||||
echo "files: png.h|configure.ac|CMakeLists.txt"
|
||||
exit "${@:-0}"
|
||||
}
|
||||
|
||||
function main {
|
||||
local opt
|
||||
while getopts ":" opt
|
||||
do
|
||||
# This ain't a while-loop. It only pretends to be.
|
||||
[[ $1 == -[?h]* || $1 == --help || $1 == --help=* ]] && usage 0
|
||||
ci_err "unknown option: '$1'"
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
[[ $# -eq 0 ]] && usage 2
|
||||
# And... go!
|
||||
ci_shellify "$@"
|
||||
}
|
||||
|
||||
main "$@"
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit -o pipefail -o posix
|
||||
|
||||
# Copyright (c) 2019-2024 Cosmin Truta.
|
||||
# Copyright (c) 2019-2025 Cosmin Truta.
|
||||
#
|
||||
# Use, modification and distribution are subject to the MIT License.
|
||||
# Please see the accompanying file LICENSE_MIT.txt
|
||||
@ -64,6 +64,7 @@ function ci_trace_build {
|
||||
ci_info "environment option: \$CI_RANLIB: '$CI_RANLIB'"
|
||||
ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'"
|
||||
ci_info "environment option: \$CI_FORCE: '$CI_FORCE'"
|
||||
ci_info "environment option: \$CI_NO_BUILD: '$CI_NO_BUILD'"
|
||||
ci_info "environment option: \$CI_NO_TEST: '$CI_NO_TEST'"
|
||||
ci_info "environment option: \$CI_NO_INSTALL: '$CI_NO_INSTALL'"
|
||||
ci_info "environment option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'"
|
||||
@ -148,10 +149,12 @@ function ci_build {
|
||||
-S . \
|
||||
-DCMAKE_INSTALL_PREFIX="$CI_INSTALL_DIR" \
|
||||
"${all_cmake_vars[@]}"
|
||||
# Spawn "cmake --build ...".
|
||||
ci_spawn "$CI_CMAKE" --build "$CI_BUILD_DIR" \
|
||||
--config "$CI_CMAKE_BUILD_TYPE" \
|
||||
"${all_cmake_build_flags[@]}"
|
||||
ci_expr $((CI_NO_BUILD)) || {
|
||||
# Spawn "cmake --build ...".
|
||||
ci_spawn "$CI_CMAKE" --build "$CI_BUILD_DIR" \
|
||||
--config "$CI_CMAKE_BUILD_TYPE" \
|
||||
"${all_cmake_build_flags[@]}"
|
||||
}
|
||||
ci_expr $((CI_NO_TEST)) || {
|
||||
# Spawn "ctest" if testing is not disabled.
|
||||
ci_spawn pushd "$CI_BUILD_DIR"
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit -o pipefail -o posix
|
||||
|
||||
# Copyright (c) 2019-2024 Cosmin Truta.
|
||||
# Copyright (c) 2019-2025 Cosmin Truta.
|
||||
#
|
||||
# Use, modification and distribution are subject to the MIT License.
|
||||
# Please see the accompanying file LICENSE_MIT.txt
|
||||
@ -58,6 +58,7 @@ function ci_trace_build {
|
||||
ci_info "environment option: \$CI_LD_FLAGS: '$CI_LD_FLAGS'"
|
||||
ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'"
|
||||
ci_info "environment option: \$CI_FORCE: '$CI_FORCE'"
|
||||
ci_info "environment option: \$CI_NO_BUILD: '$CI_NO_BUILD'"
|
||||
ci_info "environment option: \$CI_NO_TEST: '$CI_NO_TEST'"
|
||||
ci_info "environment option: \$CI_NO_INSTALL: '$CI_NO_INSTALL'"
|
||||
ci_info "environment option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'"
|
||||
@ -131,8 +132,10 @@ function ci_build {
|
||||
ci_spawn cd "$CI_BUILD_DIR"
|
||||
# Spawn "configure".
|
||||
ci_spawn "$CI_SRC_DIR/configure" --prefix="$CI_INSTALL_DIR" $CI_CONFIGURE_FLAGS
|
||||
# Spawn "make".
|
||||
ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS
|
||||
ci_expr $((CI_NO_BUILD)) || {
|
||||
# Spawn "make".
|
||||
ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS
|
||||
}
|
||||
ci_expr $((CI_NO_TEST)) || {
|
||||
# Spawn "make test" if testing is not disabled.
|
||||
ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS test
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit -o pipefail -o posix
|
||||
|
||||
# Copyright (c) 2019-2024 Cosmin Truta.
|
||||
# Copyright (c) 2019-2025 Cosmin Truta.
|
||||
#
|
||||
# Use, modification and distribution are subject to the MIT License.
|
||||
# Please see the accompanying file LICENSE_MIT.txt
|
||||
@ -51,6 +51,7 @@ function ci_trace_build {
|
||||
ci_info "environment option: \$CI_LIBS: '$CI_LIBS'"
|
||||
ci_info "environment option: \$CI_SANITIZERS: '$CI_SANITIZERS'"
|
||||
ci_info "environment option: \$CI_FORCE: '$CI_FORCE'"
|
||||
ci_info "environment option: \$CI_NO_BUILD: '$CI_NO_BUILD'"
|
||||
ci_info "environment option: \$CI_NO_TEST: '$CI_NO_TEST'"
|
||||
ci_info "environment option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'"
|
||||
ci_info "executable: \$CI_MAKE: $(command -V "$CI_MAKE")"
|
||||
@ -145,10 +146,12 @@ function ci_build {
|
||||
for my_makefile in $CI_MAKEFILES
|
||||
do
|
||||
ci_info "using makefile: $my_makefile"
|
||||
# Spawn "make".
|
||||
ci_spawn "$CI_MAKE" -f "$my_makefile" \
|
||||
"${all_make_flags[@]}" \
|
||||
"${all_make_vars[@]}"
|
||||
ci_expr $((CI_NO_BUILD)) || {
|
||||
# Spawn "make".
|
||||
ci_spawn "$CI_MAKE" -f "$my_makefile" \
|
||||
"${all_make_flags[@]}" \
|
||||
"${all_make_vars[@]}"
|
||||
}
|
||||
ci_expr $((CI_NO_TEST)) || {
|
||||
# Spawn "make test" if testing is not disabled.
|
||||
ci_spawn "$CI_MAKE" -f "$my_makefile" \
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit -o pipefail -o posix
|
||||
|
||||
# Copyright (c) 2019-2024 Cosmin Truta.
|
||||
# Copyright (c) 2019-2025 Cosmin Truta.
|
||||
#
|
||||
# Use, modification and distribution are subject to the MIT License.
|
||||
# Please see the accompanying file LICENSE_MIT.txt
|
||||
@ -12,33 +12,43 @@ set -o errexit -o pipefail -o posix
|
||||
source "$(dirname "$0")/lib/ci.lib.sh"
|
||||
cd "$CI_TOPLEVEL_DIR"
|
||||
|
||||
function ci_init_shellify {
|
||||
[[ -f $CI_SCRIPT_DIR/ci_shellify.sh ]] || {
|
||||
ci_err_internal "missing script: '$CI_SCRIPT_DIR/ci_shellify.sh'"
|
||||
}
|
||||
}
|
||||
# Declare the global environments collected from various sources.
|
||||
declare CI_ENV_LIBPNG_VER # collected from png.h
|
||||
declare CI_ENV_AUTOCONF_VER # collected from configure.ac
|
||||
declare CI_ENV_CMAKE_VER # collected from CMakeLists.txt
|
||||
declare CI_ENV_LIBPNGCONFIG_VER # collected from scripts/libpng-config-head.in
|
||||
|
||||
function ci_run_shellify {
|
||||
local my_script my_result
|
||||
my_script="$CI_SCRIPT_DIR/libexec/ci_shellify_${1#--}.sh"
|
||||
shift 1
|
||||
[[ -f $my_script ]] || {
|
||||
ci_err_internal "missing script: '$my_script'"
|
||||
}
|
||||
ci_info "shellifying:" "$@"
|
||||
local my_result
|
||||
"$BASH" "$CI_SCRIPT_DIR/ci_shellify.sh" "$@"
|
||||
"$BASH" "$my_script" "$@"
|
||||
echo "$my_result" | "$BASH" --posix || ci_err "bad shellify output"
|
||||
echo "$my_result"
|
||||
}
|
||||
|
||||
function ci_verify_version {
|
||||
function ci_init_version_verification {
|
||||
ci_info "## START OF VERIFICATION ##"
|
||||
local my_env_libpng_ver my_env_autoconf_ver my_env_cmake_ver my_expect
|
||||
ci_init_shellify
|
||||
my_env_libpng_ver="$(ci_run_shellify png.h)"
|
||||
echo "$my_env_libpng_ver"
|
||||
my_env_autoconf_ver="$(ci_run_shellify configure.ac)"
|
||||
echo "$my_env_autoconf_ver"
|
||||
my_env_cmake_ver="$(ci_run_shellify CMakeLists.txt)"
|
||||
echo "$my_env_cmake_ver"
|
||||
ci_info "## VERIFYING: png.h version definitions ##"
|
||||
eval "$my_env_libpng_ver"
|
||||
local my_expect="${PNG_LIBPNG_VER_MAJOR}.${PNG_LIBPNG_VER_MINOR}.${PNG_LIBPNG_VER_RELEASE}"
|
||||
CI_ENV_LIBPNG_VER="$(ci_run_shellify --c png.h)"
|
||||
echo "$CI_ENV_LIBPNG_VER"
|
||||
CI_ENV_AUTOCONF_VER="$(ci_run_shellify --autoconf configure.ac)"
|
||||
echo "$CI_ENV_AUTOCONF_VER"
|
||||
CI_ENV_CMAKE_VER="$(ci_run_shellify --cmake CMakeLists.txt)"
|
||||
echo "$CI_ENV_CMAKE_VER"
|
||||
CI_ENV_LIBPNGCONFIG_VER="$(ci_run_shellify --shell scripts/libpng-config-head.in)"
|
||||
echo "$CI_ENV_LIBPNGCONFIG_VER"
|
||||
}
|
||||
|
||||
# shellcheck disable=SC2154
|
||||
function ci_do_version_verification {
|
||||
local my_expect
|
||||
ci_info "## VERIFYING: version definitions in 'png.h' ##"
|
||||
eval "$CI_ENV_LIBPNG_VER"
|
||||
my_expect="${PNG_LIBPNG_VER_MAJOR}.${PNG_LIBPNG_VER_MINOR}.${PNG_LIBPNG_VER_RELEASE}"
|
||||
if [[ "$PNG_LIBPNG_VER_STRING" == "$my_expect"* ]]
|
||||
then
|
||||
ci_info "matched: \$PNG_LIBPNG_VER_STRING == $my_expect*"
|
||||
@ -77,7 +87,7 @@ function ci_verify_version {
|
||||
else
|
||||
ci_err "mismatched: \$PNG_LIBPNG_VER_BUILD != [01]"
|
||||
fi
|
||||
ci_info "## VERIFYING: png.h build definitions ##"
|
||||
ci_info "## VERIFYING: build definitions in 'png.h' ##"
|
||||
my_expect="${PNG_LIBPNG_VER_MAJOR}.${PNG_LIBPNG_VER_MINOR}.${PNG_LIBPNG_VER_RELEASE}"
|
||||
if [[ "$PNG_LIBPNG_VER_STRING" == "$my_expect" ]]
|
||||
then
|
||||
@ -110,19 +120,19 @@ function ci_verify_version {
|
||||
else
|
||||
ci_err "unexpected: \$PNG_LIBPNG_VER_STRING == '$PNG_LIBPNG_VER_STRING'"
|
||||
fi
|
||||
ci_info "## VERIFYING: png.h type definitions ##"
|
||||
ci_info "## VERIFYING: type definitions in 'png.h' ##"
|
||||
my_expect="$(echo "png_libpng_version_${PNG_LIBPNG_VER_STRING}" | tr . _)"
|
||||
ci_spawn grep -w -e "$my_expect" png.h
|
||||
ci_info "## VERIFYING: configure.ac version definitions ##"
|
||||
eval "$my_env_autoconf_ver"
|
||||
ci_info "## VERIFYING: version definitions in 'configure.ac' ##"
|
||||
eval "$CI_ENV_AUTOCONF_VER"
|
||||
if [[ "$PNGLIB_VERSION" == "$PNG_LIBPNG_VER_STRING" ]]
|
||||
then
|
||||
ci_info "matched: \$PNGLIB_VERSION == \$PNG_LIBPNG_VER_STRING"
|
||||
else
|
||||
ci_err "mismatched: \$PNGLIB_VERSION != \$PNG_LIBPNG_VER_STRING"
|
||||
fi
|
||||
ci_info "## VERIFYING: CMakeLists.txt version definitions ##"
|
||||
eval "$my_env_cmake_ver"
|
||||
ci_info "## VERIFYING: version definitions in 'CMakeLists.txt' ##"
|
||||
eval "$CI_ENV_CMAKE_VER"
|
||||
if [[ "$PNGLIB_VERSION" == "$PNG_LIBPNG_VER_STRING" && "$PNGLIB_SUBREVISION" == 0 ]]
|
||||
then
|
||||
ci_info "matched: \$PNGLIB_VERSION == \$PNG_LIBPNG_VER_STRING"
|
||||
@ -133,8 +143,26 @@ function ci_verify_version {
|
||||
else
|
||||
ci_err "mismatched: \$PNGLIB_VERSION != \$PNG_LIBPNG_VER_STRING"
|
||||
fi
|
||||
ci_info "## VERIFYING: version definitions in 'scripts/libpng-config-head.in' ##"
|
||||
eval "$CI_ENV_LIBPNGCONFIG_VER"
|
||||
if [[ "$version" == "$PNG_LIBPNG_VER_STRING" ]]
|
||||
then
|
||||
ci_info "matched: \$version == \$PNG_LIBPNG_VER_STRING"
|
||||
else
|
||||
ci_err "mismatched: \$version != \$PNG_LIBPNG_VER_STRING"
|
||||
fi
|
||||
}
|
||||
|
||||
function ci_finish_version_verification {
|
||||
ci_info "## END OF VERIFICATION ##"
|
||||
ci_info "success!"
|
||||
# Relying on "set -o errexit" to not reach here in case of error.
|
||||
ci_info "## SUCCESS ##"
|
||||
}
|
||||
|
||||
function ci_verify_version {
|
||||
ci_init_version_verification
|
||||
ci_do_version_verification
|
||||
ci_finish_version_verification
|
||||
}
|
||||
|
||||
function usage {
|
||||
|
@ -1,4 +1,4 @@
|
||||
# Copyright (c) 2019-2024 Cosmin Truta.
|
||||
# Copyright (c) 2019-2025 Cosmin Truta.
|
||||
#
|
||||
# Use, modification and distribution are subject to the MIT License.
|
||||
# Please see the accompanying file LICENSE_MIT.txt
|
||||
@ -91,6 +91,9 @@ function ci_spawn {
|
||||
[[ ${CI_FORCE:-0} == [01] ]] || {
|
||||
ci_err "bad boolean option: \$CI_FORCE: '$CI_FORCE'"
|
||||
}
|
||||
[[ ${CI_NO_BUILD:-0} == [01] ]] || {
|
||||
ci_err "bad boolean option: \$CI_NO_BUILD: '$CI_NO_BUILD'"
|
||||
}
|
||||
[[ ${CI_NO_TEST:-0} == [01] ]] || {
|
||||
ci_err "bad boolean option: \$CI_NO_TEST: '$CI_NO_TEST'"
|
||||
}
|
||||
@ -100,3 +103,9 @@ function ci_spawn {
|
||||
[[ ${CI_NO_CLEAN:-0} == [01] ]] || {
|
||||
ci_err "bad boolean option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'"
|
||||
}
|
||||
if ci_expr $((CI_NO_BUILD))
|
||||
then
|
||||
ci_expr $((CI_NO_TEST && CI_NO_INSTALL)) || {
|
||||
ci_err "\$CI_NO_BUILD requires \$CI_NO_TEST and \$CI_NO_INSTALL"
|
||||
}
|
||||
fi
|
||||
|
48
ci/libexec/ci_shellify_autoconf.sh
Executable file
48
ci/libexec/ci_shellify_autoconf.sh
Executable file
@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit -o pipefail -o posix
|
||||
|
||||
# Copyright (c) 2019-2025 Cosmin Truta.
|
||||
#
|
||||
# Use, modification and distribution are subject to the MIT License.
|
||||
# Please see the accompanying file LICENSE_MIT.txt
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
# shellcheck source=ci/lib/ci.lib.sh
|
||||
source "$(dirname "$0")/../lib/ci.lib.sh"
|
||||
|
||||
function ci_shellify_autoconf {
|
||||
# Convert autoconf (M4) text, specifically originating
|
||||
# from configure.ac, to shell scripting text.
|
||||
# Select only the easy-to-parse definitions of PNGLIB_*.
|
||||
sed -n -e '/^ *PNGLIB_[^ ]*=[$"0-9A-Za-z_]/ p' |
|
||||
sed -e 's/^ *PNG\([0-9A-Za-z_]*\)=\([^# ]*\).*$/PNG\1=\2/' \
|
||||
-e 's/^\([^ ]*=[^ ]*\).*$/export \1;/'
|
||||
}
|
||||
|
||||
function usage {
|
||||
echo "usage: $CI_SCRIPT_NAME [<options>] configure.ac"
|
||||
echo "options: -?|-h|--help"
|
||||
exit "${@:-0}"
|
||||
}
|
||||
|
||||
function main {
|
||||
local opt
|
||||
while getopts ":" opt
|
||||
do
|
||||
# This ain't a while-loop. It only pretends to be.
|
||||
[[ $1 == -[?h]* || $1 == --help || $1 == --help=* ]] && usage 0
|
||||
ci_err "unknown option: '$1'"
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
[[ $# -eq 0 ]] && usage 2
|
||||
[[ $# -eq 1 ]] || ci_err "too many operands"
|
||||
# And... go!
|
||||
test -e "$1" || ci_err "no such file: '$1'"
|
||||
[[ $(basename -- "$1") == configure.ac ]] || {
|
||||
ci_err "incorrect operand: '$1' (expecting: 'configure.ac')"
|
||||
}
|
||||
ci_shellify_autoconf <"$1"
|
||||
}
|
||||
|
||||
main "$@"
|
49
ci/libexec/ci_shellify_c.sh
Executable file
49
ci/libexec/ci_shellify_c.sh
Executable file
@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit -o pipefail -o posix
|
||||
|
||||
# Copyright (c) 2019-2025 Cosmin Truta.
|
||||
#
|
||||
# Use, modification and distribution are subject to the MIT License.
|
||||
# Please see the accompanying file LICENSE_MIT.txt
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
# shellcheck source=ci/lib/ci.lib.sh
|
||||
source "$(dirname "$0")/../lib/ci.lib.sh"
|
||||
|
||||
function ci_shellify_c {
|
||||
# Convert C preprocessor text, specifically originating
|
||||
# from png.h, to shell scripting text.
|
||||
# Select only the easy-to-parse definitions of PNG_LIBPNG_*.
|
||||
sed -n -e '/^\# *define * PNG_LIBPNG_[^ ]* * ["0-9A-Za-z_]/ p' |
|
||||
sed -e 's/^\# *define * PNG\([^ ]*\) * \([^ ]*\)/PNG\1=\2/' \
|
||||
-e 's/=PNG\([0-9A-Za-z_]*\)/=\${PNG\1}/' \
|
||||
-e 's/^\([^ ]*=[^ ]*\).*$/export \1;/'
|
||||
}
|
||||
|
||||
function usage {
|
||||
echo "usage: $CI_SCRIPT_NAME [<options>] png.h"
|
||||
echo "options: -?|-h|--help"
|
||||
exit "${@:-0}"
|
||||
}
|
||||
|
||||
function main {
|
||||
local opt
|
||||
while getopts ":" opt
|
||||
do
|
||||
# This ain't a while-loop. It only pretends to be.
|
||||
[[ $1 == -[?h]* || $1 == --help || $1 == --help=* ]] && usage 0
|
||||
ci_err "unknown option: '$1'"
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
[[ $# -eq 0 ]] && usage 2
|
||||
[[ $# -eq 1 ]] || ci_err "too many operands"
|
||||
# And... go!
|
||||
test -e "$1" || ci_err "no such file: '$1'"
|
||||
[[ $(basename -- "$1") == png.h ]] || {
|
||||
ci_err "incorrect operand: '$1' (expecting: 'png.h')"
|
||||
}
|
||||
ci_shellify_c <"$1"
|
||||
}
|
||||
|
||||
main "$@"
|
49
ci/libexec/ci_shellify_cmake.sh
Executable file
49
ci/libexec/ci_shellify_cmake.sh
Executable file
@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit -o pipefail -o posix
|
||||
|
||||
# Copyright (c) 2019-2025 Cosmin Truta.
|
||||
#
|
||||
# Use, modification and distribution are subject to the MIT License.
|
||||
# Please see the accompanying file LICENSE_MIT.txt
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
# shellcheck source=ci/lib/ci.lib.sh
|
||||
source "$(dirname "$0")/../lib/ci.lib.sh"
|
||||
|
||||
function ci_shellify_cmake {
|
||||
# Convert CMake lists text, specifically originating
|
||||
# from CMakeLists.txt, to shell scripting text.
|
||||
# Select only the easy-to-parse definitions of PNGLIB_*.
|
||||
sed -n -e '/^ *set *(PNGLIB_[^ ]* * [$"0-9A-Za-z_].*)/ p' |
|
||||
sed -e 's/^ *set *(PNG\([^ ]*\) * \([^() ]*\)).*$/PNG\1=\2/' \
|
||||
-e 's/^\([^ ]*=[^ ]*\).*$/export \1;/'
|
||||
}
|
||||
|
||||
function usage {
|
||||
echo "usage: $CI_SCRIPT_NAME [<options>] CMakeLists.txt"
|
||||
echo "options: -?|-h|--help"
|
||||
exit "${@:-0}"
|
||||
}
|
||||
|
||||
function main {
|
||||
local opt
|
||||
while getopts ":" opt
|
||||
do
|
||||
# This ain't a while-loop. It only pretends to be.
|
||||
[[ $1 == -[?h]* || $1 == --help || $1 == --help=* ]] && usage 0
|
||||
ci_err "unknown option: '$1'"
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
[[ $# -eq 0 ]] && usage 2
|
||||
[[ $# -eq 1 ]] || ci_err "too many operands"
|
||||
# And... go!
|
||||
test -e "$1" || ci_err "no such file: '$1'"
|
||||
filename="$(basename -- "$1")"
|
||||
[[ $filename == [Cc][Mm]ake[Ll]ists.txt ]] || {
|
||||
ci_err "incorrect operand: '$1' (expecting: 'CMakeLists.txt')"
|
||||
}
|
||||
ci_shellify_cmake <"$1"
|
||||
}
|
||||
|
||||
main "$@"
|
46
ci/libexec/ci_shellify_shell.sh
Executable file
46
ci/libexec/ci_shellify_shell.sh
Executable file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
set -o errexit -o pipefail -o posix
|
||||
|
||||
# Copyright (c) 2019-2025 Cosmin Truta.
|
||||
#
|
||||
# Use, modification and distribution are subject to the MIT License.
|
||||
# Please see the accompanying file LICENSE_MIT.txt
|
||||
#
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
# shellcheck source=ci/lib/ci.lib.sh
|
||||
source "$(dirname "$0")/../lib/ci.lib.sh"
|
||||
|
||||
function ci_shellify_shell {
|
||||
# Convert shell scripting text to shell scripting text.
|
||||
# Select only the easy-to-parse version definitions.
|
||||
sed -n -e '/^ *[A-Za-z_][0-9A-Za-z_]*=[0-9][^ #]* *$/ p' |
|
||||
sed -e 's/^ *\([^ ]*=[^ ]*\) *$/export \1;/'
|
||||
}
|
||||
|
||||
function usage {
|
||||
echo "usage: $CI_SCRIPT_NAME [<options>] libpng-config-head.in"
|
||||
echo "options: -?|-h|--help"
|
||||
exit "${@:-0}"
|
||||
}
|
||||
|
||||
function main {
|
||||
local opt
|
||||
while getopts ":" opt
|
||||
do
|
||||
# This ain't a while-loop. It only pretends to be.
|
||||
[[ $1 == -[?h]* || $1 == --help || $1 == --help=* ]] && usage 0
|
||||
ci_err "unknown option: '$1'"
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
[[ $# -eq 0 ]] && usage 2
|
||||
[[ $# -eq 1 ]] || ci_err "too many operands"
|
||||
# And... go!
|
||||
test -e "$1" || ci_err "no such file: '$1'"
|
||||
[[ $(basename -- "$1") == libpng-config-head.in ]] || {
|
||||
ci_err "incorrect operand: '$1' (expecting: 'libpng-config-head.in')"
|
||||
}
|
||||
ci_shellify_shell <"$1"
|
||||
}
|
||||
|
||||
main "$@"
|
35
compile
35
compile
@ -1,9 +1,9 @@
|
||||
#! /bin/sh
|
||||
# Wrapper for compilers which do not understand '-c -o'.
|
||||
|
||||
scriptversion=2024-06-19.01; # UTC
|
||||
scriptversion=2025-06-18.21; # UTC
|
||||
|
||||
# Copyright (C) 1999-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999-2025 Free Software Foundation, Inc.
|
||||
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
@ -37,11 +37,11 @@ IFS=" "" $nl"
|
||||
|
||||
file_conv=
|
||||
|
||||
# func_file_conv build_file lazy
|
||||
# func_file_conv build_file unneeded_conversions
|
||||
# Convert a $build file to $host form and store it in $file
|
||||
# Currently only supports Windows hosts. If the determined conversion
|
||||
# type is listed in (the comma separated) LAZY, no conversion will
|
||||
# take place.
|
||||
# type is listed in (the comma separated) UNNEEDED_CONVERSIONS, no
|
||||
# conversion will take place.
|
||||
func_file_conv ()
|
||||
{
|
||||
file=$1
|
||||
@ -51,9 +51,20 @@ func_file_conv ()
|
||||
# lazily determine how to convert abs files
|
||||
case `uname -s` in
|
||||
MINGW*)
|
||||
file_conv=mingw
|
||||
if test -n "$MSYSTEM" && (cygpath --version) >/dev/null 2>&1; then
|
||||
# MSYS2 environment.
|
||||
file_conv=cygwin
|
||||
else
|
||||
# Original MinGW environment.
|
||||
file_conv=mingw
|
||||
fi
|
||||
;;
|
||||
CYGWIN* | MSYS*)
|
||||
MSYS*)
|
||||
# Old MSYS environment, or MSYS2 with 32-bit MSYS2 shell.
|
||||
file_conv=cygwin
|
||||
;;
|
||||
CYGWIN*)
|
||||
# Cygwin environment.
|
||||
file_conv=cygwin
|
||||
;;
|
||||
*)
|
||||
@ -63,12 +74,14 @@ func_file_conv ()
|
||||
fi
|
||||
case $file_conv/,$2, in
|
||||
*,$file_conv,*)
|
||||
# This is the optimization mentioned above:
|
||||
# If UNNEEDED_CONVERSIONS contains $file_conv, don't convert.
|
||||
;;
|
||||
mingw/*)
|
||||
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||
;;
|
||||
cygwin/* | msys/*)
|
||||
file=`cygpath -m "$file" || echo "$file"`
|
||||
cygwin/*)
|
||||
file=`cygpath -w "$file" || echo "$file"`
|
||||
;;
|
||||
wine/*)
|
||||
file=`winepath -w "$file" || echo "$file"`
|
||||
@ -343,9 +356,9 @@ exit $ret
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp nil t)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-format: "%Y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
|
11
config.guess
vendored
11
config.guess
vendored
@ -4,7 +4,7 @@
|
||||
|
||||
# shellcheck disable=SC2006,SC2268 # see below for rationale
|
||||
|
||||
timestamp='2024-01-01'
|
||||
timestamp='2024-07-27'
|
||||
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
@ -123,7 +123,7 @@ set_cc_for_build() {
|
||||
dummy=$tmp/dummy
|
||||
case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
|
||||
,,) echo "int x;" > "$dummy.c"
|
||||
for driver in cc gcc c89 c99 ; do
|
||||
for driver in cc gcc c17 c99 c89 ; do
|
||||
if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
|
||||
CC_FOR_BUILD=$driver
|
||||
break
|
||||
@ -634,7 +634,8 @@ EOF
|
||||
sed 's/^ //' << EOF > "$dummy.c"
|
||||
#include <sys/systemcfg.h>
|
||||
|
||||
main()
|
||||
int
|
||||
main ()
|
||||
{
|
||||
if (!__power_pc())
|
||||
exit(1);
|
||||
@ -718,7 +719,8 @@ EOF
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
int main ()
|
||||
int
|
||||
main ()
|
||||
{
|
||||
#if defined(_SC_KERNEL_BITS)
|
||||
long bits = sysconf(_SC_KERNEL_BITS);
|
||||
@ -1621,6 +1623,7 @@ cat > "$dummy.c" <<EOF
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
int
|
||||
main ()
|
||||
{
|
||||
#if defined (sony)
|
||||
|
@ -108,6 +108,9 @@
|
||||
/* Enable POWERPC VSX optimizations */
|
||||
#undef PNG_POWERPC_VSX_OPT
|
||||
|
||||
/* 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. */
|
||||
|
729
config.sub
vendored
729
config.sub
vendored
@ -2,9 +2,9 @@
|
||||
# Configuration validation subroutine script.
|
||||
# Copyright 1992-2024 Free Software Foundation, Inc.
|
||||
|
||||
# shellcheck disable=SC2006,SC2268 # see below for rationale
|
||||
# shellcheck disable=SC2006,SC2268,SC2162 # see below for rationale
|
||||
|
||||
timestamp='2024-01-01'
|
||||
timestamp='2024-05-27'
|
||||
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
@ -120,7 +120,6 @@ case $# in
|
||||
esac
|
||||
|
||||
# Split fields of configuration type
|
||||
# shellcheck disable=SC2162
|
||||
saved_IFS=$IFS
|
||||
IFS="-" read field1 field2 field3 field4 <<EOF
|
||||
$1
|
||||
@ -142,10 +141,20 @@ case $1 in
|
||||
# parts
|
||||
maybe_os=$field2-$field3
|
||||
case $maybe_os in
|
||||
nto-qnx* | linux-* | uclinux-uclibc* \
|
||||
| uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
|
||||
| netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
|
||||
| storm-chaos* | os2-emx* | rtmk-nova* | managarm-* \
|
||||
cloudabi*-eabi* \
|
||||
| kfreebsd*-gnu* \
|
||||
| knetbsd*-gnu* \
|
||||
| kopensolaris*-gnu* \
|
||||
| linux-* \
|
||||
| managarm-* \
|
||||
| netbsd*-eabi* \
|
||||
| netbsd*-gnu* \
|
||||
| nto-qnx* \
|
||||
| os2-emx* \
|
||||
| rtmk-nova* \
|
||||
| storm-chaos* \
|
||||
| uclinux-gnu* \
|
||||
| uclinux-uclibc* \
|
||||
| windows-* )
|
||||
basic_machine=$field1
|
||||
basic_os=$maybe_os
|
||||
@ -161,8 +170,12 @@ case $1 in
|
||||
esac
|
||||
;;
|
||||
*-*)
|
||||
# A lone config we happen to match not fitting any pattern
|
||||
case $field1-$field2 in
|
||||
# Shorthands that happen to contain a single dash
|
||||
convex-c[12] | convex-c3[248])
|
||||
basic_machine=$field2-convex
|
||||
basic_os=
|
||||
;;
|
||||
decstation-3100)
|
||||
basic_machine=mips-dec
|
||||
basic_os=
|
||||
@ -170,28 +183,88 @@ case $1 in
|
||||
*-*)
|
||||
# Second component is usually, but not always the OS
|
||||
case $field2 in
|
||||
# Prevent following clause from handling this valid os
|
||||
# Do not treat sunos as a manufacturer
|
||||
sun*os*)
|
||||
basic_machine=$field1
|
||||
basic_os=$field2
|
||||
;;
|
||||
# Manufacturers
|
||||
3100* \
|
||||
| 32* \
|
||||
| 3300* \
|
||||
| 3600* \
|
||||
| 7300* \
|
||||
| acorn \
|
||||
| altos* \
|
||||
| apollo \
|
||||
| apple \
|
||||
| atari \
|
||||
| att* \
|
||||
| axis \
|
||||
| be \
|
||||
| bull \
|
||||
| cbm \
|
||||
| ccur \
|
||||
| cisco \
|
||||
| commodore \
|
||||
| convergent* \
|
||||
| convex* \
|
||||
| cray \
|
||||
| crds \
|
||||
| dec* \
|
||||
| delta* \
|
||||
| dg \
|
||||
| digital \
|
||||
| dolphin \
|
||||
| encore* \
|
||||
| gould \
|
||||
| harris \
|
||||
| highlevel \
|
||||
| hitachi* \
|
||||
| hp \
|
||||
| ibm* \
|
||||
| intergraph \
|
||||
| isi* \
|
||||
| knuth \
|
||||
| masscomp \
|
||||
| microblaze* \
|
||||
| mips* \
|
||||
| motorola* \
|
||||
| ncr* \
|
||||
| news \
|
||||
| next \
|
||||
| ns \
|
||||
| oki \
|
||||
| omron* \
|
||||
| pc533* \
|
||||
| rebel \
|
||||
| rom68k \
|
||||
| rombug \
|
||||
| semi \
|
||||
| sequent* \
|
||||
| siemens \
|
||||
| sgi* \
|
||||
| siemens \
|
||||
| sim \
|
||||
| sni \
|
||||
| sony* \
|
||||
| stratus \
|
||||
| sun \
|
||||
| sun[234]* \
|
||||
| tektronix \
|
||||
| tti* \
|
||||
| ultra \
|
||||
| unicom* \
|
||||
| wec \
|
||||
| winbond \
|
||||
| wrs)
|
||||
basic_machine=$field1-$field2
|
||||
basic_os=
|
||||
;;
|
||||
zephyr*)
|
||||
basic_machine=$field1-unknown
|
||||
basic_os=$field2
|
||||
;;
|
||||
# Manufacturers
|
||||
dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \
|
||||
| att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
|
||||
| unicom* | ibm* | next | hp | isi* | apollo | altos* \
|
||||
| convergent* | ncr* | news | 32* | 3600* | 3100* \
|
||||
| hitachi* | c[123]* | convex* | sun | crds | omron* | dg \
|
||||
| ultra | tti* | harris | dolphin | highlevel | gould \
|
||||
| cbm | ns | masscomp | apple | axis | knuth | cray \
|
||||
| microblaze* | sim | cisco \
|
||||
| oki | wec | wrs | winbond)
|
||||
basic_machine=$field1-$field2
|
||||
basic_os=
|
||||
;;
|
||||
*)
|
||||
basic_machine=$field1
|
||||
basic_os=$field2
|
||||
@ -272,26 +345,6 @@ case $1 in
|
||||
basic_machine=arm-unknown
|
||||
basic_os=cegcc
|
||||
;;
|
||||
convex-c1)
|
||||
basic_machine=c1-convex
|
||||
basic_os=bsd
|
||||
;;
|
||||
convex-c2)
|
||||
basic_machine=c2-convex
|
||||
basic_os=bsd
|
||||
;;
|
||||
convex-c32)
|
||||
basic_machine=c32-convex
|
||||
basic_os=bsd
|
||||
;;
|
||||
convex-c34)
|
||||
basic_machine=c34-convex
|
||||
basic_os=bsd
|
||||
;;
|
||||
convex-c38)
|
||||
basic_machine=c38-convex
|
||||
basic_os=bsd
|
||||
;;
|
||||
cray)
|
||||
basic_machine=j90-cray
|
||||
basic_os=unicos
|
||||
@ -714,15 +767,26 @@ case $basic_machine in
|
||||
vendor=dec
|
||||
basic_os=tops20
|
||||
;;
|
||||
delta | 3300 | motorola-3300 | motorola-delta \
|
||||
| 3300-motorola | delta-motorola)
|
||||
delta | 3300 | delta-motorola | 3300-motorola | motorola-delta | motorola-3300)
|
||||
cpu=m68k
|
||||
vendor=motorola
|
||||
;;
|
||||
dpx2*)
|
||||
# This used to be dpx2*, but that gets the RS6000-based
|
||||
# DPX/20 and the x86-based DPX/2-100 wrong. See
|
||||
# https://oldskool.silicium.org/stations/bull_dpx20.htm
|
||||
# https://www.feb-patrimoine.com/english/bull_dpx2.htm
|
||||
# https://www.feb-patrimoine.com/english/unix_and_bull.htm
|
||||
dpx2 | dpx2[23]00 | dpx2[23]xx)
|
||||
cpu=m68k
|
||||
vendor=bull
|
||||
basic_os=sysv3
|
||||
;;
|
||||
dpx2100 | dpx21xx)
|
||||
cpu=i386
|
||||
vendor=bull
|
||||
;;
|
||||
dpx20)
|
||||
cpu=rs6000
|
||||
vendor=bull
|
||||
;;
|
||||
encore | umax | mmax)
|
||||
cpu=ns32k
|
||||
@ -837,18 +901,6 @@ case $basic_machine in
|
||||
next | m*-next)
|
||||
cpu=m68k
|
||||
vendor=next
|
||||
case $basic_os in
|
||||
openstep*)
|
||||
;;
|
||||
nextstep*)
|
||||
;;
|
||||
ns2*)
|
||||
basic_os=nextstep2
|
||||
;;
|
||||
*)
|
||||
basic_os=nextstep3
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
np1)
|
||||
cpu=np1
|
||||
@ -937,7 +989,6 @@ case $basic_machine in
|
||||
;;
|
||||
|
||||
*-*)
|
||||
# shellcheck disable=SC2162
|
||||
saved_IFS=$IFS
|
||||
IFS="-" read cpu vendor <<EOF
|
||||
$basic_machine
|
||||
@ -972,15 +1023,19 @@ unset -v basic_machine
|
||||
|
||||
# Decode basic machines in the full and proper CPU-Company form.
|
||||
case $cpu-$vendor in
|
||||
# Here we handle the default manufacturer of certain CPU types in canonical form. It is in
|
||||
# some cases the only manufacturer, in others, it is the most popular.
|
||||
# Here we handle the default manufacturer of certain CPU types in canonical form.
|
||||
# It is in some cases the only manufacturer, in others, it is the most popular.
|
||||
c[12]-convex | c[12]-unknown | c3[248]-convex | c3[248]-unknown)
|
||||
vendor=convex
|
||||
basic_os=${basic_os:-bsd}
|
||||
;;
|
||||
craynv-unknown)
|
||||
vendor=cray
|
||||
basic_os=${basic_os:-unicosmp}
|
||||
;;
|
||||
c90-unknown | c90-cray)
|
||||
vendor=cray
|
||||
basic_os=${Basic_os:-unicos}
|
||||
basic_os=${basic_os:-unicos}
|
||||
;;
|
||||
fx80-unknown)
|
||||
vendor=alliant
|
||||
@ -1026,11 +1081,29 @@ case $cpu-$vendor in
|
||||
vendor=alt
|
||||
basic_os=${basic_os:-linux-gnueabihf}
|
||||
;;
|
||||
dpx20-unknown | dpx20-bull)
|
||||
cpu=rs6000
|
||||
vendor=bull
|
||||
|
||||
# Normalized CPU+vendor pairs that imply an OS, if not otherwise specified
|
||||
m68k-isi)
|
||||
basic_os=${basic_os:-sysv}
|
||||
;;
|
||||
m68k-sony)
|
||||
basic_os=${basic_os:-newsos}
|
||||
;;
|
||||
m68k-tektronix)
|
||||
basic_os=${basic_os:-bsd}
|
||||
;;
|
||||
m88k-harris)
|
||||
basic_os=${basic_os:-sysv3}
|
||||
;;
|
||||
i386-bull | m68k-bull)
|
||||
basic_os=${basic_os:-sysv3}
|
||||
;;
|
||||
rs6000-bull)
|
||||
basic_os=${basic_os:-bosx}
|
||||
;;
|
||||
mips-sni)
|
||||
basic_os=${basic_os:-sysv4}
|
||||
;;
|
||||
|
||||
# Here we normalize CPU types irrespective of the vendor
|
||||
amd64-*)
|
||||
@ -1038,7 +1111,7 @@ case $cpu-$vendor in
|
||||
;;
|
||||
blackfin-*)
|
||||
cpu=bfin
|
||||
basic_os=linux
|
||||
basic_os=${basic_os:-linux}
|
||||
;;
|
||||
c54x-*)
|
||||
cpu=tic54x
|
||||
@ -1061,7 +1134,7 @@ case $cpu-$vendor in
|
||||
;;
|
||||
m68knommu-*)
|
||||
cpu=m68k
|
||||
basic_os=linux
|
||||
basic_os=${basic_os:-linux}
|
||||
;;
|
||||
m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)
|
||||
cpu=s12z
|
||||
@ -1071,7 +1144,7 @@ case $cpu-$vendor in
|
||||
;;
|
||||
parisc-*)
|
||||
cpu=hppa
|
||||
basic_os=linux
|
||||
basic_os=${basic_os:-linux}
|
||||
;;
|
||||
pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
|
||||
cpu=i586
|
||||
@ -1085,9 +1158,6 @@ case $cpu-$vendor in
|
||||
pentium4-*)
|
||||
cpu=i786
|
||||
;;
|
||||
pc98-*)
|
||||
cpu=i386
|
||||
;;
|
||||
ppc-* | ppcbe-*)
|
||||
cpu=powerpc
|
||||
;;
|
||||
@ -1121,9 +1191,6 @@ case $cpu-$vendor in
|
||||
tx39el-*)
|
||||
cpu=mipstx39el
|
||||
;;
|
||||
x64-*)
|
||||
cpu=x86_64
|
||||
;;
|
||||
xscale-* | xscalee[bl]-*)
|
||||
cpu=`echo "$cpu" | sed 's/^xscale/arm/'`
|
||||
;;
|
||||
@ -1179,90 +1246,227 @@ case $cpu-$vendor in
|
||||
# Recognize the canonical CPU types that are allowed with any
|
||||
# company name.
|
||||
case $cpu in
|
||||
1750a | 580 \
|
||||
1750a \
|
||||
| 580 \
|
||||
| [cjt]90 \
|
||||
| a29k \
|
||||
| aarch64 | aarch64_be | aarch64c | arm64ec \
|
||||
| aarch64 \
|
||||
| aarch64_be \
|
||||
| aarch64c \
|
||||
| abacus \
|
||||
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \
|
||||
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \
|
||||
| alphapca5[67] | alpha64pca5[67] \
|
||||
| alpha \
|
||||
| alpha64 \
|
||||
| alpha64ev56 \
|
||||
| alpha64ev6[78] \
|
||||
| alpha64ev[4-8] \
|
||||
| alpha64pca5[67] \
|
||||
| alphaev56 \
|
||||
| alphaev6[78] \
|
||||
| alphaev[4-8] \
|
||||
| alphapca5[67] \
|
||||
| am33_2.0 \
|
||||
| amdgcn \
|
||||
| arc | arceb | arc32 | arc64 \
|
||||
| arm | arm[lb]e | arme[lb] | armv* \
|
||||
| avr | avr32 \
|
||||
| arc \
|
||||
| arc32 \
|
||||
| arc64 \
|
||||
| arceb \
|
||||
| arm \
|
||||
| arm64e \
|
||||
| arm64ec \
|
||||
| arm[lb]e \
|
||||
| arme[lb] \
|
||||
| armv* \
|
||||
| asmjs \
|
||||
| avr \
|
||||
| avr32 \
|
||||
| ba \
|
||||
| be32 | be64 \
|
||||
| bfin | bpf | bs2000 \
|
||||
| c[123]* | c30 | [cjt]90 | c4x \
|
||||
| c8051 | clipper | craynv | csky | cydra \
|
||||
| d10v | d30v | dlx | dsp16xx \
|
||||
| e2k | elxsi | epiphany \
|
||||
| f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \
|
||||
| javascript \
|
||||
| h8300 | h8500 \
|
||||
| hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
|
||||
| be32 \
|
||||
| be64 \
|
||||
| bfin \
|
||||
| bpf \
|
||||
| bs2000 \
|
||||
| c30 \
|
||||
| c4x \
|
||||
| c8051 \
|
||||
| c[123]* \
|
||||
| clipper \
|
||||
| craynv \
|
||||
| csky \
|
||||
| cydra \
|
||||
| d10v \
|
||||
| d30v \
|
||||
| dlx \
|
||||
| dsp16xx \
|
||||
| e2k \
|
||||
| elxsi \
|
||||
| epiphany \
|
||||
| f30[01] \
|
||||
| f700 \
|
||||
| fido \
|
||||
| fr30 \
|
||||
| frv \
|
||||
| ft32 \
|
||||
| fx80 \
|
||||
| h8300 \
|
||||
| h8500 \
|
||||
| hexagon \
|
||||
| i370 | i*86 | i860 | i960 | ia16 | ia64 \
|
||||
| ip2k | iq2000 \
|
||||
| hppa \
|
||||
| hppa1.[01] \
|
||||
| hppa2.0 \
|
||||
| hppa2.0[nw] \
|
||||
| hppa64 \
|
||||
| i*86 \
|
||||
| i370 \
|
||||
| i860 \
|
||||
| i960 \
|
||||
| ia16 \
|
||||
| ia64 \
|
||||
| ip2k \
|
||||
| iq2000 \
|
||||
| javascript \
|
||||
| k1om \
|
||||
| kvx \
|
||||
| le32 | le64 \
|
||||
| le32 \
|
||||
| le64 \
|
||||
| lm32 \
|
||||
| loongarch32 | loongarch64 \
|
||||
| m32c | m32r | m32rle \
|
||||
| m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \
|
||||
| m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \
|
||||
| m88110 | m88k | maxq | mb | mcore | mep | metag \
|
||||
| microblaze | microblazeel \
|
||||
| loongarch32 \
|
||||
| loongarch64 \
|
||||
| m32c \
|
||||
| m32r \
|
||||
| m32rle \
|
||||
| m5200 \
|
||||
| m68000 \
|
||||
| m680[012346]0 \
|
||||
| m6811 \
|
||||
| m6812 \
|
||||
| m68360 \
|
||||
| m683?2 \
|
||||
| m68hc11 \
|
||||
| m68hc12 \
|
||||
| m68hcs12x \
|
||||
| m68k \
|
||||
| m88110 \
|
||||
| m88k \
|
||||
| maxq \
|
||||
| mb \
|
||||
| mcore \
|
||||
| mep \
|
||||
| metag \
|
||||
| microblaze \
|
||||
| microblazeel \
|
||||
| mips* \
|
||||
| mmix \
|
||||
| mn10200 | mn10300 \
|
||||
| mn10200 \
|
||||
| mn10300 \
|
||||
| moxie \
|
||||
| mt \
|
||||
| msp430 \
|
||||
| mt \
|
||||
| nanomips* \
|
||||
| nds32 | nds32le | nds32be \
|
||||
| nds32 \
|
||||
| nds32be \
|
||||
| nds32le \
|
||||
| nfp \
|
||||
| nios | nios2 | nios2eb | nios2el \
|
||||
| none | np1 | ns16k | ns32k | nvptx \
|
||||
| nios \
|
||||
| nios2 \
|
||||
| nios2eb \
|
||||
| nios2el \
|
||||
| none \
|
||||
| np1 \
|
||||
| ns16k \
|
||||
| ns32k \
|
||||
| nvptx \
|
||||
| open8 \
|
||||
| or1k* \
|
||||
| or32 \
|
||||
| orion \
|
||||
| pdp10 \
|
||||
| pdp11 \
|
||||
| picochip \
|
||||
| pdp10 | pdp11 | pj | pjl | pn | power \
|
||||
| powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \
|
||||
| pj \
|
||||
| pjl \
|
||||
| pn \
|
||||
| power \
|
||||
| powerpc \
|
||||
| powerpc64 \
|
||||
| powerpc64le \
|
||||
| powerpcle \
|
||||
| powerpcspe \
|
||||
| pru \
|
||||
| pyramid \
|
||||
| riscv | riscv32 | riscv32be | riscv64 | riscv64be \
|
||||
| rl78 | romp | rs6000 | rx \
|
||||
| s390 | s390x \
|
||||
| riscv \
|
||||
| riscv32 \
|
||||
| riscv32be \
|
||||
| riscv64 \
|
||||
| riscv64be \
|
||||
| rl78 \
|
||||
| romp \
|
||||
| rs6000 \
|
||||
| rx \
|
||||
| s390 \
|
||||
| s390x \
|
||||
| score \
|
||||
| sh | shl \
|
||||
| sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \
|
||||
| sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \
|
||||
| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \
|
||||
| sh \
|
||||
| sh64 \
|
||||
| sh64le \
|
||||
| sh[12345][lb]e \
|
||||
| sh[1234] \
|
||||
| sh[1234]e[lb] \
|
||||
| sh[23]e \
|
||||
| sh[23]ele \
|
||||
| sh[24]a \
|
||||
| sh[24]ae[lb] \
|
||||
| sh[lb]e \
|
||||
| she[lb] \
|
||||
| shl \
|
||||
| sparc \
|
||||
| sparc64 \
|
||||
| sparc64b \
|
||||
| sparc64v \
|
||||
| sparc86x \
|
||||
| sparclet \
|
||||
| sparclite \
|
||||
| sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \
|
||||
| sparcv8 \
|
||||
| sparcv9 \
|
||||
| sparcv9b \
|
||||
| sparcv9v \
|
||||
| spu \
|
||||
| sv1 \
|
||||
| sx* \
|
||||
| tahoe \
|
||||
| thumbv7* \
|
||||
| tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \
|
||||
| tic30 \
|
||||
| tic4x \
|
||||
| tic54x \
|
||||
| tic55x \
|
||||
| tic6x \
|
||||
| tic80 \
|
||||
| tron \
|
||||
| ubicom32 \
|
||||
| v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \
|
||||
| v70 \
|
||||
| v810 \
|
||||
| v850 \
|
||||
| v850e \
|
||||
| v850e1 \
|
||||
| v850e2 \
|
||||
| v850e2v3 \
|
||||
| v850es \
|
||||
| vax \
|
||||
| vc4 \
|
||||
| visium \
|
||||
| w65 \
|
||||
| wasm32 | wasm64 \
|
||||
| wasm32 \
|
||||
| wasm64 \
|
||||
| we32k \
|
||||
| x86 | x86_64 | xc16x | xgate | xps100 \
|
||||
| xstormy16 | xtensa* \
|
||||
| x86 \
|
||||
| x86_64 \
|
||||
| xc16x \
|
||||
| xgate \
|
||||
| xps100 \
|
||||
| xstormy16 \
|
||||
| xtensa* \
|
||||
| ymp \
|
||||
| z8k | z80)
|
||||
| z80 \
|
||||
| z8k)
|
||||
;;
|
||||
|
||||
*)
|
||||
@ -1307,7 +1511,6 @@ case $basic_os in
|
||||
os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`
|
||||
;;
|
||||
*-*)
|
||||
# shellcheck disable=SC2162
|
||||
saved_IFS=$IFS
|
||||
IFS="-" read kernel os <<EOF
|
||||
$basic_os
|
||||
@ -1354,6 +1557,23 @@ case $os in
|
||||
unixware*)
|
||||
os=sysv4.2uw
|
||||
;;
|
||||
# The marketing names for NeXT's operating systems were
|
||||
# NeXTSTEP, NeXTSTEP 2, OpenSTEP 3, OpenSTEP 4. 'openstep' is
|
||||
# mapped to 'openstep3', but 'openstep1' and 'openstep2' are
|
||||
# mapped to 'nextstep' and 'nextstep2', consistent with the
|
||||
# treatment of SunOS/Solaris.
|
||||
ns | ns1 | nextstep | nextstep1 | openstep1)
|
||||
os=nextstep
|
||||
;;
|
||||
ns2 | nextstep2 | openstep2)
|
||||
os=nextstep2
|
||||
;;
|
||||
ns3 | nextstep3 | openstep | openstep3)
|
||||
os=openstep3
|
||||
;;
|
||||
ns4 | nextstep4 | openstep4)
|
||||
os=openstep4
|
||||
;;
|
||||
# es1800 is here to avoid being matched by es* (a different OS)
|
||||
es1800*)
|
||||
os=ose
|
||||
@ -1424,6 +1644,7 @@ case $os in
|
||||
;;
|
||||
utek*)
|
||||
os=bsd
|
||||
vendor=`echo "$vendor" | sed -e 's|^unknown$|tektronix|'`
|
||||
;;
|
||||
dynix*)
|
||||
os=bsd
|
||||
@ -1440,21 +1661,25 @@ case $os in
|
||||
386bsd)
|
||||
os=bsd
|
||||
;;
|
||||
ctix* | uts*)
|
||||
ctix*)
|
||||
os=sysv
|
||||
vendor=`echo "$vendor" | sed -e 's|^unknown$|convergent|'`
|
||||
;;
|
||||
uts*)
|
||||
os=sysv
|
||||
;;
|
||||
nova*)
|
||||
os=rtmk-nova
|
||||
;;
|
||||
ns2)
|
||||
os=nextstep2
|
||||
kernel=rtmk
|
||||
os=nova
|
||||
;;
|
||||
# Preserve the version number of sinix5.
|
||||
sinix5.*)
|
||||
os=`echo "$os" | sed -e 's|sinix|sysv|'`
|
||||
vendor=`echo "$vendor" | sed -e 's|^unknown$|sni|'`
|
||||
;;
|
||||
sinix*)
|
||||
os=sysv4
|
||||
vendor=`echo "$vendor" | sed -e 's|^unknown$|sni|'`
|
||||
;;
|
||||
tpf*)
|
||||
os=tpf
|
||||
@ -1595,6 +1820,14 @@ case $cpu-$vendor in
|
||||
os=
|
||||
obj=elf
|
||||
;;
|
||||
# The -sgi and -siemens entries must be before the mips- entry
|
||||
# or we get the wrong os.
|
||||
*-sgi)
|
||||
os=irix
|
||||
;;
|
||||
*-siemens)
|
||||
os=sysv4
|
||||
;;
|
||||
mips*-cisco)
|
||||
os=
|
||||
obj=elf
|
||||
@ -1607,7 +1840,8 @@ case $cpu-$vendor in
|
||||
os=
|
||||
obj=coff
|
||||
;;
|
||||
*-tti) # must be before sparc entry or we get the wrong os.
|
||||
# This must be before the sparc-* entry or we get the wrong os.
|
||||
*-tti)
|
||||
os=sysv3
|
||||
;;
|
||||
sparc-* | *-sun)
|
||||
@ -1639,7 +1873,7 @@ case $cpu-$vendor in
|
||||
os=hpux
|
||||
;;
|
||||
*-hitachi)
|
||||
os=hiux
|
||||
os=hiuxwe2
|
||||
;;
|
||||
i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
|
||||
os=sysv
|
||||
@ -1683,12 +1917,6 @@ case $cpu-$vendor in
|
||||
*-encore)
|
||||
os=bsd
|
||||
;;
|
||||
*-sgi)
|
||||
os=irix
|
||||
;;
|
||||
*-siemens)
|
||||
os=sysv4
|
||||
;;
|
||||
*-masscomp)
|
||||
os=rtu
|
||||
;;
|
||||
@ -1735,40 +1963,193 @@ case $os in
|
||||
ghcjs)
|
||||
;;
|
||||
# Now accept the basic system types.
|
||||
# The portable systems comes first.
|
||||
# Each alternative MUST end in a * to match a version number.
|
||||
gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
|
||||
| *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \
|
||||
| hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
|
||||
| sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \
|
||||
| hiux* | abug | nacl* | netware* | windows* \
|
||||
| os9* | macos* | osx* | ios* | tvos* | watchos* \
|
||||
| mpw* | magic* | mmixware* | mon960* | lnews* \
|
||||
| amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
|
||||
| aos* | aros* | cloudabi* | sortix* | twizzler* \
|
||||
| nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
|
||||
| clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \
|
||||
| mirbsd* | netbsd* | dicos* | openedition* | ose* \
|
||||
| bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \
|
||||
| ekkobsd* | freebsd* | riscix* | lynxos* | os400* \
|
||||
| bosx* | nextstep* | cxux* | oabi* \
|
||||
| ptx* | ecoff* | winnt* | domain* | vsta* \
|
||||
| udi* | lites* | ieee* | go32* | aux* | hcos* \
|
||||
| chorusrdb* | cegcc* | glidix* | serenity* \
|
||||
| cygwin* | msys* | moss* | proelf* | rtems* \
|
||||
| midipix* | mingw32* | mingw64* | mint* \
|
||||
| uxpv* | beos* | mpeix* | udk* | moxiebox* \
|
||||
| interix* | uwin* | mks* | rhapsody* | darwin* \
|
||||
| openstep* | oskit* | conix* | pw32* | nonstopux* \
|
||||
| storm-chaos* | tops10* | tenex* | tops20* | its* \
|
||||
| os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \
|
||||
| scout* | superux* | sysv* | rtmk* | tpf* | windiss* \
|
||||
| powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
|
||||
| skyos* | haiku* | rdos* | toppers* | drops* | es* \
|
||||
| onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
|
||||
| midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \
|
||||
| nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \
|
||||
| fiwix* | mlibc* | cos* | mbr* | ironclad* )
|
||||
abug \
|
||||
| aix* \
|
||||
| amdhsa* \
|
||||
| amigados* \
|
||||
| amigaos* \
|
||||
| android* \
|
||||
| aof* \
|
||||
| aos* \
|
||||
| aros* \
|
||||
| atheos* \
|
||||
| auroraux* \
|
||||
| aux* \
|
||||
| beos* \
|
||||
| bitrig* \
|
||||
| bme* \
|
||||
| bosx* \
|
||||
| bsd* \
|
||||
| cegcc* \
|
||||
| chorusos* \
|
||||
| chorusrdb* \
|
||||
| clix* \
|
||||
| cloudabi* \
|
||||
| cnk* \
|
||||
| conix* \
|
||||
| cos* \
|
||||
| cxux* \
|
||||
| cygwin* \
|
||||
| darwin* \
|
||||
| dgux* \
|
||||
| dicos* \
|
||||
| dnix* \
|
||||
| domain* \
|
||||
| dragonfly* \
|
||||
| drops* \
|
||||
| ebmon* \
|
||||
| ecoff* \
|
||||
| ekkobsd* \
|
||||
| emscripten* \
|
||||
| emx* \
|
||||
| es* \
|
||||
| fiwix* \
|
||||
| freebsd* \
|
||||
| fuchsia* \
|
||||
| genix* \
|
||||
| genode* \
|
||||
| glidix* \
|
||||
| gnu* \
|
||||
| go32* \
|
||||
| haiku* \
|
||||
| hcos* \
|
||||
| hiux* \
|
||||
| hms* \
|
||||
| hpux* \
|
||||
| ieee* \
|
||||
| interix* \
|
||||
| ios* \
|
||||
| iris* \
|
||||
| irix* \
|
||||
| ironclad* \
|
||||
| isc* \
|
||||
| its* \
|
||||
| l4re* \
|
||||
| libertybsd* \
|
||||
| lites* \
|
||||
| lnews* \
|
||||
| luna* \
|
||||
| lynxos* \
|
||||
| mach* \
|
||||
| macos* \
|
||||
| magic* \
|
||||
| mbr* \
|
||||
| midipix* \
|
||||
| midnightbsd* \
|
||||
| mingw32* \
|
||||
| mingw64* \
|
||||
| minix* \
|
||||
| mint* \
|
||||
| mirbsd* \
|
||||
| mks* \
|
||||
| mlibc* \
|
||||
| mmixware* \
|
||||
| mon960* \
|
||||
| morphos* \
|
||||
| moss* \
|
||||
| moxiebox* \
|
||||
| mpeix* \
|
||||
| mpw* \
|
||||
| msdos* \
|
||||
| msys* \
|
||||
| mvs* \
|
||||
| nacl* \
|
||||
| netbsd* \
|
||||
| netware* \
|
||||
| newsos* \
|
||||
| nextstep* \
|
||||
| nindy* \
|
||||
| nonstopux* \
|
||||
| nova* \
|
||||
| nsk* \
|
||||
| nucleus* \
|
||||
| nx6 \
|
||||
| nx7 \
|
||||
| oabi* \
|
||||
| ohos* \
|
||||
| onefs* \
|
||||
| openbsd* \
|
||||
| openedition* \
|
||||
| openstep* \
|
||||
| os108* \
|
||||
| os2* \
|
||||
| os400* \
|
||||
| os68k* \
|
||||
| os9* \
|
||||
| ose* \
|
||||
| osf* \
|
||||
| oskit* \
|
||||
| osx* \
|
||||
| palmos* \
|
||||
| phoenix* \
|
||||
| plan9* \
|
||||
| powermax* \
|
||||
| powerunix* \
|
||||
| proelf* \
|
||||
| psos* \
|
||||
| psp* \
|
||||
| ptx* \
|
||||
| pw32* \
|
||||
| qnx* \
|
||||
| rdos* \
|
||||
| redox* \
|
||||
| rhapsody* \
|
||||
| riscix* \
|
||||
| riscos* \
|
||||
| rtems* \
|
||||
| rtmk* \
|
||||
| rtu* \
|
||||
| scout* \
|
||||
| secbsd* \
|
||||
| sei* \
|
||||
| serenity* \
|
||||
| sim* \
|
||||
| skyos* \
|
||||
| solaris* \
|
||||
| solidbsd* \
|
||||
| sortix* \
|
||||
| storm-chaos* \
|
||||
| sunos \
|
||||
| sunos[34]* \
|
||||
| superux* \
|
||||
| syllable* \
|
||||
| sym* \
|
||||
| sysv* \
|
||||
| tenex* \
|
||||
| tirtos* \
|
||||
| toppers* \
|
||||
| tops10* \
|
||||
| tops20* \
|
||||
| tpf* \
|
||||
| tvos* \
|
||||
| twizzler* \
|
||||
| uclinux* \
|
||||
| udi* \
|
||||
| udk* \
|
||||
| ultrix* \
|
||||
| unicos* \
|
||||
| uniplus* \
|
||||
| unleashed* \
|
||||
| unos* \
|
||||
| uwin* \
|
||||
| uxpv* \
|
||||
| v88r* \
|
||||
|*vms* \
|
||||
| vos* \
|
||||
| vsta* \
|
||||
| vxsim* \
|
||||
| vxworks* \
|
||||
| wasi* \
|
||||
| watchos* \
|
||||
| wince* \
|
||||
| windiss* \
|
||||
| windows* \
|
||||
| winnt* \
|
||||
| xenix* \
|
||||
| xray* \
|
||||
| zephyr* \
|
||||
| zvmoe* )
|
||||
;;
|
||||
# This one is extra strict with allowed versions
|
||||
sco3.2v2 | sco3.2v[4-9]* | sco5v6*)
|
||||
@ -1829,9 +2210,9 @@ esac
|
||||
case $kernel-$os-$obj in
|
||||
linux-gnu*- | linux-android*- | linux-dietlibc*- | linux-llvm*- \
|
||||
| linux-mlibc*- | linux-musl*- | linux-newlib*- \
|
||||
| linux-relibc*- | linux-uclibc*- )
|
||||
| linux-relibc*- | linux-uclibc*- | linux-ohos*- )
|
||||
;;
|
||||
uclinux-uclibc*- )
|
||||
uclinux-uclibc*- | uclinux-gnu*- )
|
||||
;;
|
||||
managarm-mlibc*- | managarm-kernel*- )
|
||||
;;
|
||||
@ -1856,7 +2237,7 @@ case $kernel-$os-$obj in
|
||||
echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2
|
||||
exit 1
|
||||
;;
|
||||
kfreebsd*-gnu*- | kopensolaris*-gnu*-)
|
||||
kfreebsd*-gnu*- | knetbsd*-gnu*- | netbsd*-gnu*- | kopensolaris*-gnu*-)
|
||||
;;
|
||||
vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-)
|
||||
;;
|
||||
@ -1864,6 +2245,8 @@ case $kernel-$os-$obj in
|
||||
;;
|
||||
os2-emx-)
|
||||
;;
|
||||
rtmk-nova-)
|
||||
;;
|
||||
*-eabi*- | *-gnueabi*-)
|
||||
;;
|
||||
none--*)
|
||||
@ -1890,7 +2273,7 @@ case $vendor in
|
||||
*-riscix*)
|
||||
vendor=acorn
|
||||
;;
|
||||
*-sunos*)
|
||||
*-sunos* | *-solaris*)
|
||||
vendor=sun
|
||||
;;
|
||||
*-cnk* | *-aix*)
|
||||
|
277
configure
vendored
277
configure
vendored
@ -1,6 +1,6 @@
|
||||
#! /bin/sh
|
||||
# Guess values for system-dependent variables and create Makefiles.
|
||||
# Generated by GNU Autoconf 2.72 for libpng 1.6.46.
|
||||
# Generated by GNU Autoconf 2.72 for libpng 1.6.51.git.
|
||||
#
|
||||
# Report bugs to <png-mng-implement@lists.sourceforge.net>.
|
||||
#
|
||||
@ -614,8 +614,8 @@ MAKEFLAGS=
|
||||
# Identity of this package.
|
||||
PACKAGE_NAME='libpng'
|
||||
PACKAGE_TARNAME='libpng'
|
||||
PACKAGE_VERSION='1.6.46'
|
||||
PACKAGE_STRING='libpng 1.6.46'
|
||||
PACKAGE_VERSION='1.6.51.git'
|
||||
PACKAGE_STRING='libpng 1.6.51.git'
|
||||
PACKAGE_BUGREPORT='png-mng-implement@lists.sourceforge.net'
|
||||
PACKAGE_URL=''
|
||||
|
||||
@ -656,6 +656,8 @@ ac_subst_vars='am__EXEEXT_FALSE
|
||||
am__EXEEXT_TRUE
|
||||
LTLIBOBJS
|
||||
LIBOBJS
|
||||
PNG_RISCV_RVV_FALSE
|
||||
PNG_RISCV_RVV_TRUE
|
||||
PNG_LOONGARCH_LSX_FALSE
|
||||
PNG_LOONGARCH_LSX_TRUE
|
||||
PNG_POWERPC_VSX_FALSE
|
||||
@ -858,6 +860,7 @@ enable_mips_mmi
|
||||
enable_intel_sse
|
||||
enable_powerpc_vsx
|
||||
enable_loongarch_lsx
|
||||
enable_riscv_rvv
|
||||
'
|
||||
ac_precious_vars='build_alias
|
||||
host_alias
|
||||
@ -1421,7 +1424,7 @@ if test "$ac_init_help" = "long"; then
|
||||
# Omit some internal or obsolete options to make the list less imposing.
|
||||
# This message is too long to be a string in the A/UX 3.1 sh.
|
||||
cat <<_ACEOF
|
||||
'configure' configures libpng 1.6.46 to adapt to many kinds of systems.
|
||||
'configure' configures libpng 1.6.51.git to adapt to many kinds of systems.
|
||||
|
||||
Usage: $0 [OPTION]... [VAR=VALUE]...
|
||||
|
||||
@ -1492,7 +1495,7 @@ fi
|
||||
|
||||
if test -n "$ac_init_help"; then
|
||||
case $ac_init_help in
|
||||
short | recursive ) echo "Configuration of libpng 1.6.46:";;
|
||||
short | recursive ) echo "Configuration of libpng 1.6.51.git:";;
|
||||
esac
|
||||
cat <<\_ACEOF
|
||||
|
||||
@ -1590,6 +1593,12 @@ Optional Features:
|
||||
no/off: disable the optimizations; yes/on: turn on
|
||||
unconditionally. If not specified: determined by the
|
||||
compiler.
|
||||
--enable-riscv-rvv Enable RISC-V Vector optimizations: =no/off, check,
|
||||
api, yes/on: no/off: disable the optimizations;
|
||||
check: use internal checking code api: disable by
|
||||
default, enable by a call to png_set_option yes/on:
|
||||
turn on. If not specified: determined by the
|
||||
compiler.
|
||||
|
||||
Optional Packages:
|
||||
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
|
||||
@ -1689,7 +1698,7 @@ fi
|
||||
test -n "$ac_init_help" && exit $ac_status
|
||||
if $ac_init_version; then
|
||||
cat <<\_ACEOF
|
||||
libpng configure 1.6.46
|
||||
libpng configure 1.6.51.git
|
||||
generated by GNU Autoconf 2.72
|
||||
|
||||
Copyright (C) 2023 Free Software Foundation, Inc.
|
||||
@ -1952,7 +1961,7 @@ cat >config.log <<_ACEOF
|
||||
This file contains any messages produced by compilers while
|
||||
running configure, to aid debugging if configure makes a mistake.
|
||||
|
||||
It was created by libpng $as_me 1.6.46, which was
|
||||
It was created by libpng $as_me 1.6.51.git, which was
|
||||
generated by GNU Autoconf 2.72. Invocation command line was
|
||||
|
||||
$ $0$ac_configure_args_raw
|
||||
@ -2733,7 +2742,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
|
||||
# dist-xz requires automake 1.11 or later
|
||||
# 1.12.2 fixes a security issue in 1.11.2 and 1.12.1
|
||||
# 1.13 is required for parallel tests
|
||||
am__api_version='1.17'
|
||||
am__api_version='1.18'
|
||||
|
||||
|
||||
|
||||
@ -3003,10 +3012,14 @@ am_lf='
|
||||
'
|
||||
case `pwd` in
|
||||
*[\\\"\#\$\&\'\`$am_lf]*)
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
printf "%s\n" "no" >&6; }
|
||||
as_fn_error $? "unsafe absolute working directory name" "$LINENO" 5;;
|
||||
esac
|
||||
case $srcdir in
|
||||
*[\\\"\#\$\&\'\`$am_lf\ \ ]*)
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
printf "%s\n" "no" >&6; }
|
||||
as_fn_error $? "unsafe srcdir value: '$srcdir'" "$LINENO" 5;;
|
||||
esac
|
||||
|
||||
@ -3433,7 +3446,7 @@ fi
|
||||
|
||||
# Define the identity of the package.
|
||||
PACKAGE='libpng'
|
||||
VERSION='1.6.46'
|
||||
VERSION='1.6.51.git'
|
||||
|
||||
|
||||
printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h
|
||||
@ -3471,9 +3484,133 @@ AMTAR='$${TAR-tar}'
|
||||
|
||||
|
||||
# We'll loop over all known methods to create a tar archive until one works.
|
||||
_am_tools='gnutar pax cpio none'
|
||||
_am_tools='gnutar plaintar pax cpio none'
|
||||
|
||||
am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'
|
||||
# The POSIX 1988 'ustar' format is defined with fixed-size fields.
|
||||
# There is notably a 21 bits limit for the UID and the GID. In fact,
|
||||
# the 'pax' utility can hang on bigger UID/GID (see automake bug#8343
|
||||
# and bug#13588).
|
||||
am_max_uid=2097151 # 2^21 - 1
|
||||
am_max_gid=$am_max_uid
|
||||
# The $UID and $GID variables are not portable, so we need to resort
|
||||
# to the POSIX-mandated id(1) utility. Errors in the 'id' calls
|
||||
# below are definitely unexpected, so allow the users to see them
|
||||
# (that is, avoid stderr redirection).
|
||||
am_uid=`id -u || echo unknown`
|
||||
am_gid=`id -g || echo unknown`
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether UID '$am_uid' is supported by ustar format" >&5
|
||||
printf %s "checking whether UID '$am_uid' is supported by ustar format... " >&6; }
|
||||
if test x$am_uid = xunknown; then
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: ancient id detected; assuming current UID is ok, but dist-ustar might not work" >&5
|
||||
printf "%s\n" "$as_me: WARNING: ancient id detected; assuming current UID is ok, but dist-ustar might not work" >&2;}
|
||||
elif test $am_uid -le $am_max_uid; then
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
printf "%s\n" "yes" >&6; }
|
||||
else
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
printf "%s\n" "no" >&6; }
|
||||
_am_tools=none
|
||||
fi
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether GID '$am_gid' is supported by ustar format" >&5
|
||||
printf %s "checking whether GID '$am_gid' is supported by ustar format... " >&6; }
|
||||
if test x$gm_gid = xunknown; then
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: ancient id detected; assuming current GID is ok, but dist-ustar might not work" >&5
|
||||
printf "%s\n" "$as_me: WARNING: ancient id detected; assuming current GID is ok, but dist-ustar might not work" >&2;}
|
||||
elif test $am_gid -le $am_max_gid; then
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
|
||||
printf "%s\n" "yes" >&6; }
|
||||
else
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
|
||||
printf "%s\n" "no" >&6; }
|
||||
_am_tools=none
|
||||
fi
|
||||
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to create a ustar tar archive" >&5
|
||||
printf %s "checking how to create a ustar tar archive... " >&6; }
|
||||
|
||||
# Go ahead even if we have the value already cached. We do so because we
|
||||
# need to set the values for the 'am__tar' and 'am__untar' variables.
|
||||
_am_tools=${am_cv_prog_tar_ustar-$_am_tools}
|
||||
|
||||
for _am_tool in $_am_tools; do
|
||||
case $_am_tool in
|
||||
gnutar)
|
||||
for _am_tar in tar gnutar gtar; do
|
||||
{ echo "$as_me:$LINENO: $_am_tar --version" >&5
|
||||
($_am_tar --version) >&5 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } && break
|
||||
done
|
||||
am__tar="$_am_tar --format=ustar -chf - "'"$$tardir"'
|
||||
am__tar_="$_am_tar --format=ustar -chf - "'"$tardir"'
|
||||
am__untar="$_am_tar -xf -"
|
||||
;;
|
||||
plaintar)
|
||||
# Must skip GNU tar: if it does not support --format= it doesn't create
|
||||
# ustar tarball either.
|
||||
(tar --version) >/dev/null 2>&1 && continue
|
||||
am__tar='tar chf - "$$tardir"'
|
||||
am__tar_='tar chf - "$tardir"'
|
||||
am__untar='tar xf -'
|
||||
;;
|
||||
pax)
|
||||
am__tar='pax -L -x ustar -w "$$tardir"'
|
||||
am__tar_='pax -L -x ustar -w "$tardir"'
|
||||
am__untar='pax -r'
|
||||
;;
|
||||
cpio)
|
||||
am__tar='find "$$tardir" -print | cpio -o -H ustar -L'
|
||||
am__tar_='find "$tardir" -print | cpio -o -H ustar -L'
|
||||
am__untar='cpio -i -H ustar -d'
|
||||
;;
|
||||
none)
|
||||
am__tar=false
|
||||
am__tar_=false
|
||||
am__untar=false
|
||||
;;
|
||||
esac
|
||||
|
||||
# If the value was cached, stop now. We just wanted to have am__tar
|
||||
# and am__untar set.
|
||||
test -n "${am_cv_prog_tar_ustar}" && break
|
||||
|
||||
# tar/untar a dummy directory, and stop if the command works.
|
||||
rm -rf conftest.dir
|
||||
mkdir conftest.dir
|
||||
echo GrepMe > conftest.dir/file
|
||||
{ echo "$as_me:$LINENO: tardir=conftest.dir && eval $am__tar_ >conftest.tar" >&5
|
||||
(tardir=conftest.dir && eval $am__tar_ >conftest.tar) >&5 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }
|
||||
rm -rf conftest.dir
|
||||
if test -s conftest.tar; then
|
||||
{ echo "$as_me:$LINENO: $am__untar <conftest.tar" >&5
|
||||
($am__untar <conftest.tar) >&5 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }
|
||||
{ echo "$as_me:$LINENO: cat conftest.dir/file" >&5
|
||||
(cat conftest.dir/file) >&5 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }
|
||||
grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
|
||||
fi
|
||||
done
|
||||
rm -rf conftest.dir
|
||||
|
||||
if test ${am_cv_prog_tar_ustar+y}
|
||||
then :
|
||||
printf %s "(cached) " >&6
|
||||
else case e in #(
|
||||
e) am_cv_prog_tar_ustar=$_am_tool ;;
|
||||
esac
|
||||
fi
|
||||
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_prog_tar_ustar" >&5
|
||||
printf "%s\n" "$am_cv_prog_tar_ustar" >&6; }
|
||||
|
||||
|
||||
|
||||
@ -3528,10 +3665,10 @@ fi
|
||||
|
||||
|
||||
|
||||
PNGLIB_VERSION=1.6.46
|
||||
PNGLIB_VERSION=1.6.51.git
|
||||
PNGLIB_MAJOR=1
|
||||
PNGLIB_MINOR=6
|
||||
PNGLIB_RELEASE=46
|
||||
PNGLIB_RELEASE=51
|
||||
|
||||
|
||||
|
||||
@ -4611,7 +4748,10 @@ _ACEOF
|
||||
break
|
||||
fi
|
||||
done
|
||||
rm -f core conftest*
|
||||
# aligned with autoconf, so not including core; see bug#72225.
|
||||
rm -f -r a.out a.exe b.out conftest.$ac_ext conftest.$ac_objext \
|
||||
conftest.dSYM conftest1.$ac_ext conftest1.$ac_objext conftest1.dSYM \
|
||||
conftest2.$ac_ext conftest2.$ac_objext conftest2.dSYM
|
||||
unset am_i ;;
|
||||
esac
|
||||
fi
|
||||
@ -15156,6 +15296,10 @@ printf "%s\n" "#define PNG_INTEL_SSE_OPT 0" >>confdefs.h
|
||||
|
||||
printf "%s\n" "#define PNG_LOONGARCH_LSX_OPT 0" >>confdefs.h
|
||||
|
||||
enable_riscv_rvv=no
|
||||
|
||||
printf "%s\n" "#define PNG_RISCV_RVV_OPT 0" >>confdefs.h
|
||||
|
||||
;;
|
||||
*)
|
||||
# allow enabling hardware optimization on any system:
|
||||
@ -15193,6 +15337,12 @@ printf "%s\n" "#define PNG_POWERPC_VSX_OPT 2" >>confdefs.h
|
||||
|
||||
printf "%s\n" "#define PNG_LOONGARCH_LSX_OPT 1" >>confdefs.h
|
||||
|
||||
;;
|
||||
riscv64)
|
||||
enable_riscv_rvv=yes
|
||||
|
||||
printf "%s\n" "#define PNG_RISCV_RVV_OPT 2" >>confdefs.h
|
||||
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
@ -15550,6 +15700,97 @@ else
|
||||
fi
|
||||
|
||||
|
||||
# RISC-V
|
||||
# ======
|
||||
#
|
||||
# RISC-V Vector support.
|
||||
|
||||
# Check whether --enable-riscv-rvv was given.
|
||||
if test ${enable_riscv_rvv+y}
|
||||
then :
|
||||
enableval=$enable_riscv_rvv; case "$enableval" in
|
||||
no|off)
|
||||
# disable the default enabling on __riscv systems:
|
||||
|
||||
printf "%s\n" "#define PNG_RISCV_RVV_OPT 0" >>confdefs.h
|
||||
|
||||
# Prevent inclusion of the platform-specific files below:
|
||||
enable_riscv_rvv=no ;;
|
||||
yes|on)
|
||||
|
||||
printf "%s\n" "#define PNG_RISCV_RVV_OPT 2" >>confdefs.h
|
||||
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: --enable-riscv-rvv:
|
||||
if you want the optimizations pass e.g. '-march=rv64gv1p0' to the compiler." >&5
|
||||
printf "%s\n" "$as_me: WARNING: --enable-riscv-rvv:
|
||||
if you want the optimizations pass e.g. '-march=rv64gv1p0' to the compiler." >&2;};;
|
||||
*)
|
||||
as_fn_error $? "--enable-riscv-rvv=${enable_riscv_rvv}: invalid value" "$LINENO" 5
|
||||
esac
|
||||
fi
|
||||
|
||||
|
||||
if test "$enable_riscv_rvv" != "no" &&
|
||||
case "$host_cpu" in
|
||||
riscv64) : ;;
|
||||
*) test "$enable_riscv_rvv" != '' ;;
|
||||
esac
|
||||
then
|
||||
compiler_support_riscv_rvv=no
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to use RISC-V RVV intrinsics" >&5
|
||||
printf %s "checking whether to use RISC-V RVV intrinsics... " >&6; }
|
||||
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
#include <riscv_vector.h>
|
||||
#include <asm/hwcap.h>
|
||||
#ifndef COMPAT_HWCAP_ISA_V /* added in linux-6.5 */
|
||||
#error "COMPAT_HWCAP_ISA_V is not available"
|
||||
#endif
|
||||
int main() {
|
||||
const float src[] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
uint64_t ptr[2] = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A};
|
||||
vuint8m1_t a = __riscv_vreinterpret_v_u64m1_u8m1(__riscv_vle64_v_u64m1(ptr, 2));
|
||||
vfloat32m1_t val = __riscv_vle32_v_f32m1((const float*)(src), 4);
|
||||
return (int)__riscv_vfmv_f_s_f32m1_f32(val);
|
||||
}
|
||||
_ACEOF
|
||||
if ac_fn_c_try_compile "$LINENO"
|
||||
then :
|
||||
compiler_support_riscv_rvv=yes
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $compiler_support_riscv_rvv" >&5
|
||||
printf "%s\n" "$compiler_support_riscv_rvv" >&6; }
|
||||
if test "$compiler_support_riscv_rvv" = "yes"; then
|
||||
|
||||
printf "%s\n" "#define PNG_RISCV_RVV_OPT 1" >>confdefs.h
|
||||
|
||||
else
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Compiler does not support riscv rvv." >&5
|
||||
printf "%s\n" "$as_me: WARNING: Compiler does not support riscv rvv." >&2;}
|
||||
fi
|
||||
fi
|
||||
|
||||
# Add RISC-V-specific files to all builds where $host_cpu is riscv ('riscv64')
|
||||
# or where RISC-V optimizations were explicitly requested (this allows a fallback
|
||||
# if a future host CPU does not match 'riscv64')
|
||||
|
||||
if test "$enable_riscv_rvv" != "no" &&
|
||||
test "$compiler_support_riscv_rvv" = "yes" &&
|
||||
case "$host_cpu" in
|
||||
riscv64) : ;;
|
||||
*) test "$compiler_support_riscv_rvv" != '' ;;
|
||||
esac; then
|
||||
PNG_RISCV_RVV_TRUE=
|
||||
PNG_RISCV_RVV_FALSE='#'
|
||||
else
|
||||
PNG_RISCV_RVV_TRUE='#'
|
||||
PNG_RISCV_RVV_FALSE=
|
||||
fi
|
||||
|
||||
|
||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: Extra options for compiler: $PNG_COPTS" >&5
|
||||
printf "%s\n" "$as_me: Extra options for compiler: $PNG_COPTS" >&6;}
|
||||
|
||||
@ -15772,6 +16013,10 @@ if test -z "${PNG_LOONGARCH_LSX_TRUE}" && test -z "${PNG_LOONGARCH_LSX_FALSE}";
|
||||
as_fn_error $? "conditional \"PNG_LOONGARCH_LSX\" was never defined.
|
||||
Usually this means the macro was only invoked conditionally." "$LINENO" 5
|
||||
fi
|
||||
if test -z "${PNG_RISCV_RVV_TRUE}" && test -z "${PNG_RISCV_RVV_FALSE}"; then
|
||||
as_fn_error $? "conditional \"PNG_RISCV_RVV\" was never defined.
|
||||
Usually this means the macro was only invoked conditionally." "$LINENO" 5
|
||||
fi
|
||||
|
||||
: "${CONFIG_STATUS=./config.status}"
|
||||
ac_write_fail=0
|
||||
@ -16165,7 +16410,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
|
||||
# report actual input values of CONFIG_FILES etc. instead of their
|
||||
# values after options handling.
|
||||
ac_log="
|
||||
This file was extended by libpng $as_me 1.6.46, which was
|
||||
This file was extended by libpng $as_me 1.6.51.git, which was
|
||||
generated by GNU Autoconf 2.72. Invocation command line was
|
||||
|
||||
CONFIG_FILES = $CONFIG_FILES
|
||||
@ -16233,7 +16478,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
|
||||
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
|
||||
ac_cs_config='$ac_cs_config_escaped'
|
||||
ac_cs_version="\\
|
||||
libpng config.status 1.6.46
|
||||
libpng config.status 1.6.51.git
|
||||
configured by $0, generated by GNU Autoconf 2.72,
|
||||
with options \\"\$ac_cs_config\\"
|
||||
|
||||
|
84
configure.ac
84
configure.ac
@ -25,7 +25,7 @@ AC_PREREQ([2.68])
|
||||
|
||||
dnl Version number stuff here:
|
||||
|
||||
AC_INIT([libpng],[1.6.46],[png-mng-implement@lists.sourceforge.net])
|
||||
AC_INIT([libpng],[1.6.51.git],[png-mng-implement@lists.sourceforge.net])
|
||||
AC_CONFIG_MACRO_DIR([scripts/autoconf])
|
||||
|
||||
# libpng does not follow GNU file name conventions (hence 'foreign')
|
||||
@ -46,10 +46,10 @@ dnl automake, so the following is not necessary (and is not defined anyway):
|
||||
dnl AM_PREREQ([1.11.2])
|
||||
dnl stop configure from automagically running automake
|
||||
|
||||
PNGLIB_VERSION=1.6.46
|
||||
PNGLIB_VERSION=1.6.51.git
|
||||
PNGLIB_MAJOR=1
|
||||
PNGLIB_MINOR=6
|
||||
PNGLIB_RELEASE=46
|
||||
PNGLIB_RELEASE=51
|
||||
|
||||
dnl End of version number stuff
|
||||
|
||||
@ -343,6 +343,9 @@ AC_ARG_ENABLE([hardware-optimizations],
|
||||
enable_loongarch_lsx=no
|
||||
AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [0],
|
||||
[Disable LOONGARCH_LSX optimizations])
|
||||
enable_riscv_rvv=no
|
||||
AC_DEFINE([PNG_RISCV_RVV_OPT], [0],
|
||||
[Disable RISC-V Vector optimizations])
|
||||
;;
|
||||
*)
|
||||
# allow enabling hardware optimization on any system:
|
||||
@ -375,6 +378,11 @@ AC_ARG_ENABLE([hardware-optimizations],
|
||||
AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1],
|
||||
[Enable LOONGARCH_LSX optimizations])
|
||||
;;
|
||||
riscv64)
|
||||
enable_riscv_rvv=yes
|
||||
AC_DEFINE([PNG_RISCV_RVV_OPT], [2],
|
||||
[Enable RISC-V Vector optimizations])
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac])
|
||||
@ -661,6 +669,76 @@ AM_CONDITIONAL([PNG_LOONGARCH_LSX],
|
||||
*) test "$enable_loongarch_lsx" != '' ;;
|
||||
esac])
|
||||
|
||||
# RISC-V
|
||||
# ======
|
||||
#
|
||||
# RISC-V Vector support.
|
||||
|
||||
AC_ARG_ENABLE([riscv-rvv],
|
||||
AS_HELP_STRING([[[--enable-riscv-rvv]]],
|
||||
[Enable RISC-V Vector optimizations: =no/off, check, api, yes/on:]
|
||||
[no/off: disable the optimizations; check: use internal checking code]
|
||||
[api: disable by default, enable by a call to png_set_option]
|
||||
[yes/on: turn on. If not specified: determined by the compiler.]),
|
||||
[case "$enableval" in
|
||||
no|off)
|
||||
# disable the default enabling on __riscv systems:
|
||||
AC_DEFINE([PNG_RISCV_RVV_OPT], [0],
|
||||
[Disable RISC-V Vector optimizations])
|
||||
# Prevent inclusion of the platform-specific files below:
|
||||
enable_riscv_rvv=no ;;
|
||||
yes|on)
|
||||
AC_DEFINE([PNG_RISCV_RVV_OPT], [2],
|
||||
[Enable RISC-V Vector optimizations])
|
||||
AC_MSG_WARN([--enable-riscv-rvv:]
|
||||
[if you want the optimizations pass e.g. '-march=rv64gv1p0' to the compiler.]);;
|
||||
*)
|
||||
AC_MSG_ERROR([--enable-riscv-rvv=${enable_riscv_rvv}: invalid value])
|
||||
esac])
|
||||
|
||||
if test "$enable_riscv_rvv" != "no" &&
|
||||
case "$host_cpu" in
|
||||
riscv64) : ;;
|
||||
*) test "$enable_riscv_rvv" != '' ;;
|
||||
esac
|
||||
then
|
||||
compiler_support_riscv_rvv=no
|
||||
AC_MSG_CHECKING(whether to use RISC-V RVV intrinsics)
|
||||
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
|
||||
#include <riscv_vector.h>
|
||||
#include <asm/hwcap.h>
|
||||
#ifndef COMPAT_HWCAP_ISA_V /* added in linux-6.5 */
|
||||
#error "COMPAT_HWCAP_ISA_V is not available"
|
||||
#endif
|
||||
int main() {
|
||||
const float src[] = { 0.0f, 0.0f, 0.0f, 0.0f };
|
||||
uint64_t ptr[2] = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A};
|
||||
vuint8m1_t a = __riscv_vreinterpret_v_u64m1_u8m1(__riscv_vle64_v_u64m1(ptr, 2));
|
||||
vfloat32m1_t val = __riscv_vle32_v_f32m1((const float*)(src), 4);
|
||||
return (int)__riscv_vfmv_f_s_f32m1_f32(val);
|
||||
}]])],compiler_support_riscv_rvv=yes)
|
||||
AC_MSG_RESULT($compiler_support_riscv_rvv)
|
||||
if test "$compiler_support_riscv_rvv" = "yes"; then
|
||||
AC_DEFINE([PNG_RISCV_RVV_OPT], [1],
|
||||
[Enable RISCV RVV optimizations])
|
||||
else
|
||||
AC_MSG_WARN([Compiler does not support riscv rvv.])
|
||||
fi
|
||||
fi
|
||||
|
||||
# Add RISC-V-specific files to all builds where $host_cpu is riscv ('riscv64')
|
||||
# or where RISC-V optimizations were explicitly requested (this allows a fallback
|
||||
# if a future host CPU does not match 'riscv64')
|
||||
|
||||
AM_CONDITIONAL([PNG_RISCV_RVV],
|
||||
[test "$enable_riscv_rvv" != "no" &&
|
||||
test "$compiler_support_riscv_rvv" = "yes" &&
|
||||
case "$host_cpu" in
|
||||
riscv64) : ;;
|
||||
*) test "$compiler_support_riscv_rvv" != '' ;;
|
||||
esac])
|
||||
|
||||
AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
|
||||
|
||||
# Config files, substituting as above
|
||||
|
15
contrib/conftest/fixed.dfa
Normal file
15
contrib/conftest/fixed.dfa
Normal file
@ -0,0 +1,15 @@
|
||||
# fixed.dfa
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Author: John Bowler
|
||||
# Copyright: (c) John Bowler, 2025
|
||||
# Usage rights:
|
||||
# To the extent possible under law, the author has waived all copyright and
|
||||
# related or neighboring rights to this work. This work is published from:
|
||||
# United States.
|
||||
#
|
||||
# Test the standard libpng configuration without floating point (the internal
|
||||
# fixed point implementations are used instead).
|
||||
#
|
||||
option FLOATING_ARITHMETIC off
|
||||
option FLOATING_POINT off
|
14
contrib/conftest/float-fixed.dfa
Normal file
14
contrib/conftest/float-fixed.dfa
Normal file
@ -0,0 +1,14 @@
|
||||
# fixed-float.dfa
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Author: John Bowler
|
||||
# Copyright: (c) John Bowler, 2025
|
||||
# Usage rights:
|
||||
# To the extent possible under law, the author has waived all copyright and
|
||||
# related or neighboring rights to this work. This work is published from:
|
||||
# United States.
|
||||
#
|
||||
# Test the standard libpng configuration with the fixed point internal
|
||||
# implementation in place of the default floating point
|
||||
#
|
||||
option FLOATING_ARITHMETIC off
|
21
contrib/conftest/nocompile-limits.dfa
Normal file
21
contrib/conftest/nocompile-limits.dfa
Normal file
@ -0,0 +1,21 @@
|
||||
# nolimits.dfa
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Author: John Bowler
|
||||
# Copyright: (c) John Bowler, 2025
|
||||
#
|
||||
# Usage rights:
|
||||
# To the extent possible under law, the author has waived all copyright and
|
||||
# related or neighboring rights to this work. This work is published from:
|
||||
# United States.
|
||||
#
|
||||
# Build libpng without any limits and without run-time settable limits. Turning
|
||||
# USER_LIMITS off reduces libpng code size by allowing compile-time elimination
|
||||
# of some checking code.
|
||||
#
|
||||
option USER_LIMITS off
|
||||
|
||||
@# define PNG_USER_WIDTH_MAX PNG_UINT_31_MAX
|
||||
@# define PNG_USER_HEIGHT_MAX PNG_UINT_31_MAX
|
||||
@# define PNG_USER_CHUNK_CACHE_MAX 0
|
||||
@# define PNG_USER_CHUNK_MALLOC_MAX 0
|
19
contrib/conftest/nolimits.dfa
Normal file
19
contrib/conftest/nolimits.dfa
Normal file
@ -0,0 +1,19 @@
|
||||
# nolimits.dfa
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Author: John Bowler
|
||||
# Copyright: (c) John Bowler, 2025
|
||||
#
|
||||
# Usage rights:
|
||||
# To the extent possible under law, the author has waived all copyright and
|
||||
# related or neighboring rights to this work. This work is published from:
|
||||
# United States.
|
||||
#
|
||||
# Build libpng without any limits. With these settigs run-time limits are still
|
||||
# possible.
|
||||
#
|
||||
@# define PNG_USER_WIDTH_MAX PNG_UINT_31_MAX
|
||||
@# define PNG_USER_HEIGHT_MAX PNG_UINT_31_MAX
|
||||
@# define PNG_USER_CHUNK_CACHE_MAX 0
|
||||
@# define PNG_USER_CHUNK_MALLOC_MAX 0
|
||||
|
13
contrib/conftest/read-full.dfa
Normal file
13
contrib/conftest/read-full.dfa
Normal file
@ -0,0 +1,13 @@
|
||||
# read-full.dfa
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Author: John Bowler
|
||||
# Copyright: (c) John Bowler, 2025
|
||||
# Usage rights:
|
||||
# To the extent possible under law, the author has waived all copyright and
|
||||
# related or neighboring rights to this work. This work is published from:
|
||||
# United States.
|
||||
#
|
||||
# Build libpng with no write support and full read support.
|
||||
#
|
||||
option WRITE off
|
13
contrib/conftest/write-full.dfa
Normal file
13
contrib/conftest/write-full.dfa
Normal file
@ -0,0 +1,13 @@
|
||||
# write-full.dfa
|
||||
# Build time configuration of libpng
|
||||
#
|
||||
# Author: John Bowler
|
||||
# Copyright: (c) John Bowler, 2025
|
||||
# Usage rights:
|
||||
# To the extent possible under law, the author has waived all copyright and
|
||||
# related or neighboring rights to this work. This work is published from:
|
||||
# United States.
|
||||
#
|
||||
# Build libpng with no read support and full write support.
|
||||
#
|
||||
option READ off
|
143
contrib/examples/.clang-format
Normal file
143
contrib/examples/.clang-format
Normal file
@ -0,0 +1,143 @@
|
||||
---
|
||||
Language: Cpp
|
||||
AccessModifierOffset: -3
|
||||
AlignAfterOpenBracket: Align
|
||||
AlignArrayOfStructures: None
|
||||
AlignConsecutiveAssignments:
|
||||
Enabled: false
|
||||
AlignConsecutiveBitFields:
|
||||
Enabled: false
|
||||
AlignConsecutiveDeclarations:
|
||||
Enabled: false
|
||||
AlignConsecutiveMacros:
|
||||
Enabled: false
|
||||
AlignConsecutiveShortCaseStatements:
|
||||
Enabled: false
|
||||
AlignEscapedNewlines: DontAlign
|
||||
AlignOperands: false
|
||||
AlignTrailingComments:
|
||||
Kind: Never
|
||||
OverEmptyLines: 0
|
||||
AllowAllArgumentsOnNextLine: true
|
||||
AllowAllParametersOfDeclarationOnNextLine: true
|
||||
AllowBreakBeforeNoexceptSpecifier: Never
|
||||
AllowShortBlocksOnASingleLine: Never
|
||||
AllowShortCaseExpressionOnASingleLine: true
|
||||
AllowShortCaseLabelsOnASingleLine: true
|
||||
AllowShortCompoundRequirementOnASingleLine: true
|
||||
AllowShortEnumsOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortIfStatementsOnASingleLine: Never
|
||||
AllowShortLambdasOnASingleLine: All
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AllowShortNamespacesOnASingleLine: false
|
||||
AlwaysBreakBeforeMultilineStrings: false
|
||||
BinPackArguments: true
|
||||
BinPackParameters: BinPack
|
||||
BitFieldColonSpacing: Both
|
||||
BraceWrapping:
|
||||
AfterCaseLabel: true
|
||||
AfterClass: true
|
||||
AfterControlStatement: Always
|
||||
AfterEnum: true
|
||||
AfterExternBlock: false
|
||||
AfterFunction: true
|
||||
AfterNamespace: false
|
||||
AfterObjCDeclaration: true
|
||||
AfterStruct: true
|
||||
AfterUnion: true
|
||||
BeforeCatch: true
|
||||
BeforeElse: true
|
||||
BeforeLambdaBody: false
|
||||
BeforeWhile: false
|
||||
IndentBraces: false
|
||||
SplitEmptyFunction: true
|
||||
SplitEmptyRecord: true
|
||||
SplitEmptyNamespace: true
|
||||
BreakAdjacentStringLiterals: true
|
||||
BreakAfterAttributes: Leave
|
||||
BreakAfterJavaFieldAnnotations: false
|
||||
BreakAfterReturnType: TopLevel
|
||||
BreakArrays: true
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeConceptDeclarations: Always
|
||||
BreakBeforeBraces: Custom
|
||||
BreakBeforeTernaryOperators: false
|
||||
BreakStringLiterals: false
|
||||
BreakTemplateDeclarations: MultiLine
|
||||
ColumnLimit: 79
|
||||
ContinuationIndentWidth: 3
|
||||
DerivePointerAlignment: true
|
||||
EmptyLineAfterAccessModifier: Never
|
||||
EmptyLineBeforeAccessModifier: LogicalBlock
|
||||
FixNamespaceComments: true
|
||||
IncludeBlocks: Preserve
|
||||
IndentAccessModifiers: false
|
||||
IndentCaseBlocks: true
|
||||
IndentCaseLabels: true
|
||||
IndentExportBlock: true
|
||||
IndentExternBlock: AfterExternBlock
|
||||
IndentGotoLabels: false
|
||||
IndentPPDirectives: None
|
||||
IndentRequiresClause: true
|
||||
IndentWidth: 3
|
||||
IndentWrappedFunctionNames: false
|
||||
KeepEmptyLines:
|
||||
AtEndOfFile: false
|
||||
AtStartOfBlock: false
|
||||
AtStartOfFile: false
|
||||
KeepFormFeed: false
|
||||
MaxEmptyLinesToKeep: 2
|
||||
NamespaceIndentation: None
|
||||
PackConstructorInitializers: Never
|
||||
PointerAlignment: Left
|
||||
QualifierAlignment: Custom
|
||||
QualifierOrder: [static, inline, constexpr, const, volatile, restrict, type]
|
||||
ReferenceAlignment: Pointer
|
||||
ReflowComments: Never
|
||||
RequiresClausePosition: OwnLine
|
||||
RequiresExpressionIndentation: OuterScope
|
||||
SortIncludes: false
|
||||
SortUsingDeclarations: LexicographicNumeric
|
||||
SpaceAfterCStyleCast: false
|
||||
SpaceAfterLogicalNot: false
|
||||
SpaceAfterTemplateKeyword: true
|
||||
SpaceAroundPointerQualifiers: Default
|
||||
SpaceBeforeAssignmentOperators: true
|
||||
SpaceBeforeCaseColon: false
|
||||
SpaceBeforeCpp11BracedList: false
|
||||
SpaceBeforeCtorInitializerColon: true
|
||||
SpaceBeforeInheritanceColon: true
|
||||
SpaceBeforeJsonColon: false
|
||||
SpaceBeforeParens: ControlStatements
|
||||
SpaceBeforeParensOptions:
|
||||
AfterControlStatements: true
|
||||
AfterFunctionDefinitionName: false
|
||||
AfterFunctionDeclarationName: false
|
||||
AfterOverloadedOperator: false
|
||||
AfterPlacementOperator: true
|
||||
AfterRequiresInClause: false
|
||||
AfterRequiresInExpression: false
|
||||
BeforeNonEmptyParentheses: false
|
||||
SpaceBeforeRangeBasedForLoopColon: true
|
||||
SpaceBeforeSquareBrackets: false
|
||||
SpaceInEmptyBlock: false
|
||||
SpacesBeforeTrailingComments: 1
|
||||
SpacesInAngles: Never
|
||||
SpacesInContainerLiterals: true
|
||||
SpacesInLineCommentPrefix:
|
||||
Minimum: 1
|
||||
Maximum: -1
|
||||
SpacesInParens: Never
|
||||
SpacesInParensOptions:
|
||||
ExceptDoubleParentheses: false
|
||||
InCStyleCasts: false
|
||||
InConditionalStatements: false
|
||||
InEmptyParentheses: false
|
||||
Other: false
|
||||
SpacesInSquareBrackets: false
|
||||
Standard: Latest
|
||||
TabWidth: 8
|
||||
UseTab: Never
|
||||
WrapNamespaceBodyWithEmptyLines: Leave
|
||||
...
|
@ -26,8 +26,9 @@
|
||||
|
||||
#include <png.h>
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) && defined(PNG_STDIO_SUPPORTED) && \
|
||||
defined (PNG_iCCP_SUPPORTED)
|
||||
#if !defined(PNG_iCCP_SUPPORTED) || !defined(PNG_READ_SUPPORTED)
|
||||
#error This program requires libpng supporting the iCCP chunk and the read API
|
||||
#endif
|
||||
|
||||
|
||||
static int verbose = 1;
|
||||
@ -36,7 +37,8 @@ static png_byte no_profile[] = "no profile";
|
||||
static png_bytep
|
||||
extract(FILE *fp, png_uint_32 *proflen)
|
||||
{
|
||||
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,0);
|
||||
png_structp png_ptr =
|
||||
png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
png_infop info_ptr = NULL;
|
||||
png_bytep result = NULL;
|
||||
|
||||
@ -69,7 +71,7 @@ extract(FILE *fp, png_uint_32 *proflen)
|
||||
png_bytep profile;
|
||||
|
||||
if (png_get_iCCP(png_ptr, info_ptr, &name, &compression_type, &profile,
|
||||
proflen) & PNG_INFO_iCCP)
|
||||
proflen) & PNG_INFO_iCCP)
|
||||
{
|
||||
result = malloc(*proflen);
|
||||
if (result != NULL)
|
||||
@ -107,7 +109,7 @@ extract_one_file(const char *filename)
|
||||
const char *ep = strrchr(filename, '.');
|
||||
|
||||
if (ep != NULL)
|
||||
len = ep-filename;
|
||||
len = ep - filename;
|
||||
|
||||
else
|
||||
len = strlen(filename);
|
||||
@ -119,14 +121,14 @@ extract_one_file(const char *filename)
|
||||
FILE *of;
|
||||
|
||||
memcpy(output, filename, len);
|
||||
strcpy(output+len, ".icc");
|
||||
strcpy(output + len, ".icc");
|
||||
|
||||
of = fopen(output, "wb");
|
||||
if (of != NULL)
|
||||
{
|
||||
if (fwrite(profile, proflen, 1, of) == 1 &&
|
||||
fflush(of) == 0 &&
|
||||
fclose(of) == 0)
|
||||
fflush(of) == 0 &&
|
||||
fclose(of) == 0)
|
||||
{
|
||||
if (verbose)
|
||||
printf("%s -> %s\n", filename, output);
|
||||
@ -161,6 +163,9 @@ extract_one_file(const char *filename)
|
||||
else
|
||||
fprintf(stderr, "%s: could not open file\n", filename);
|
||||
|
||||
if (fp != NULL)
|
||||
fclose(fp);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -170,7 +175,7 @@ main(int argc, char **argv)
|
||||
int i;
|
||||
int extracted = 0;
|
||||
|
||||
for (i=1; i<argc; ++i)
|
||||
for (i = 1; i < argc; ++i)
|
||||
{
|
||||
if (strcmp(argv[i], "-q") == 0)
|
||||
verbose = 0;
|
||||
@ -182,4 +187,3 @@ main(int argc, char **argv)
|
||||
/* Exit code is true if any extract succeeds */
|
||||
return extracted == 0;
|
||||
}
|
||||
#endif /* READ && STDIO && iCCP */
|
||||
|
@ -15,8 +15,8 @@
|
||||
* images. Normally you would call png_set_interlace_handling() to have libpng
|
||||
* deal with the interlace for you, but that obliges you to buffer half of the
|
||||
* image to assemble the interlaced rows. In this code
|
||||
* png_set_interlace_handling() is not called and, instead, the code handles the
|
||||
* interlace passes directly looking for the required pixel.
|
||||
* png_set_interlace_handling() is not called and, instead, the code handles
|
||||
* the interlace passes directly looking for the required pixel.
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
@ -27,34 +27,37 @@
|
||||
*/
|
||||
#include "../../png.h"
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) && defined(PNG_SEQUENTIAL_READ_SUPPORTED)
|
||||
#if !defined(PNG_READ_SUPPORTED) || !defined(PNG_SEQUENTIAL_READ_SUPPORTED)
|
||||
#error This program requires libpng supporting the read and sequential read API
|
||||
#endif
|
||||
|
||||
|
||||
/* Return component 'c' of pixel 'x' from the given row. */
|
||||
static unsigned int
|
||||
component(png_const_bytep row, png_uint_32 x, unsigned int c,
|
||||
unsigned int bit_depth, unsigned int channels)
|
||||
unsigned int bit_depth, unsigned int channels)
|
||||
{
|
||||
/* PNG images can be up to 2^31 pixels wide, but this means they can be up to
|
||||
* 2^37 bits wide (for a 64-bit pixel - the largest possible) and hence 2^34
|
||||
* bytes wide. Since the row fitted into memory, however, the following must
|
||||
/* PNG images can be up to 2^31 pixels wide, which means they can be up to
|
||||
* 2^37 bits wide (for a 64-bit pixel - the largest possible) and hence
|
||||
* 2^34 bytes wide. Since the row fitted into memory, the following must
|
||||
* work:
|
||||
*/
|
||||
png_uint_32 bit_offset_hi = bit_depth * ((x >> 6) * channels);
|
||||
png_uint_32 bit_offset_lo = bit_depth * ((x & 0x3f) * channels + c);
|
||||
|
||||
row = (png_const_bytep)(((const png_byte (*)[8])row) + bit_offset_hi);
|
||||
row = (png_const_bytep)(((const png_byte(*)[8])row) + bit_offset_hi);
|
||||
row += bit_offset_lo >> 3;
|
||||
bit_offset_lo &= 0x07;
|
||||
|
||||
/* PNG pixels are packed into bytes to put the first pixel in the highest
|
||||
* bits of the byte and into two bytes for 16-bit values with the high 8 bits
|
||||
* first, so:
|
||||
* bits of the byte, and into two bytes for 16-bit values with the high
|
||||
* 8 bits first, so:
|
||||
*/
|
||||
switch (bit_depth)
|
||||
{
|
||||
case 1: return (row[0] >> (7-bit_offset_lo)) & 0x01;
|
||||
case 2: return (row[0] >> (6-bit_offset_lo)) & 0x03;
|
||||
case 4: return (row[0] >> (4-bit_offset_lo)) & 0x0f;
|
||||
case 1: return (row[0] >> (7 - bit_offset_lo)) & 0x01;
|
||||
case 2: return (row[0] >> (6 - bit_offset_lo)) & 0x03;
|
||||
case 4: return (row[0] >> (4 - bit_offset_lo)) & 0x0f;
|
||||
case 8: return row[0];
|
||||
case 16: return (row[0] << 8) + row[1];
|
||||
default:
|
||||
@ -71,7 +74,7 @@ component(png_const_bytep row, png_uint_32 x, unsigned int c,
|
||||
*/
|
||||
static void
|
||||
print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
|
||||
png_uint_32 x)
|
||||
png_uint_32 x)
|
||||
{
|
||||
unsigned int bit_depth = png_get_bit_depth(png_ptr, info_ptr);
|
||||
|
||||
@ -92,22 +95,24 @@ print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
|
||||
int num_palette = 0;
|
||||
|
||||
if ((png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette) &
|
||||
PNG_INFO_PLTE) && num_palette > 0 && palette != NULL)
|
||||
PNG_INFO_PLTE) &&
|
||||
(num_palette > 0) &&
|
||||
(palette != NULL))
|
||||
{
|
||||
png_bytep trans_alpha = NULL;
|
||||
int num_trans = 0;
|
||||
if ((png_get_tRNS(png_ptr, info_ptr, &trans_alpha, &num_trans,
|
||||
NULL) & PNG_INFO_tRNS) && num_trans > 0 &&
|
||||
trans_alpha != NULL)
|
||||
NULL) & PNG_INFO_tRNS) &&
|
||||
(num_trans > 0) &&
|
||||
(trans_alpha != NULL))
|
||||
printf("INDEXED %u = %d %d %d %d\n", index,
|
||||
palette[index].red, palette[index].green,
|
||||
palette[index].blue,
|
||||
index < num_trans ? trans_alpha[index] : 255);
|
||||
palette[index].red, palette[index].green,
|
||||
palette[index].blue,
|
||||
index < num_trans ? trans_alpha[index] : 255);
|
||||
|
||||
else /* no transparency */
|
||||
printf("INDEXED %u = %d %d %d\n", index,
|
||||
palette[index].red, palette[index].green,
|
||||
palette[index].blue);
|
||||
printf("INDEXED %u = %d %d %d\n", index, palette[index].red,
|
||||
palette[index].green, palette[index].blue);
|
||||
}
|
||||
|
||||
else
|
||||
@ -117,20 +122,20 @@ print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
|
||||
|
||||
case PNG_COLOR_TYPE_RGB:
|
||||
printf("RGB %u %u %u\n", component(row, x, 0, bit_depth, 3),
|
||||
component(row, x, 1, bit_depth, 3),
|
||||
component(row, x, 2, bit_depth, 3));
|
||||
component(row, x, 1, bit_depth, 3),
|
||||
component(row, x, 2, bit_depth, 3));
|
||||
return;
|
||||
|
||||
case PNG_COLOR_TYPE_GRAY_ALPHA:
|
||||
printf("GRAY+ALPHA %u %u\n", component(row, x, 0, bit_depth, 2),
|
||||
component(row, x, 1, bit_depth, 2));
|
||||
component(row, x, 1, bit_depth, 2));
|
||||
return;
|
||||
|
||||
case PNG_COLOR_TYPE_RGB_ALPHA:
|
||||
printf("RGBA %u %u %u %u\n", component(row, x, 0, bit_depth, 4),
|
||||
component(row, x, 1, bit_depth, 4),
|
||||
component(row, x, 2, bit_depth, 4),
|
||||
component(row, x, 3, bit_depth, 4));
|
||||
component(row, x, 1, bit_depth, 4),
|
||||
component(row, x, 2, bit_depth, 4),
|
||||
component(row, x, 3, bit_depth, 4));
|
||||
return;
|
||||
|
||||
default:
|
||||
@ -138,7 +143,8 @@ print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
int
|
||||
main(int argc, const char **argv)
|
||||
{
|
||||
/* This program uses the default, <setjmp.h> based, libpng error handling
|
||||
* mechanism, therefore any local variable that exists before the call to
|
||||
@ -146,7 +152,7 @@ int main(int argc, const char **argv)
|
||||
* be declared with 'volatile' to ensure that their values don't get
|
||||
* destroyed by longjmp:
|
||||
*/
|
||||
volatile int result = 1/*fail*/;
|
||||
volatile int result = 1 /*fail*/;
|
||||
|
||||
if (argc == 4)
|
||||
{
|
||||
@ -163,8 +169,8 @@ int main(int argc, const char **argv)
|
||||
* writes error messages to stderr. Creating the png_struct is a
|
||||
* little tricky; just copy the following code.
|
||||
*/
|
||||
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
|
||||
NULL, NULL, NULL);
|
||||
png_structp png_ptr =
|
||||
png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
@ -184,11 +190,11 @@ int main(int argc, const char **argv)
|
||||
compression_method, filter_method;
|
||||
png_bytep row_tmp;
|
||||
|
||||
/* Now associate the recently opened (FILE*) with the default
|
||||
* libpng initialization functions. Sometimes libpng is
|
||||
* compiled without stdio support (it can be difficult to do
|
||||
* in some environments); in that case you will have to write
|
||||
* your own read callback to read data from the (FILE*).
|
||||
/* Now associate the recently opened FILE object with the
|
||||
* default libpng initialization functions. Sometimes libpng
|
||||
* is compiled without stdio support (it can be difficult to
|
||||
* do in some environments); in that case you will have to
|
||||
* write your own read callback to read data from the stream.
|
||||
*/
|
||||
png_init_io(png_ptr, f);
|
||||
|
||||
@ -202,21 +208,21 @@ int main(int argc, const char **argv)
|
||||
* space. In this case png_malloc is used - it will not
|
||||
* return if memory isn't available.
|
||||
*/
|
||||
row = png_malloc(png_ptr, png_get_rowbytes(png_ptr,
|
||||
info_ptr));
|
||||
row =
|
||||
png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr));
|
||||
|
||||
/* To avoid the overhead of using a volatile auto copy row_tmp
|
||||
/* Avoid the overhead of using a volatile auto copy row_tmp
|
||||
* to a local here - just use row for the png_free below.
|
||||
*/
|
||||
row_tmp = row;
|
||||
|
||||
/* All the information we need is in the header is returned by
|
||||
* png_get_IHDR, if this fails we can now use 'png_error' to
|
||||
/* All the information we need is in the header returned by
|
||||
* png_get_IHDR. If this fails, we can use 'png_error' to
|
||||
* signal the error and return control to the setjmp above.
|
||||
*/
|
||||
if (png_get_IHDR(png_ptr, info_ptr, &width, &height,
|
||||
&bit_depth, &color_type, &interlace_method,
|
||||
&compression_method, &filter_method))
|
||||
&bit_depth, &color_type, &interlace_method,
|
||||
&compression_method, &filter_method))
|
||||
{
|
||||
int passes, pass;
|
||||
|
||||
@ -242,7 +248,7 @@ int main(int argc, const char **argv)
|
||||
/* Now read the pixels, pass-by-pass, row-by-row: */
|
||||
png_start_read_image(png_ptr);
|
||||
|
||||
for (pass=0; pass<passes; ++pass)
|
||||
for (pass = 0; pass < passes; ++pass)
|
||||
{
|
||||
png_uint_32 ystart, xstart, ystep, xstep;
|
||||
png_uint_32 py;
|
||||
@ -299,19 +305,27 @@ int main(int argc, const char **argv)
|
||||
* are, of course, much better ways of doing this
|
||||
* than using a for loop:
|
||||
*/
|
||||
if (y == py) for (px = xstart, ppx = 0;
|
||||
px < width; px += xstep, ++ppx) if (x == px)
|
||||
if (y == py)
|
||||
{
|
||||
/* 'ppx' is the index of the pixel in the row
|
||||
* buffer.
|
||||
*/
|
||||
print_pixel(png_ptr, info_ptr, row_tmp, ppx);
|
||||
for (px = xstart, ppx = 0;
|
||||
px < width;
|
||||
px += xstep, ++ppx)
|
||||
{
|
||||
if (x == px)
|
||||
{
|
||||
/* 'ppx' is the index of the pixel in the
|
||||
* row buffer.
|
||||
*/
|
||||
print_pixel(png_ptr, info_ptr, row_tmp,
|
||||
ppx);
|
||||
|
||||
/* Now terminate the loops early - we have
|
||||
* found and handled the required data.
|
||||
*/
|
||||
goto pass_loop_end;
|
||||
} /* x loop */
|
||||
/* Now terminate the loops early - we have
|
||||
* found and handled the required data.
|
||||
*/
|
||||
goto pass_loop_end;
|
||||
} /* x loop */
|
||||
}
|
||||
}
|
||||
} /* y loop */
|
||||
} /* pass loop */
|
||||
|
||||
@ -323,7 +337,6 @@ int main(int argc, const char **argv)
|
||||
|
||||
else
|
||||
png_error(png_ptr, "pngpixel: png_get_IHDR failed");
|
||||
|
||||
}
|
||||
|
||||
else
|
||||
@ -349,7 +362,8 @@ int main(int argc, const char **argv)
|
||||
}
|
||||
|
||||
else
|
||||
fprintf(stderr, "pngpixel: out of memory allocating png_info\n");
|
||||
fprintf(stderr,
|
||||
"pngpixel: out of memory allocating png_info\n");
|
||||
|
||||
png_destroy_read_struct(&png_ptr, NULL, NULL);
|
||||
}
|
||||
@ -368,4 +382,3 @@ int main(int argc, const char **argv)
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif /* READ && SEQUENTIAL_READ */
|
||||
|
@ -8,8 +8,8 @@
|
||||
* Read a PNG and write it out in a fixed format, using the 'simplified API'
|
||||
* that was introduced in libpng-1.6.0.
|
||||
*
|
||||
* This sample code is just the code from the top of 'example.c' with some error
|
||||
* handling added. See example.c for more comments.
|
||||
* This sample code is just the code from 'example.c' with some error handling
|
||||
* added. See example.c in the top-level libpng directory for more comments.
|
||||
*/
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
@ -20,10 +20,15 @@
|
||||
* ensure the code picks up the local libpng implementation:
|
||||
*/
|
||||
#include "../../png.h"
|
||||
#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) && \
|
||||
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
#if !defined(PNG_SIMPLIFIED_READ_SUPPORTED) || \
|
||||
!defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
|
||||
#error This program requires libpng supporting the simplified read/write API
|
||||
#endif
|
||||
|
||||
|
||||
int
|
||||
main(int argc, const char **argv)
|
||||
{
|
||||
int result = 1;
|
||||
|
||||
@ -48,22 +53,22 @@ int main(int argc, const char **argv)
|
||||
|
||||
if (buffer != NULL)
|
||||
{
|
||||
if (png_image_finish_read(&image, NULL/*background*/, buffer,
|
||||
0/*row_stride*/, NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP */))
|
||||
if (png_image_finish_read(&image, NULL /*background*/, buffer,
|
||||
0 /*row_stride*/, NULL /*colormap */))
|
||||
{
|
||||
if (png_image_write_to_file(&image, argv[2],
|
||||
0/*convert_to_8bit*/, buffer, 0/*row_stride*/,
|
||||
NULL/*colormap*/))
|
||||
if (png_image_write_to_file(
|
||||
&image, argv[2], 0 /*convert_to_8bit*/, buffer,
|
||||
0 /*row_stride*/, NULL /*colormap*/))
|
||||
result = 0;
|
||||
|
||||
else
|
||||
fprintf(stderr, "pngtopng: write %s: %s\n", argv[2],
|
||||
image.message);
|
||||
image.message);
|
||||
}
|
||||
|
||||
else
|
||||
fprintf(stderr, "pngtopng: read %s: %s\n", argv[1],
|
||||
image.message);
|
||||
image.message);
|
||||
|
||||
free(buffer);
|
||||
}
|
||||
@ -71,7 +76,7 @@ int main(int argc, const char **argv)
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "pngtopng: out of memory: %lu bytes\n",
|
||||
(unsigned long)PNG_IMAGE_SIZE(image));
|
||||
(unsigned long)PNG_IMAGE_SIZE(image));
|
||||
|
||||
/* This is the only place where a 'free' is required; libpng does
|
||||
* the cleanup on error and success, but in this case we couldn't
|
||||
@ -93,4 +98,3 @@ int main(int argc, const char **argv)
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif /* READ && WRITE */
|
||||
|
@ -6,9 +6,9 @@
|
||||
* United States.
|
||||
*
|
||||
* Read several PNG files, which should have an alpha channel or transparency
|
||||
* information, and composite them together to produce one or more 16-bit linear
|
||||
* RGBA intermediates. This involves doing the correct 'over' composition to
|
||||
* combine the alpha channels and corresponding data.
|
||||
* information, and composite them together to produce one or more 16-bit
|
||||
* linear RGBA intermediates. This involves doing the 'over' compositing
|
||||
* operation to combine the alpha channels and corresponding data.
|
||||
*
|
||||
* Finally read an output (background) PNG using the 24-bit RGB format (the
|
||||
* PNG will be composited on green (#00ff00) by default if it has an alpha
|
||||
@ -28,8 +28,8 @@
|
||||
* correctly. Apart from the libpng Simplified API the only work done in here
|
||||
* is to combine multiple input PNG images into a single sprite; this involves
|
||||
* a Porter-Duff 'over' operation and the input PNG images may, as a result,
|
||||
* be regarded as being layered one on top of the other with the first (leftmost
|
||||
* on the command line) being at the bottom and the last on the top.
|
||||
* be regarded as being layered one on top of the other with the first
|
||||
* (leftmost on the command line) being at the bottom and the last on the top.
|
||||
*/
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
@ -44,54 +44,61 @@
|
||||
*/
|
||||
#include "../../png.h"
|
||||
|
||||
#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
|
||||
#if !defined(PNG_SIMPLIFIED_READ_SUPPORTED)
|
||||
#error This program requires libpng supporting the simplified read API
|
||||
#endif
|
||||
|
||||
#define sprite_name_chars 15
|
||||
struct sprite {
|
||||
FILE *file;
|
||||
png_uint_16p buffer;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
char name[sprite_name_chars+1];
|
||||
struct sprite
|
||||
{
|
||||
FILE *file;
|
||||
png_uint_16p buffer;
|
||||
unsigned int width;
|
||||
unsigned int height;
|
||||
char name[sprite_name_chars + 1];
|
||||
};
|
||||
|
||||
#if 0 /* div by 65535 test program */
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void) {
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
double err = 0;
|
||||
unsigned int xerr = 0;
|
||||
unsigned int r = 32769;
|
||||
unsigned int x = 0;
|
||||
|
||||
do
|
||||
{
|
||||
unsigned int x = 0;
|
||||
unsigned int t = x + (x >> 16) /*+ (x >> 31)*/ + r;
|
||||
double v = x, errtest;
|
||||
|
||||
do {
|
||||
unsigned int t = x + (x >> 16) /*+ (x >> 31)*/ + r;
|
||||
double v = x, errtest;
|
||||
if (t < x)
|
||||
{
|
||||
fprintf(stderr, "overflow: %u+%u -> %u\n", x, r, t);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (t < x) {
|
||||
fprintf(stderr, "overflow: %u+%u -> %u\n", x, r, t);
|
||||
return 1;
|
||||
v /= 65535;
|
||||
errtest = v;
|
||||
t >>= 16;
|
||||
errtest -= t;
|
||||
|
||||
if (errtest > err)
|
||||
{
|
||||
err = errtest;
|
||||
xerr = x;
|
||||
|
||||
if (errtest >= .5)
|
||||
{
|
||||
fprintf(stderr, "error: %u/65535 = %f, not %u, error %f\n",
|
||||
x, v, t, errtest);
|
||||
return 0;
|
||||
}
|
||||
|
||||
v /= 65535;
|
||||
errtest = v;
|
||||
t >>= 16;
|
||||
errtest -= t;
|
||||
|
||||
if (errtest > err) {
|
||||
err = errtest;
|
||||
xerr = x;
|
||||
|
||||
if (errtest >= .5) {
|
||||
fprintf(stderr, "error: %u/65535 = %f, not %u, error %f\n",
|
||||
x, v, t, errtest);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
} while (++x <= 65535U*65535U);
|
||||
}
|
||||
}
|
||||
} while (++x <= 65535U * 65535U);
|
||||
|
||||
printf("error %f @ %u\n", err, xerr);
|
||||
|
||||
@ -101,7 +108,7 @@ int main(void) {
|
||||
|
||||
static void
|
||||
sprite_op(const struct sprite *sprite, int x_offset, int y_offset,
|
||||
png_imagep image, const png_uint_16 *buffer)
|
||||
png_imagep image, const png_uint_16 *buffer)
|
||||
{
|
||||
/* This is where the Porter-Duff 'Over' operator is evaluated; change this
|
||||
* code to change the operator (this could be parameterized). Any other
|
||||
@ -112,8 +119,8 @@ sprite_op(const struct sprite *sprite, int x_offset, int y_offset,
|
||||
/* Check for an x or y offset that pushes any part of the image beyond the
|
||||
* right or bottom of the sprite:
|
||||
*/
|
||||
if ((y_offset < 0 || (unsigned)/*SAFE*/y_offset < sprite->height) &&
|
||||
(x_offset < 0 || (unsigned)/*SAFE*/x_offset < sprite->width))
|
||||
if ((y_offset < 0 || /*SAFE*/ (unsigned)y_offset < sprite->height) &&
|
||||
(x_offset < 0 || /*SAFE*/ (unsigned)x_offset < sprite->width))
|
||||
{
|
||||
unsigned int y = 0;
|
||||
|
||||
@ -130,7 +137,7 @@ sprite_op(const struct sprite *sprite, int x_offset, int y_offset,
|
||||
do
|
||||
{
|
||||
/* In and out are RGBA values, so: */
|
||||
const png_uint_16 *in_pixel = buffer + (y * image->width + x)*4;
|
||||
const png_uint_16 *in_pixel = buffer + (y * image->width + x) * 4;
|
||||
png_uint_32 in_alpha = in_pixel[3];
|
||||
|
||||
/* This is the optimized Porter-Duff 'Over' operation, when the
|
||||
@ -139,10 +146,10 @@ sprite_op(const struct sprite *sprite, int x_offset, int y_offset,
|
||||
if (in_alpha > 0)
|
||||
{
|
||||
png_uint_16 *out_pixel = sprite->buffer +
|
||||
((y+y_offset) * sprite->width + (x+x_offset))*4;
|
||||
((y + y_offset) * sprite->width + (x + x_offset)) * 4;
|
||||
|
||||
/* This is the weight to apply to the output: */
|
||||
in_alpha = 65535-in_alpha;
|
||||
in_alpha = 65535 - in_alpha;
|
||||
|
||||
if (in_alpha > 0)
|
||||
{
|
||||
@ -159,9 +166,9 @@ sprite_op(const struct sprite *sprite, int x_offset, int y_offset,
|
||||
*/
|
||||
png_uint_32 tmp;
|
||||
|
||||
# define compose(c)\
|
||||
tmp = out_pixel[c] * in_alpha;\
|
||||
tmp = (tmp + (tmp >> 16) + 32769) >> 16;\
|
||||
# define compose(c) \
|
||||
tmp = out_pixel[c] * in_alpha; \
|
||||
tmp = (tmp + (tmp >> 16) + 32769) >> 16; \
|
||||
out_pixel[c] = tmp + in_pixel[c]
|
||||
|
||||
/* The following is very vectorizable... */
|
||||
@ -172,15 +179,15 @@ sprite_op(const struct sprite *sprite, int x_offset, int y_offset,
|
||||
}
|
||||
|
||||
else
|
||||
out_pixel[0] = in_pixel[0],
|
||||
out_pixel[1] = in_pixel[1],
|
||||
out_pixel[2] = in_pixel[2],
|
||||
{
|
||||
out_pixel[0] = in_pixel[0];
|
||||
out_pixel[1] = in_pixel[1];
|
||||
out_pixel[2] = in_pixel[2];
|
||||
out_pixel[3] = in_pixel[3];
|
||||
}
|
||||
}
|
||||
}
|
||||
while (++x < image->width);
|
||||
}
|
||||
while (++y < image->height);
|
||||
} while (++x < image->width);
|
||||
} while (++y < image->height);
|
||||
}
|
||||
}
|
||||
|
||||
@ -224,9 +231,8 @@ create_sprite(struct sprite *sprite, int *argc, const char ***argv)
|
||||
|
||||
if (buffer != NULL)
|
||||
{
|
||||
if (png_image_finish_read(&image, NULL/*background*/, buffer,
|
||||
0/*row_stride*/,
|
||||
NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP*/))
|
||||
if (png_image_finish_read(&image, NULL /*background*/, buffer,
|
||||
0 /*row_stride*/, NULL /*colormap*/))
|
||||
{
|
||||
/* This is the place where the Porter-Duff 'Over' operator
|
||||
* needs to be done by this code. In fact, any image
|
||||
@ -245,14 +251,14 @@ create_sprite(struct sprite *sprite, int *argc, const char ***argv)
|
||||
{
|
||||
free(buffer);
|
||||
fprintf(stderr, "simpleover: read %s: %s\n", (*argv)[0],
|
||||
image.message);
|
||||
image.message);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "simpleover: out of memory: %lu bytes\n",
|
||||
(unsigned long)PNG_IMAGE_SIZE(image));
|
||||
(unsigned long)PNG_IMAGE_SIZE(image));
|
||||
|
||||
/* png_image_free must be called if we abort the Simplified API
|
||||
* read because of a problem detected in this code. If problems
|
||||
@ -290,8 +296,9 @@ create_sprite(struct sprite *sprite, int *argc, const char ***argv)
|
||||
save.flags = PNG_IMAGE_FLAG_FAST;
|
||||
save.colormap_entries = 0;
|
||||
|
||||
if (png_image_write_to_stdio(&save, sprite->file, 1/*convert_to_8_bit*/,
|
||||
sprite->buffer, 0/*row_stride*/, NULL/*colormap*/))
|
||||
if (png_image_write_to_stdio(&save, sprite->file, 1 /*convert_to_8_bit*/,
|
||||
sprite->buffer, 0 /*row_stride*/,
|
||||
NULL /*colormap*/))
|
||||
{
|
||||
/* Success; the buffer is no longer needed: */
|
||||
free(sprite->buffer);
|
||||
@ -301,19 +308,20 @@ create_sprite(struct sprite *sprite, int *argc, const char ***argv)
|
||||
|
||||
else
|
||||
fprintf(stderr, "simpleover: write sprite %s: %s\n", sprite->name,
|
||||
save.message);
|
||||
save.message);
|
||||
}
|
||||
|
||||
else
|
||||
fprintf(stderr, "simpleover: sprite %s: could not allocate tmpfile: %s\n",
|
||||
sprite->name, strerror(errno));
|
||||
fprintf(stderr,
|
||||
"simpleover: sprite %s: could not allocate tmpfile: %s\n",
|
||||
sprite->name, strerror(errno));
|
||||
|
||||
return 0; /* fail */
|
||||
}
|
||||
|
||||
static int
|
||||
add_sprite(png_imagep output, png_bytep out_buf, struct sprite *sprite,
|
||||
int *argc, const char ***argv)
|
||||
int *argc, const char ***argv)
|
||||
{
|
||||
/* Given a --add argument naming this sprite, perform the operations listed
|
||||
* in the following arguments. The arguments are expected to have the form
|
||||
@ -334,13 +342,13 @@ add_sprite(png_imagep output, png_bytep out_buf, struct sprite *sprite,
|
||||
* will fit.
|
||||
*/
|
||||
if (x < 0 || y < 0 ||
|
||||
(unsigned)/*SAFE*/x >= output->width ||
|
||||
(unsigned)/*SAFE*/y >= output->height ||
|
||||
sprite->width > output->width-x ||
|
||||
sprite->height > output->height-y)
|
||||
/*SAFE*/ (unsigned)x >= output->width ||
|
||||
/*SAFE*/ (unsigned)y >= output->height ||
|
||||
sprite->width > output->width - x ||
|
||||
sprite->height > output->height - y)
|
||||
{
|
||||
fprintf(stderr, "simpleover: sprite %s @ (%d,%d) outside image\n",
|
||||
sprite->name, x, y);
|
||||
sprite->name, x, y);
|
||||
/* Could just skip this, but for the moment it is an error */
|
||||
return 0; /* error */
|
||||
}
|
||||
@ -359,10 +367,10 @@ add_sprite(png_imagep output, png_bytep out_buf, struct sprite *sprite,
|
||||
{
|
||||
in.format = PNG_FORMAT_RGB; /* force compose */
|
||||
|
||||
if (png_image_finish_read(&in, NULL/*background*/,
|
||||
out_buf + (y*output->width + x)*3/*RGB*/,
|
||||
output->width*3/*row_stride*/,
|
||||
NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP*/))
|
||||
if (png_image_finish_read(
|
||||
&in, NULL /*background*/,
|
||||
out_buf + (y * output->width + x) * 3 /*RGB*/,
|
||||
output->width * 3 /*row_stride*/, NULL /*colormap*/))
|
||||
{
|
||||
++*argv, --*argc;
|
||||
continue;
|
||||
@ -371,7 +379,7 @@ add_sprite(png_imagep output, png_bytep out_buf, struct sprite *sprite,
|
||||
|
||||
/* The read failed: */
|
||||
fprintf(stderr, "simpleover: add sprite %s: %s\n", sprite->name,
|
||||
in.message);
|
||||
in.message);
|
||||
return 0; /* error */
|
||||
}
|
||||
}
|
||||
@ -379,7 +387,7 @@ add_sprite(png_imagep output, png_bytep out_buf, struct sprite *sprite,
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "simpleover: --add='%s': invalid position %s\n",
|
||||
sprite->name, (*argv)[0]);
|
||||
sprite->name, (*argv)[0]);
|
||||
return 0; /* error */
|
||||
}
|
||||
}
|
||||
@ -389,10 +397,10 @@ add_sprite(png_imagep output, png_bytep out_buf, struct sprite *sprite,
|
||||
|
||||
static int
|
||||
simpleover_process(png_imagep output, png_bytep out_buf, int argc,
|
||||
const char **argv)
|
||||
const char **argv)
|
||||
{
|
||||
int result = 1; /* success */
|
||||
# define csprites 10/*limit*/
|
||||
# define csprites 10 /*limit*/
|
||||
# define str(a) #a
|
||||
int nsprites = 0;
|
||||
struct sprite sprites[csprites];
|
||||
@ -412,23 +420,25 @@ simpleover_process(png_imagep output, png_bytep out_buf, int argc,
|
||||
sprites[nsprites].width = sprites[nsprites].height = 0;
|
||||
sprites[nsprites].name[0] = 0;
|
||||
|
||||
n = sscanf(argv[0], "--sprite=%u,%u,%" str(sprite_name_chars) "s%c",
|
||||
&sprites[nsprites].width, &sprites[nsprites].height,
|
||||
sprites[nsprites].name, &tombstone);
|
||||
n = sscanf(argv[0],
|
||||
"--sprite=%u,%u,%" str(sprite_name_chars) "s%c",
|
||||
&sprites[nsprites].width, &sprites[nsprites].height,
|
||||
sprites[nsprites].name, &tombstone);
|
||||
|
||||
if ((n == 2 || n == 3) &&
|
||||
sprites[nsprites].width > 0 && sprites[nsprites].height > 0)
|
||||
(sprites[nsprites].width > 0) &&
|
||||
(sprites[nsprites].height > 0))
|
||||
{
|
||||
size_t buf_size, tmp;
|
||||
|
||||
/* Default a name if not given. */
|
||||
if (sprites[nsprites].name[0] == 0)
|
||||
sprintf(sprites[nsprites].name, "sprite-%d", nsprites+1);
|
||||
sprintf(sprites[nsprites].name, "sprite-%d", nsprites + 1);
|
||||
|
||||
/* Allocate a buffer for the sprite and calculate the buffer
|
||||
* size:
|
||||
*/
|
||||
buf_size = sizeof (png_uint_16 [4]);
|
||||
buf_size = sizeof(png_uint_16[4]);
|
||||
buf_size *= sprites[nsprites].width;
|
||||
buf_size *= sprites[nsprites].height;
|
||||
|
||||
@ -437,7 +447,7 @@ simpleover_process(png_imagep output, png_bytep out_buf, int argc,
|
||||
tmp /= sprites[nsprites].width;
|
||||
tmp /= sprites[nsprites].height;
|
||||
|
||||
if (tmp == sizeof (png_uint_16 [4]))
|
||||
if (tmp == sizeof(png_uint_16[4]))
|
||||
{
|
||||
sprites[nsprites].buffer = malloc(buf_size);
|
||||
/* This buffer must be initialized to transparent: */
|
||||
@ -448,7 +458,7 @@ simpleover_process(png_imagep output, png_bytep out_buf, int argc,
|
||||
sprites[nsprites].file = NULL;
|
||||
++argv, --argc;
|
||||
|
||||
if (create_sprite(sprites+nsprites++, &argc, &argv))
|
||||
if (create_sprite(sprites + nsprites++, &argc, &argv))
|
||||
{
|
||||
result = 1; /* still ok */
|
||||
continue;
|
||||
@ -466,7 +476,8 @@ simpleover_process(png_imagep output, png_bytep out_buf, int argc,
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "simpleover: %s: invalid sprite (%u,%u)\n",
|
||||
argv[0], sprites[nsprites].width, sprites[nsprites].height);
|
||||
argv[0],
|
||||
sprites[nsprites].width, sprites[nsprites].height);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -480,7 +491,7 @@ simpleover_process(png_imagep output, png_bytep out_buf, int argc,
|
||||
|
||||
else if (strncmp(argv[0], "--add=", 6) == 0)
|
||||
{
|
||||
const char *name = argv[0]+6;
|
||||
const char *name = argv[0] + 6;
|
||||
int isprite = nsprites;
|
||||
|
||||
++argv, --argc;
|
||||
@ -489,7 +500,8 @@ simpleover_process(png_imagep output, png_bytep out_buf, int argc,
|
||||
{
|
||||
if (strcmp(sprites[isprite].name, name) == 0)
|
||||
{
|
||||
if (!add_sprite(output, out_buf, sprites+isprite, &argc, &argv))
|
||||
if (!add_sprite(output, out_buf, sprites + isprite,
|
||||
&argc, &argv))
|
||||
goto out; /* error in add_sprite */
|
||||
|
||||
break;
|
||||
@ -498,7 +510,8 @@ simpleover_process(png_imagep output, png_bytep out_buf, int argc,
|
||||
|
||||
if (isprite < 0) /* sprite not found */
|
||||
{
|
||||
fprintf(stderr, "simpleover: --add='%s': sprite not found\n", name);
|
||||
fprintf(stderr, "simpleover: --add='%s': sprite not found\n",
|
||||
name);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -526,7 +539,8 @@ out:
|
||||
return result;
|
||||
}
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
int
|
||||
main(int argc, const char **argv)
|
||||
{
|
||||
int result = 1; /* default to fail */
|
||||
|
||||
@ -536,7 +550,7 @@ int main(int argc, const char **argv)
|
||||
const char *output = NULL;
|
||||
png_image image;
|
||||
|
||||
if (argc > 2 && argv[2][0] != '-'/*an operation*/)
|
||||
if (argc > 2 && argv[2][0] != '-' /*an operation*/)
|
||||
{
|
||||
output = argv[2];
|
||||
argi = 3;
|
||||
@ -558,7 +572,7 @@ int main(int argc, const char **argv)
|
||||
png_color background = {0, 0xff, 0}; /* fully saturated green */
|
||||
|
||||
if (png_image_finish_read(&image, &background, buffer,
|
||||
0/*row_stride*/, NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP */))
|
||||
0 /*row_stride*/, NULL /*colormap*/))
|
||||
{
|
||||
/* At this point png_image_finish_read has cleaned up the
|
||||
* allocated data in png_image, and only the buffer needs to be
|
||||
@ -566,22 +580,24 @@ int main(int argc, const char **argv)
|
||||
*
|
||||
* Perform the remaining operations:
|
||||
*/
|
||||
if (simpleover_process(&image, buffer, argc-argi, argv+argi))
|
||||
if (simpleover_process(&image, buffer,
|
||||
argc - argi, argv + argi))
|
||||
{
|
||||
/* Write the output: */
|
||||
if ((output != NULL &&
|
||||
png_image_write_to_file(&image, output,
|
||||
0/*convert_to_8bit*/, buffer, 0/*row_stride*/,
|
||||
NULL/*colormap*/)) ||
|
||||
png_image_write_to_file(
|
||||
&image, output, 0 /*convert_to_8bit*/, buffer,
|
||||
0 /*row_stride*/, NULL /*colormap*/)) ||
|
||||
(output == NULL &&
|
||||
png_image_write_to_stdio(&image, stdout,
|
||||
0/*convert_to_8bit*/, buffer, 0/*row_stride*/,
|
||||
NULL/*colormap*/)))
|
||||
png_image_write_to_stdio(
|
||||
&image, stdout, 0 /*convert_to_8bit*/, buffer,
|
||||
0 /*row_stride*/, NULL /*colormap*/)))
|
||||
result = 0;
|
||||
|
||||
else
|
||||
fprintf(stderr, "simpleover: write %s: %s\n",
|
||||
output == NULL ? "stdout" : output, image.message);
|
||||
output == NULL ? "stdout" : output,
|
||||
image.message);
|
||||
}
|
||||
|
||||
/* else simpleover_process writes an error message */
|
||||
@ -589,7 +605,7 @@ int main(int argc, const char **argv)
|
||||
|
||||
else
|
||||
fprintf(stderr, "simpleover: read %s: %s\n", argv[1],
|
||||
image.message);
|
||||
image.message);
|
||||
|
||||
free(buffer);
|
||||
}
|
||||
@ -597,7 +613,7 @@ int main(int argc, const char **argv)
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "simpleover: out of memory: %lu bytes\n",
|
||||
(unsigned long)PNG_IMAGE_SIZE(image));
|
||||
(unsigned long)PNG_IMAGE_SIZE(image));
|
||||
|
||||
/* This is the only place where a 'free' is required; libpng does
|
||||
* the cleanup on error and success, but in this case we couldn't
|
||||
@ -617,7 +633,8 @@ int main(int argc, const char **argv)
|
||||
else
|
||||
{
|
||||
/* Usage message */
|
||||
fprintf(stderr,
|
||||
fprintf(
|
||||
stderr,
|
||||
"simpleover: usage: simpleover background.png [output.png]\n"
|
||||
" Output 'background.png' as a 24-bit RGB PNG file in 'output.png'\n"
|
||||
" or, if not given, stdout. 'background.png' will be composited\n"
|
||||
@ -628,13 +645,13 @@ int main(int argc, const char **argv)
|
||||
" --sprite=width,height,name {[--at=x,y] {sprite.png}}\n"
|
||||
" Produce a transparent sprite of size (width,height) and with\n"
|
||||
" name 'name'.\n"
|
||||
" For each sprite.png composite it using a Porter-Duff 'Over'\n"
|
||||
" operation at offset (x,y) in the sprite (defaulting to (0,0)).\n"
|
||||
" For each sprite.png composite it is using a Porter-Duff 'Over'\n"
|
||||
" operation at offset (x,y) in the sprite, defaulting to (0,0).\n"
|
||||
" Input PNGs will be truncated to the area of the sprite.\n"
|
||||
"\n"
|
||||
" --add='name' {x,y}\n"
|
||||
" Optionally, before output, composite a sprite, 'name', which\n"
|
||||
" must have been previously produced using --sprite, at each\n"
|
||||
" must have been previously produced using --sprite at each\n"
|
||||
" offset (x,y) in the output image. Each sprite must fit\n"
|
||||
" completely within the output image.\n"
|
||||
"\n"
|
||||
@ -645,4 +662,3 @@ int main(int argc, const char **argv)
|
||||
|
||||
return result;
|
||||
}
|
||||
#endif /* SIMPLIFIED_READ */
|
||||
|
@ -542,6 +542,7 @@ typedef enum
|
||||
struct display
|
||||
{
|
||||
jmp_buf error_return; /* Where to go to on error */
|
||||
error_level error_code; /* Set before longjmp */
|
||||
|
||||
const char *filename; /* The name of the original file */
|
||||
const char *operation; /* Operation being performed */
|
||||
@ -762,7 +763,10 @@ display_log(struct display *dp, error_level level, const char *fmt, ...)
|
||||
|
||||
/* Errors cause this routine to exit to the fail code */
|
||||
if (level > APP_FAIL || (level > ERRORS && !(dp->options & CONTINUE)))
|
||||
{
|
||||
dp->error_code = level;
|
||||
longjmp(dp->error_return, level);
|
||||
}
|
||||
}
|
||||
|
||||
/* error handler callbacks for libpng */
|
||||
@ -1570,18 +1574,19 @@ static int
|
||||
do_test(struct display *dp, const char *file)
|
||||
/* Exists solely to isolate the setjmp clobbers */
|
||||
{
|
||||
int ret = setjmp(dp->error_return);
|
||||
dp->error_code = VERBOSE; /* The "lowest" level */
|
||||
|
||||
if (ret == 0)
|
||||
if (setjmp(dp->error_return) == 0)
|
||||
{
|
||||
test_one_file(dp, file);
|
||||
return 0;
|
||||
}
|
||||
|
||||
else if (ret < ERRORS) /* shouldn't longjmp on warnings */
|
||||
display_log(dp, INTERNAL_ERROR, "unexpected return code %d", ret);
|
||||
else if (dp->error_code < ERRORS) /* shouldn't longjmp on warnings */
|
||||
display_log(dp, INTERNAL_ERROR, "unexpected return code %d",
|
||||
dp->error_code);
|
||||
|
||||
return ret;
|
||||
return dp->error_code;
|
||||
}
|
||||
|
||||
int
|
||||
@ -1681,7 +1686,11 @@ main(int argc, char **argv)
|
||||
int ret = do_test(&d, argv[i]);
|
||||
|
||||
if (ret > QUIET) /* abort on user or internal error */
|
||||
{
|
||||
display_clean(&d);
|
||||
display_destroy(&d);
|
||||
return 99;
|
||||
}
|
||||
}
|
||||
|
||||
/* Here on any return, including failures, except user/internal issues
|
||||
|
@ -595,7 +595,8 @@ newimage(Image *image)
|
||||
memset(image, 0, sizeof *image);
|
||||
}
|
||||
|
||||
/* Reset the image to be read again - only needs to rewind the FILE* at present.
|
||||
/* Reset the image to be read again - only needs to rewind the FILE object at
|
||||
* present.
|
||||
*/
|
||||
static void
|
||||
resetimage(Image *image)
|
||||
|
85
contrib/riscv-rvv/README
Normal file
85
contrib/riscv-rvv/README
Normal 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
contrib/riscv-rvv/linux.c
Normal file
36
contrib/riscv-rvv/linux.c
Normal 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() {
|
||||
#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
|
||||
}
|
@ -32,7 +32,7 @@
|
||||
#endif
|
||||
|
||||
#if PNG_LIBPNG_VER < 10603 /* 1.6.3 */
|
||||
# error "pngfix will not work with libpng prior to 1.6.3"
|
||||
# error pngfix requires libpng version 1.6.3 or newer
|
||||
#endif
|
||||
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
@ -68,7 +68,7 @@
|
||||
#endif
|
||||
|
||||
#ifndef PNG_MAXIMUM_INFLATE_WINDOW
|
||||
# error "pngfix not supported in this libpng version"
|
||||
# error pngfix requires libpng with PNG_MAXIMUM_INFLATE_WINDOW supported
|
||||
#endif
|
||||
|
||||
#if ZLIB_VERNUM >= 0x1240
|
||||
|
8
depcomp
8
depcomp
@ -1,9 +1,9 @@
|
||||
#! /bin/sh
|
||||
# depcomp - compile a program generating dependencies as side-effects
|
||||
|
||||
scriptversion=2024-06-19.01; # UTC
|
||||
scriptversion=2025-06-18.21; # UTC
|
||||
|
||||
# Copyright (C) 1999-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1999-2025 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -784,9 +784,9 @@ exit 0
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp nil t)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-format: "%Y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
|
12
example.c
12
example.c
@ -2,7 +2,7 @@
|
||||
|
||||
/* example.c - an example of using libpng
|
||||
*
|
||||
* Maintained 2018-2024 Cosmin Truta
|
||||
* Maintained 2018-2025 Cosmin Truta
|
||||
* Maintained 1998-2016 Glenn Randers-Pehrson
|
||||
* Maintained 1996-1997 Andreas Dilger
|
||||
* Written 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -179,11 +179,11 @@ int main(int argc, const char **argv)
|
||||
* components.
|
||||
*
|
||||
* You do not have to read directly from a file. You can read from memory or,
|
||||
* on systems that support it, from a <stdio.h> FILE*. This is controlled by
|
||||
* the particular png_image_read_from_ function you call at the start.
|
||||
* Likewise, on write, you can write to a FILE* if your system supports it.
|
||||
* Check the macro PNG_STDIO_SUPPORTED to see if stdio support has been
|
||||
* included in your libpng build.
|
||||
* on systems that support <stdio.h>, from a FILE object. This is controlled
|
||||
* by the particular png_image_begin_read_from_ function you call at the start.
|
||||
* Likewise, on write, you can write to a FILE object if your system supports
|
||||
* <stdio.h>. The macro PNG_STDIO_SUPPORTED indicates if stdio is available
|
||||
* and accessible from your libpng build.
|
||||
*
|
||||
* If you read 16-bit (PNG_FORMAT_FLAG_LINEAR) data, you may need to write it
|
||||
* in the 8-bit format for display. You do this by setting the convert_to_8bit
|
||||
|
@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
# install - install a program, script, or datafile
|
||||
|
||||
scriptversion=2024-06-19.01; # UTC
|
||||
scriptversion=2025-06-18.21; # UTC
|
||||
|
||||
# This originates from X11R5 (mit/util/scripts/install.sh), which was
|
||||
# later released in X11R6 (xc/config/util/install.sh) with the
|
||||
@ -533,9 +533,9 @@ do
|
||||
done
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp nil t)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-format: "%Y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
|
@ -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.46 - January 2025
|
||||
libpng version 1.6.36, December 2018, through 1.6.50 - July 2025
|
||||
Updated and distributed by Cosmin Truta
|
||||
Copyright (c) 2018-2025 Cosmin Truta
|
||||
|
||||
@ -65,18 +65,22 @@ Libpng was written as a companion to the PNG specification, as a way
|
||||
of reducing the amount of time and effort it takes to support the PNG
|
||||
file format in application programs.
|
||||
|
||||
The PNG specification (second edition), November 2003, is available as
|
||||
The PNG specification (Third Edition), June 2025, is available as
|
||||
a W3C Recommendation at
|
||||
<https://www.w3.org/TR/2025/REC-png-3-20250624/>.
|
||||
|
||||
The PNG specification (Second Edition), November 2003, is available as
|
||||
a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2004 (E)) at
|
||||
<https://www.w3.org/TR/2003/REC-PNG-20031110/>.
|
||||
The W3C and ISO documents have identical technical content.
|
||||
|
||||
The PNG-1.2 specification is available at
|
||||
<https://png-mng.sourceforge.io/pub/png/spec/1.2/>.
|
||||
It is technically equivalent
|
||||
to the PNG specification (second edition) but has some additional material.
|
||||
<https://www.libpng.org/pub/png/spec/1.2/>.
|
||||
It is technically equivalent to the PNG specification (Second Edition)
|
||||
but has some additional material.
|
||||
|
||||
The PNG-1.0 specification is available as RFC 2083 at
|
||||
<https://png-mng.sourceforge.io/pub/png/spec/1.0/> and as a
|
||||
<https://www.libpng.org/pub/png/spec/1.0/> and as a
|
||||
W3C Recommendation at <https://www.w3.org/TR/REC-png-961001>.
|
||||
|
||||
Some additional chunks are described in the special-purpose public chunks
|
||||
@ -4089,7 +4093,7 @@ READ APIs
|
||||
is filled in from the PNG header in the file.
|
||||
|
||||
int png_image_begin_read_from_stdio (png_imagep image,
|
||||
FILE* file)
|
||||
FILE *file)
|
||||
|
||||
The PNG header is read from the stdio FILE object.
|
||||
|
||||
@ -4164,7 +4168,7 @@ be written:
|
||||
int convert_to_8_bit, const void *buffer,
|
||||
png_int_32 row_stride, const void *colormap)
|
||||
|
||||
Write the image to the given (FILE*).
|
||||
Write the image to the given FILE object.
|
||||
|
||||
With all write APIs if image is in one of the linear formats with
|
||||
(png_uint_16) data then setting convert_to_8_bit will cause the output to be
|
||||
|
26
libpng.3
26
libpng.3
@ -1,6 +1,6 @@
|
||||
.TH LIBPNG 3 "January 23, 2025"
|
||||
.TH LIBPNG 3 "July 1, 2025"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.46
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.50
|
||||
|
||||
.SH SYNOPSIS
|
||||
\fB#include <png.h>\fP
|
||||
@ -223,7 +223,7 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.6.46
|
||||
|
||||
\fBint png_image_begin_read_from_file (png_imagep \fP\fIimage\fP\fB, const char \fI*file_name\fP\fB);\fP
|
||||
|
||||
\fBint png_image_begin_read_from_stdio (png_imagep \fP\fIimage\fP\fB, FILE* \fIfile\fP\fB);\fP
|
||||
\fBint png_image_begin_read_from_stdio (png_imagep \fP\fIimage\fP\fB, FILE *\fIfile\fP\fB);\fP
|
||||
|
||||
\fBint, png_image_begin_read_from_memory (png_imagep \fP\fIimage\fP\fB, png_const_voidp \fP\fImemory\fP\fB, size_t \fIsize\fP\fB);\fP
|
||||
|
||||
@ -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.46 - January 2025
|
||||
libpng version 1.6.36, December 2018, through 1.6.50 - July 2025
|
||||
Updated and distributed by Cosmin Truta
|
||||
Copyright (c) 2018-2025 Cosmin Truta
|
||||
|
||||
@ -584,18 +584,22 @@ Libpng was written as a companion to the PNG specification, as a way
|
||||
of reducing the amount of time and effort it takes to support the PNG
|
||||
file format in application programs.
|
||||
|
||||
The PNG specification (second edition), November 2003, is available as
|
||||
The PNG specification (Third Edition), June 2025, is available as
|
||||
a W3C Recommendation at
|
||||
<https://www.w3.org/TR/2025/REC-png-3-20250624/>.
|
||||
|
||||
The PNG specification (Second Edition), November 2003, is available as
|
||||
a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2004 (E)) at
|
||||
<https://www.w3.org/TR/2003/REC-PNG-20031110/>.
|
||||
The W3C and ISO documents have identical technical content.
|
||||
|
||||
The PNG-1.2 specification is available at
|
||||
<https://png-mng.sourceforge.io/pub/png/spec/1.2/>.
|
||||
It is technically equivalent
|
||||
to the PNG specification (second edition) but has some additional material.
|
||||
<https://www.libpng.org/pub/png/spec/1.2/>.
|
||||
It is technically equivalent to the PNG specification (Second Edition)
|
||||
but has some additional material.
|
||||
|
||||
The PNG-1.0 specification is available as RFC 2083 at
|
||||
<https://png-mng.sourceforge.io/pub/png/spec/1.0/> and as a
|
||||
<https://www.libpng.org/pub/png/spec/1.0/> and as a
|
||||
W3C Recommendation at <https://www.w3.org/TR/REC-png-961001>.
|
||||
|
||||
Some additional chunks are described in the special-purpose public chunks
|
||||
@ -4608,7 +4612,7 @@ READ APIs
|
||||
is filled in from the PNG header in the file.
|
||||
|
||||
int png_image_begin_read_from_stdio (png_imagep image,
|
||||
FILE* file)
|
||||
FILE *file)
|
||||
|
||||
The PNG header is read from the stdio FILE object.
|
||||
|
||||
@ -4683,7 +4687,7 @@ be written:
|
||||
int convert_to_8_bit, const void *buffer,
|
||||
png_int_32 row_stride, const void *colormap)
|
||||
|
||||
Write the image to the given (FILE*).
|
||||
Write the image to the given FILE object.
|
||||
|
||||
With all write APIs if image is in one of the linear formats with
|
||||
(png_uint_16) data then setting convert_to_8_bit will cause the output to be
|
||||
|
21
libpngpf.3
21
libpngpf.3
@ -1,24 +1,17 @@
|
||||
.TH LIBPNGPF 3 "January 23, 2025"
|
||||
.TH LIBPNGPF 3 "July 1, 2025"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.46
|
||||
(private functions)
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.50
|
||||
|
||||
.SH SYNOPSIS
|
||||
\fB#include \fI"pngpriv.h"
|
||||
|
||||
\fBAs of libpng version \fP\fI1.5.1\fP\fB, this section is no longer
|
||||
\fP\fImaintained\fP\fB, now that the private function prototypes are hidden in
|
||||
\fP\fIpngpriv.h\fP\fB and not accessible to applications. Look in
|
||||
\fP\fIpngpriv.h\fP\fB for the prototypes and a short description of each
|
||||
function.
|
||||
\fB#include "pngpriv.h"\fP
|
||||
|
||||
.SH DESCRIPTION
|
||||
The functions previously listed here are used privately by libpng and are not
|
||||
available for use by applications. They are not "exported" to applications
|
||||
using shared libraries.
|
||||
As of libpng version 1.5.1, this manual is no longer maintained. The private
|
||||
function prototypes, declared in private header files, should not be accessed
|
||||
by applications.
|
||||
|
||||
.SH "SEE ALSO"
|
||||
.BR "png"(5), " libpng"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5)
|
||||
.BR "libpng"(3)
|
||||
|
||||
.SH AUTHORS
|
||||
Cosmin Truta, Glenn Randers-Pehrson
|
||||
|
@ -48,7 +48,7 @@ static int png_have_msa(png_structp png_ptr);
|
||||
#include PNG_MIPS_MSA_FILE
|
||||
|
||||
#else /* PNG_MIPS_MSA_FILE */
|
||||
# error "PNG_MIPS_MSA_FILE undefined: no support for run-time MIPS MSA checks"
|
||||
# error PNG_MIPS_MSA_FILE undefined: no support for run-time MIPS MSA checks
|
||||
#endif /* PNG_MIPS_MSA_FILE */
|
||||
#endif /* PNG_MIPS_MSA_CHECK_SUPPORTED */
|
||||
|
||||
@ -66,12 +66,12 @@ 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"
|
||||
# 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"
|
||||
# error ALIGNED_MEMORY is required; please define PNG_ALIGNED_MEMORY_SUPPORTED
|
||||
#endif
|
||||
|
||||
/* MIPS supports two optimizations: MMI and MSA. The appropriate
|
||||
|
8
missing
8
missing
@ -1,11 +1,11 @@
|
||||
#! /bin/sh
|
||||
# Common wrapper for a few potentially missing GNU and other programs.
|
||||
|
||||
scriptversion=2024-06-07.14; # UTC
|
||||
scriptversion=2025-06-18.21; # UTC
|
||||
|
||||
# shellcheck disable=SC2006,SC2268 # we must support pre-POSIX shells
|
||||
|
||||
# Copyright (C) 1996-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2025 Free Software Foundation, Inc.
|
||||
# Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
@ -228,9 +228,9 @@ give_advice "$1" | sed -e '1s/^/WARNING: /' \
|
||||
exit $st
|
||||
|
||||
# Local variables:
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp nil t)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-format: "%Y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
|
34
png.5
34
png.5
@ -1,4 +1,4 @@
|
||||
.TH PNG 5 "January 23, 2025"
|
||||
.TH PNG 5 "July 1, 2025"
|
||||
.SH NAME
|
||||
png \- Portable Network Graphics (PNG) format
|
||||
|
||||
@ -20,20 +20,25 @@ matching on heterogeneous platforms.
|
||||
.SH "SEE ALSO"
|
||||
.BR "libpng"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5)
|
||||
.LP
|
||||
PNG Specification (Third Edition) Candidate Recommendation Draft, July 2024:
|
||||
PNG Specification (Third Edition), June 2025:
|
||||
.IP
|
||||
.br
|
||||
https://www.w3.org/TR/2024/CRD-png-3-20240718/
|
||||
https://www.w3.org/TR/2025/REC-png-3-20250624/
|
||||
.LP
|
||||
PNG Specification (Second Edition), November 2003:
|
||||
.IP
|
||||
.br
|
||||
https://www.w3.org/TR/2003/REC-PNG-20031110/
|
||||
.LP
|
||||
PNG 1.2 Specification, July 1999:
|
||||
PNG 1.2 Specification, August 1999:
|
||||
.IP
|
||||
.br
|
||||
https://png-mng.sourceforge.io/pub/png/spec/1.2/
|
||||
https://www.libpng.org/pub/png/spec/1.2/
|
||||
.LP
|
||||
PNG 1.1 Specification, December 1998:
|
||||
.IP
|
||||
.br
|
||||
https://www.libpng.org/pub/png/spec/1.1/
|
||||
.LP
|
||||
PNG 1.0 Specification, October 1996:
|
||||
.IP
|
||||
@ -50,15 +55,24 @@ https://www.w3.org/TR/REC-png-961001
|
||||
.SH AUTHORS
|
||||
This man page: Glenn Randers-Pehrson, Cosmin Truta
|
||||
.LP
|
||||
Portable Network Graphics (PNG) Specification (Third Edition).
|
||||
W3C Recommendation 24 June 2025:
|
||||
Chris Blume et al.
|
||||
.LP
|
||||
Portable Network Graphics (PNG) Specification (Second Edition)
|
||||
Information technology - Computer graphics and image processing -
|
||||
Portable Network Graphics (PNG): Functional specification.
|
||||
ISO/IEC 15948:2003 (E) (November 10, 2003): David Duce and others.
|
||||
ISO/IEC 15948:2003 (E), W3C Recommendation 10 November 2003:
|
||||
David Duce et al.
|
||||
.LP
|
||||
Portable Network Graphics (PNG) Specification Version 1.2 (July 8, 1999):
|
||||
Glenn Randers-Pehrson and others.
|
||||
Portable Network Graphics (PNG) Specification Version 1.2 (11 August 1999):
|
||||
Glenn Randers-Pehrson et al.
|
||||
.LP
|
||||
Portable Network Graphics (PNG) Specification Version 1.0 (October 1, 1996):
|
||||
Thomas Boutell and others.
|
||||
Portable Network Graphics (PNG) Specification Version 1.1 (31 December 1998):
|
||||
Glenn Randers-Pehrson et al.
|
||||
.LP
|
||||
Portable Network Graphics (PNG) Specification Version 1.0.
|
||||
IETF RFC 2083, W3C Recommendation 1 October 1996:
|
||||
Thomas Boutell et al.
|
||||
|
||||
.\" end of man page
|
||||
|
77
png.h
77
png.h
@ -1,6 +1,6 @@
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng version 1.6.46
|
||||
* libpng version 1.6.51.git
|
||||
*
|
||||
* 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.46, January 2025:
|
||||
* libpng versions 1.6.36, December 2018, through 1.6.50, July 2025:
|
||||
* Cosmin Truta
|
||||
* See also "Contributing Authors", below.
|
||||
*/
|
||||
@ -238,7 +238,7 @@
|
||||
* ...
|
||||
* 1.5.30 15 10530 15.so.15.30[.0]
|
||||
* ...
|
||||
* 1.6.46 16 10646 16.so.16.46[.0]
|
||||
* 1.6.50 16 10650 16.so.16.50[.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.46"
|
||||
#define PNG_LIBPNG_VER_STRING "1.6.51.git"
|
||||
#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,12 +285,12 @@
|
||||
/* 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 46
|
||||
#define PNG_LIBPNG_VER_RELEASE 51
|
||||
|
||||
/* This should be zero for a public release, or non-zero for a
|
||||
* development version.
|
||||
*/
|
||||
#define PNG_LIBPNG_VER_BUILD 0
|
||||
#define PNG_LIBPNG_VER_BUILD 1
|
||||
|
||||
/* Release Status */
|
||||
#define PNG_LIBPNG_BUILD_ALPHA 1
|
||||
@ -307,7 +307,7 @@
|
||||
#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
|
||||
PNG_LIBPNG_BUILD_PRIVATE */
|
||||
|
||||
#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE
|
||||
#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA
|
||||
|
||||
/* Careful here. At one time, Guy wanted to use 082, but that
|
||||
* would be octal. We must not include leading zeros.
|
||||
@ -316,7 +316,7 @@
|
||||
* From version 1.0.1 it is:
|
||||
* XXYYZZ, where XX=major, YY=minor, ZZ=release
|
||||
*/
|
||||
#define PNG_LIBPNG_VER 10646 /* 1.6.46 */
|
||||
#define PNG_LIBPNG_VER 10651 /* 1.6.51.git */
|
||||
|
||||
/* Library configuration: these options cannot be changed after
|
||||
* the library has been built.
|
||||
@ -426,7 +426,7 @@ extern "C" {
|
||||
/* This triggers a compiler error in png.c, if png.c and png.h
|
||||
* do not agree upon the version number.
|
||||
*/
|
||||
typedef char* png_libpng_version_1_6_46;
|
||||
typedef char* png_libpng_version_1_6_51_git;
|
||||
|
||||
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
|
||||
*
|
||||
@ -1570,7 +1570,7 @@ PNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr,
|
||||
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
/* Initialize the input/output for the PNG file to the default functions. */
|
||||
PNG_EXPORT(74, void, png_init_io, (png_structrp png_ptr, png_FILE_p fp));
|
||||
PNG_EXPORT(74, void, png_init_io, (png_structrp png_ptr, FILE *fp));
|
||||
#endif
|
||||
|
||||
/* Replace the (error and abort), and warning functions with user
|
||||
@ -3088,7 +3088,7 @@ PNG_EXPORT(234, int, png_image_begin_read_from_file, (png_imagep image,
|
||||
*/
|
||||
|
||||
PNG_EXPORT(235, int, png_image_begin_read_from_stdio, (png_imagep image,
|
||||
FILE* file));
|
||||
FILE *file));
|
||||
/* The PNG header is read from the stdio FILE object. */
|
||||
#endif /* STDIO */
|
||||
|
||||
@ -3163,7 +3163,7 @@ PNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image,
|
||||
PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
|
||||
int convert_to_8_bit, const void *buffer, png_int_32 row_stride,
|
||||
const void *colormap));
|
||||
/* Write the image to the given (FILE*). */
|
||||
/* Write the image to the given FILE object. */
|
||||
#endif /* SIMPLIFIED_WRITE_STDIO */
|
||||
|
||||
/* With all write APIs if image is in one of the linear formats with 16-bit
|
||||
@ -3303,26 +3303,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 */
|
||||
|
47
pngconf.h
47
pngconf.h
@ -1,6 +1,6 @@
|
||||
/* pngconf.h - machine-configurable file for libpng
|
||||
*
|
||||
* libpng version 1.6.46
|
||||
* libpng version 1.6.51.git
|
||||
*
|
||||
* Copyright (c) 2018-2025 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson
|
||||
@ -219,25 +219,13 @@
|
||||
/* NOTE: PNGCBAPI always defaults to PNGCAPI. */
|
||||
|
||||
# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)
|
||||
# error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed"
|
||||
# error PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed
|
||||
# endif
|
||||
|
||||
# if (defined(_MSC_VER) && _MSC_VER < 800) ||\
|
||||
(defined(__BORLANDC__) && __BORLANDC__ < 0x500)
|
||||
/* older Borland and MSC
|
||||
* compilers used '__export' and required this to be after
|
||||
* the type.
|
||||
*/
|
||||
# ifndef PNG_EXPORT_TYPE
|
||||
# define PNG_EXPORT_TYPE(type) type PNG_IMPEXP
|
||||
# endif
|
||||
# define PNG_DLL_EXPORT __export
|
||||
# else /* newer compiler */
|
||||
# define PNG_DLL_EXPORT __declspec(dllexport)
|
||||
# ifndef PNG_DLL_IMPORT
|
||||
# define PNG_DLL_IMPORT __declspec(dllimport)
|
||||
# endif
|
||||
# endif /* compiler */
|
||||
# define PNG_DLL_EXPORT __declspec(dllexport)
|
||||
# ifndef PNG_DLL_IMPORT
|
||||
# define PNG_DLL_IMPORT __declspec(dllimport)
|
||||
# endif
|
||||
|
||||
#else /* !Windows */
|
||||
# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
|
||||
@ -479,7 +467,7 @@
|
||||
#if CHAR_BIT == 8 && UCHAR_MAX == 255
|
||||
typedef unsigned char png_byte;
|
||||
#else
|
||||
# error "libpng requires 8-bit bytes"
|
||||
# error libpng requires 8-bit bytes
|
||||
#endif
|
||||
|
||||
#if INT_MIN == -32768 && INT_MAX == 32767
|
||||
@ -487,7 +475,7 @@
|
||||
#elif SHRT_MIN == -32768 && SHRT_MAX == 32767
|
||||
typedef short png_int_16;
|
||||
#else
|
||||
# error "libpng requires a signed 16-bit type"
|
||||
# error libpng requires a signed 16-bit integer type
|
||||
#endif
|
||||
|
||||
#if UINT_MAX == 65535
|
||||
@ -495,7 +483,7 @@
|
||||
#elif USHRT_MAX == 65535
|
||||
typedef unsigned short png_uint_16;
|
||||
#else
|
||||
# error "libpng requires an unsigned 16-bit type"
|
||||
# error libpng requires an unsigned 16-bit integer type
|
||||
#endif
|
||||
|
||||
#if INT_MIN < -2147483646 && INT_MAX > 2147483646
|
||||
@ -503,7 +491,7 @@
|
||||
#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646
|
||||
typedef long int png_int_32;
|
||||
#else
|
||||
# error "libpng requires a signed 32-bit (or more) type"
|
||||
# error libpng requires a signed 32-bit (or longer) integer type
|
||||
#endif
|
||||
|
||||
#if UINT_MAX > 4294967294U
|
||||
@ -511,7 +499,7 @@
|
||||
#elif ULONG_MAX > 4294967294U
|
||||
typedef unsigned long int png_uint_32;
|
||||
#else
|
||||
# error "libpng requires an unsigned 32-bit (or more) type"
|
||||
# error libpng requires an unsigned 32-bit (or longer) integer type
|
||||
#endif
|
||||
|
||||
/* Prior to 1.6.0, it was possible to disable the use of size_t and ptrdiff_t.
|
||||
@ -592,10 +580,6 @@ typedef const png_fixed_point * png_const_fixed_point_p;
|
||||
typedef size_t * png_size_tp;
|
||||
typedef const size_t * png_const_size_tp;
|
||||
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
typedef FILE * png_FILE_p;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
typedef double * png_doublep;
|
||||
typedef const double * png_const_doublep;
|
||||
@ -617,6 +601,15 @@ typedef double * * png_doublepp;
|
||||
/* Pointers to pointers to pointers; i.e., pointer to array */
|
||||
typedef char * * * png_charppp;
|
||||
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
/* With PNG_STDIO_SUPPORTED it was possible to use I/O streams that were
|
||||
* not necessarily stdio FILE streams, to allow building Windows applications
|
||||
* before Win32 and Windows CE applications before WinCE 3.0, but that kind
|
||||
* of support has long been discontinued.
|
||||
*/
|
||||
typedef FILE * png_FILE_p; /* [Deprecated] */
|
||||
#endif
|
||||
|
||||
#endif /* PNG_BUILDING_SYMBOL_TABLE */
|
||||
|
||||
#endif /* PNGCONF_H */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c
|
||||
/* pngdebug.h - internal debugging macros for libpng
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2018-2025 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -10,6 +10,10 @@
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
#ifndef PNGPRIV_H
|
||||
# error This file must not be included by applications; please include <png.h>
|
||||
#endif
|
||||
|
||||
/* Define PNG_DEBUG at compile time for debugging information. Higher
|
||||
* numbers for PNG_DEBUG mean more debugging information. This has
|
||||
* only been added since version 0.95 so it is not implemented throughout
|
||||
|
28
pngerror.c
28
pngerror.c
@ -1,6 +1,6 @@
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* Copyright (c) 2018-2024 Cosmin Truta
|
||||
* Copyright (c) 2018-2025 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -935,23 +935,37 @@ png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message)
|
||||
int /* PRIVATE */
|
||||
png_safe_execute(png_imagep image, int (*function)(png_voidp), png_voidp arg)
|
||||
{
|
||||
png_voidp saved_error_buf = image->opaque->error_buf;
|
||||
const png_voidp saved_error_buf = image->opaque->error_buf;
|
||||
jmp_buf safe_jmpbuf;
|
||||
int result;
|
||||
|
||||
/* Safely execute function(arg), with png_error returning back here. */
|
||||
if (setjmp(safe_jmpbuf) == 0)
|
||||
{
|
||||
int result;
|
||||
|
||||
image->opaque->error_buf = safe_jmpbuf;
|
||||
result = function(arg);
|
||||
image->opaque->error_buf = saved_error_buf;
|
||||
return result;
|
||||
|
||||
if (result)
|
||||
return 1; /* success */
|
||||
}
|
||||
|
||||
/* On png_error, return via longjmp, pop the jmpbuf, and free the image. */
|
||||
/* The function failed either because of a caught png_error and a regular
|
||||
* return of false above or because of an uncaught png_error from the
|
||||
* function itself. Ensure that the error_buf is always set back to the
|
||||
* value saved above:
|
||||
*/
|
||||
image->opaque->error_buf = saved_error_buf;
|
||||
png_image_free(image);
|
||||
return 0;
|
||||
|
||||
/* On the final false return, when about to return control to the caller, the
|
||||
* image is freed (png_image_free does this check but it is duplicated here
|
||||
* for clarity:
|
||||
*/
|
||||
if (saved_error_buf == NULL)
|
||||
png_image_free(image);
|
||||
|
||||
return 0; /* failure */
|
||||
}
|
||||
#endif /* SIMPLIFIED READ || SIMPLIFIED_WRITE */
|
||||
#endif /* READ || WRITE */
|
||||
|
180
pngget.c
180
pngget.c
@ -1,6 +1,6 @@
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* Copyright (c) 2018-2024 Cosmin Truta
|
||||
* Copyright (c) 2018-2025 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -380,7 +380,13 @@ png_fixed_inches_from_microns(png_const_structrp png_ptr, png_int_32 microns)
|
||||
* Notice that this can overflow - a warning is output and 0 is
|
||||
* returned.
|
||||
*/
|
||||
return png_muldiv_warn(png_ptr, microns, 500, 127);
|
||||
png_fixed_point result;
|
||||
|
||||
if (png_muldiv(&result, microns, 500, 127) != 0)
|
||||
return result;
|
||||
|
||||
png_warning(png_ptr, "fixed point overflow ignored");
|
||||
return 0;
|
||||
}
|
||||
|
||||
png_fixed_point PNGAPI
|
||||
@ -390,7 +396,7 @@ png_get_x_offset_inches_fixed(png_const_structrp png_ptr,
|
||||
return png_fixed_inches_from_microns(png_ptr,
|
||||
png_get_x_offset_microns(png_ptr, info_ptr));
|
||||
}
|
||||
#endif
|
||||
#endif /* FIXED_POINT */
|
||||
|
||||
#ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_fixed_point PNGAPI
|
||||
@ -518,44 +524,31 @@ png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
double *white_x, double *white_y, double *red_x, double *red_y,
|
||||
double *green_x, double *green_y, double *blue_x, double *blue_y)
|
||||
double *whitex, double *whitey, double *redx, double *redy,
|
||||
double *greenx, double *greeny, double *bluex, double *bluey)
|
||||
{
|
||||
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
|
||||
* the png_set_ APIs merely check that set end points are mutually
|
||||
* consistent.
|
||||
*/
|
||||
/* PNGv3: this just returns the values store from the cHRM, if any. */
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
|
||||
(info_ptr->valid & PNG_INFO_cHRM) != 0)
|
||||
{
|
||||
if (white_x != NULL)
|
||||
*white_x = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_xy.whitex, "cHRM white X");
|
||||
if (white_y != NULL)
|
||||
*white_y = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y");
|
||||
if (red_x != NULL)
|
||||
*red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx,
|
||||
"cHRM red X");
|
||||
if (red_y != NULL)
|
||||
*red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy,
|
||||
"cHRM red Y");
|
||||
if (green_x != NULL)
|
||||
*green_x = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_xy.greenx, "cHRM green X");
|
||||
if (green_y != NULL)
|
||||
*green_y = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y");
|
||||
if (blue_x != NULL)
|
||||
*blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex,
|
||||
"cHRM blue X");
|
||||
if (blue_y != NULL)
|
||||
*blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey,
|
||||
"cHRM blue Y");
|
||||
if (whitex != NULL)
|
||||
*whitex = png_float(png_ptr, info_ptr->cHRM.whitex, "cHRM wx");
|
||||
if (whitey != NULL)
|
||||
*whitey = png_float(png_ptr, info_ptr->cHRM.whitey, "cHRM wy");
|
||||
if (redx != NULL)
|
||||
*redx = png_float(png_ptr, info_ptr->cHRM.redx, "cHRM rx");
|
||||
if (redy != NULL)
|
||||
*redy = png_float(png_ptr, info_ptr->cHRM.redy, "cHRM ry");
|
||||
if (greenx != NULL)
|
||||
*greenx = png_float(png_ptr, info_ptr->cHRM.greenx, "cHRM gx");
|
||||
if (greeny != NULL)
|
||||
*greeny = png_float(png_ptr, info_ptr->cHRM.greeny, "cHRM gy");
|
||||
if (bluex != NULL)
|
||||
*bluex = png_float(png_ptr, info_ptr->cHRM.bluex, "cHRM bx");
|
||||
if (bluey != NULL)
|
||||
*bluey = png_float(png_ptr, info_ptr->cHRM.bluey, "cHRM by");
|
||||
return PNG_INFO_cHRM;
|
||||
}
|
||||
|
||||
@ -568,38 +561,31 @@ png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
|
||||
double *blue_Z)
|
||||
{
|
||||
png_XYZ XYZ;
|
||||
png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
|
||||
(info_ptr->valid & PNG_INFO_cHRM) != 0 &&
|
||||
png_XYZ_from_xy(&XYZ, &info_ptr->cHRM) == 0)
|
||||
{
|
||||
if (red_X != NULL)
|
||||
*red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X,
|
||||
"cHRM red X");
|
||||
*red_X = png_float(png_ptr, XYZ.red_X, "cHRM red X");
|
||||
if (red_Y != NULL)
|
||||
*red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y,
|
||||
"cHRM red Y");
|
||||
*red_Y = png_float(png_ptr, XYZ.red_Y, "cHRM red Y");
|
||||
if (red_Z != NULL)
|
||||
*red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Z,
|
||||
"cHRM red Z");
|
||||
*red_Z = png_float(png_ptr, XYZ.red_Z, "cHRM red Z");
|
||||
if (green_X != NULL)
|
||||
*green_X = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X");
|
||||
*green_X = png_float(png_ptr, XYZ.green_X, "cHRM green X");
|
||||
if (green_Y != NULL)
|
||||
*green_Y = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y");
|
||||
*green_Y = png_float(png_ptr, XYZ.green_Y, "cHRM green Y");
|
||||
if (green_Z != NULL)
|
||||
*green_Z = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z");
|
||||
*green_Z = png_float(png_ptr, XYZ.green_Z, "cHRM green Z");
|
||||
if (blue_X != NULL)
|
||||
*blue_X = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X");
|
||||
*blue_X = png_float(png_ptr, XYZ.blue_X, "cHRM blue X");
|
||||
if (blue_Y != NULL)
|
||||
*blue_Y = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y");
|
||||
*blue_Y = png_float(png_ptr, XYZ.blue_Y, "cHRM blue Y");
|
||||
if (blue_Z != NULL)
|
||||
*blue_Z = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z");
|
||||
*blue_Z = png_float(png_ptr, XYZ.blue_Z, "cHRM blue Z");
|
||||
return PNG_INFO_cHRM;
|
||||
}
|
||||
|
||||
@ -616,29 +602,22 @@ png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
|
||||
png_fixed_point *int_blue_Z)
|
||||
{
|
||||
png_XYZ XYZ;
|
||||
png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
|
||||
(info_ptr->valid & PNG_INFO_cHRM) != 0U &&
|
||||
png_XYZ_from_xy(&XYZ, &info_ptr->cHRM) == 0)
|
||||
{
|
||||
if (int_red_X != NULL)
|
||||
*int_red_X = info_ptr->colorspace.end_points_XYZ.red_X;
|
||||
if (int_red_Y != NULL)
|
||||
*int_red_Y = info_ptr->colorspace.end_points_XYZ.red_Y;
|
||||
if (int_red_Z != NULL)
|
||||
*int_red_Z = info_ptr->colorspace.end_points_XYZ.red_Z;
|
||||
if (int_green_X != NULL)
|
||||
*int_green_X = info_ptr->colorspace.end_points_XYZ.green_X;
|
||||
if (int_green_Y != NULL)
|
||||
*int_green_Y = info_ptr->colorspace.end_points_XYZ.green_Y;
|
||||
if (int_green_Z != NULL)
|
||||
*int_green_Z = info_ptr->colorspace.end_points_XYZ.green_Z;
|
||||
if (int_blue_X != NULL)
|
||||
*int_blue_X = info_ptr->colorspace.end_points_XYZ.blue_X;
|
||||
if (int_blue_Y != NULL)
|
||||
*int_blue_Y = info_ptr->colorspace.end_points_XYZ.blue_Y;
|
||||
if (int_blue_Z != NULL)
|
||||
*int_blue_Z = info_ptr->colorspace.end_points_XYZ.blue_Z;
|
||||
if (int_red_X != NULL) *int_red_X = XYZ.red_X;
|
||||
if (int_red_Y != NULL) *int_red_Y = XYZ.red_Y;
|
||||
if (int_red_Z != NULL) *int_red_Z = XYZ.red_Z;
|
||||
if (int_green_X != NULL) *int_green_X = XYZ.green_X;
|
||||
if (int_green_Y != NULL) *int_green_Y = XYZ.green_Y;
|
||||
if (int_green_Z != NULL) *int_green_Z = XYZ.green_Z;
|
||||
if (int_blue_X != NULL) *int_blue_X = XYZ.blue_X;
|
||||
if (int_blue_Y != NULL) *int_blue_Y = XYZ.blue_Y;
|
||||
if (int_blue_Z != NULL) *int_blue_Z = XYZ.blue_Z;
|
||||
return PNG_INFO_cHRM;
|
||||
}
|
||||
|
||||
@ -647,31 +626,24 @@ png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
|
||||
png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
|
||||
png_fixed_point *blue_x, png_fixed_point *blue_y)
|
||||
png_fixed_point *whitex, png_fixed_point *whitey, png_fixed_point *redx,
|
||||
png_fixed_point *redy, png_fixed_point *greenx, png_fixed_point *greeny,
|
||||
png_fixed_point *bluex, png_fixed_point *bluey)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "cHRM");
|
||||
|
||||
/* PNGv3: this just returns the values store from the cHRM, if any. */
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
|
||||
(info_ptr->valid & PNG_INFO_cHRM) != 0)
|
||||
{
|
||||
if (white_x != NULL)
|
||||
*white_x = info_ptr->colorspace.end_points_xy.whitex;
|
||||
if (white_y != NULL)
|
||||
*white_y = info_ptr->colorspace.end_points_xy.whitey;
|
||||
if (red_x != NULL)
|
||||
*red_x = info_ptr->colorspace.end_points_xy.redx;
|
||||
if (red_y != NULL)
|
||||
*red_y = info_ptr->colorspace.end_points_xy.redy;
|
||||
if (green_x != NULL)
|
||||
*green_x = info_ptr->colorspace.end_points_xy.greenx;
|
||||
if (green_y != NULL)
|
||||
*green_y = info_ptr->colorspace.end_points_xy.greeny;
|
||||
if (blue_x != NULL)
|
||||
*blue_x = info_ptr->colorspace.end_points_xy.bluex;
|
||||
if (blue_y != NULL)
|
||||
*blue_y = info_ptr->colorspace.end_points_xy.bluey;
|
||||
if (whitex != NULL) *whitex = info_ptr->cHRM.whitex;
|
||||
if (whitey != NULL) *whitey = info_ptr->cHRM.whitey;
|
||||
if (redx != NULL) *redx = info_ptr->cHRM.redx;
|
||||
if (redy != NULL) *redy = info_ptr->cHRM.redy;
|
||||
if (greenx != NULL) *greenx = info_ptr->cHRM.greenx;
|
||||
if (greeny != NULL) *greeny = info_ptr->cHRM.greeny;
|
||||
if (bluex != NULL) *bluex = info_ptr->cHRM.bluex;
|
||||
if (bluey != NULL) *bluey = info_ptr->cHRM.bluey;
|
||||
return PNG_INFO_cHRM;
|
||||
}
|
||||
|
||||
@ -688,11 +660,11 @@ png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "gAMA");
|
||||
|
||||
/* PNGv3 compatibility: only report gAMA if it is really present. */
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
|
||||
file_gamma != NULL)
|
||||
(info_ptr->valid & PNG_INFO_gAMA) != 0)
|
||||
{
|
||||
*file_gamma = info_ptr->colorspace.gamma;
|
||||
if (file_gamma != NULL) *file_gamma = info_ptr->gamma;
|
||||
return PNG_INFO_gAMA;
|
||||
}
|
||||
|
||||
@ -707,12 +679,13 @@ png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "gAMA(float)");
|
||||
|
||||
/* PNGv3 compatibility: only report gAMA if it is really present. */
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
|
||||
file_gamma != NULL)
|
||||
(info_ptr->valid & PNG_INFO_gAMA) != 0)
|
||||
{
|
||||
*file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma,
|
||||
"png_get_gAMA");
|
||||
if (file_gamma != NULL)
|
||||
*file_gamma = png_float(png_ptr, info_ptr->gamma, "gAMA");
|
||||
|
||||
return PNG_INFO_gAMA;
|
||||
}
|
||||
|
||||
@ -729,9 +702,10 @@ png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_debug1(1, "in %s retrieval function", "sRGB");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_sRGB) != 0 && file_srgb_intent != NULL)
|
||||
(info_ptr->valid & PNG_INFO_sRGB) != 0)
|
||||
{
|
||||
*file_srgb_intent = info_ptr->colorspace.rendering_intent;
|
||||
if (file_srgb_intent != NULL)
|
||||
*file_srgb_intent = info_ptr->rendering_intent;
|
||||
return PNG_INFO_sRGB;
|
||||
}
|
||||
|
||||
|
81
pnginfo.h
81
pnginfo.h
@ -1,6 +1,6 @@
|
||||
/* pnginfo.h - header file for PNG reference library
|
||||
/* pnginfo.h - internal structures for libpng
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2018-2025 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2013,2018 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -10,43 +10,20 @@
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
/* png_info is a structure that holds the information in a PNG file so
|
||||
* that the application can find out the characteristics of the image.
|
||||
* If you are reading the file, this structure will tell you what is
|
||||
* in the PNG file. If you are writing the file, fill in the information
|
||||
* you want to put into the PNG file, using png_set_*() functions, then
|
||||
* call png_write_info().
|
||||
#ifndef PNGPRIV_H
|
||||
# error This file must not be included by applications; please include <png.h>
|
||||
#endif
|
||||
|
||||
/* INTERNAL, PRIVATE definition of a PNG.
|
||||
*
|
||||
* The names chosen should be very close to the PNG specification, so
|
||||
* consult that document for information about the meaning of each field.
|
||||
* png_info is a modifiable description of a PNG datastream. The fields inside
|
||||
* this structure are accessed through png_get_<CHUNK>() functions and modified
|
||||
* using png_set_<CHUNK>() functions.
|
||||
*
|
||||
* With libpng < 0.95, it was only possible to directly set and read the
|
||||
* the values in the png_info_struct, which meant that the contents and
|
||||
* order of the values had to remain fixed. With libpng 0.95 and later,
|
||||
* however, there are now functions that abstract the contents of
|
||||
* png_info_struct from the application, so this makes it easier to use
|
||||
* libpng with dynamic libraries, and even makes it possible to use
|
||||
* libraries that don't have all of the libpng ancillary chunk-handing
|
||||
* functionality. In libpng-1.5.0 this was moved into a separate private
|
||||
* file that is not visible to applications.
|
||||
*
|
||||
* The following members may have allocated storage attached that should be
|
||||
* cleaned up before the structure is discarded: palette, trans, text,
|
||||
* pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,
|
||||
* splt_palettes, scal_unit, row_pointers, and unknowns. By default, these
|
||||
* are automatically freed when the info structure is deallocated, if they were
|
||||
* allocated internally by libpng. This behavior can be changed by means
|
||||
* of the png_data_freer() function.
|
||||
*
|
||||
* More allocation details: all the chunk-reading functions that
|
||||
* change these members go through the corresponding png_set_*
|
||||
* functions. A function to clear these members is available: see
|
||||
* png_free_data(). The png_set_* functions do not depend on being
|
||||
* able to point info structure members to any of the storage they are
|
||||
* passed (they make their own copies), EXCEPT that the png_set_text
|
||||
* functions use the same storage passed to them in the text_ptr or
|
||||
* itxt_ptr structure argument, and the png_set_rows and png_set_unknowns
|
||||
* functions do not make their own copies.
|
||||
* Some functions in libpng do directly access members of png_info. However,
|
||||
* this should be avoided. png_struct objects contain members which hold
|
||||
* caches, sometimes optimised, of the values from png_info objects, and
|
||||
* png_info is not passed to the functions which read and write image data.
|
||||
*/
|
||||
#ifndef PNGINFO_H
|
||||
#define PNGINFO_H
|
||||
@ -86,20 +63,6 @@ struct png_info_def
|
||||
* and initialize the appropriate fields below.
|
||||
*/
|
||||
|
||||
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||
/* png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are
|
||||
* defined. When COLORSPACE is switched on all the colorspace-defining
|
||||
* chunks should be enabled, when GAMMA is switched on all the gamma-defining
|
||||
* chunks should be enabled. If this is not done it becomes possible to read
|
||||
* inconsistent PNG files and assign a probably incorrect interpretation to
|
||||
* the information. (In other words, by carefully choosing which chunks to
|
||||
* recognize the system configuration can select an interpretation for PNG
|
||||
* files containing ambiguous data and this will result in inconsistent
|
||||
* behavior between different libpng builds!)
|
||||
*/
|
||||
png_colorspace colorspace;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_cICP_SUPPORTED
|
||||
/* cICP chunk data */
|
||||
png_byte cicp_colour_primaries;
|
||||
@ -211,11 +174,8 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
#endif
|
||||
|
||||
#ifdef PNG_eXIf_SUPPORTED
|
||||
int num_exif; /* Added at libpng-1.6.31 */
|
||||
png_uint_32 num_exif; /* Added at libpng-1.6.31 */
|
||||
png_bytep exif;
|
||||
# ifdef PNG_READ_eXIf_SUPPORTED
|
||||
png_bytep eXIf_buf; /* Added at libpng-1.6.32 */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_hIST_SUPPORTED
|
||||
@ -288,5 +248,16 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
png_bytepp row_pointers; /* the image bits */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_cHRM_SUPPORTED
|
||||
png_xy cHRM;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_gAMA_SUPPORTED
|
||||
png_fixed_point gamma;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sRGB_SUPPORTED
|
||||
int rendering_intent;
|
||||
#endif
|
||||
};
|
||||
#endif /* PNGINFO_H */
|
||||
|
39
pngmem.c
39
pngmem.c
@ -1,6 +1,6 @@
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2018-2025 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -72,30 +72,29 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||
* to implement a user memory handler. This checks to be sure it isn't
|
||||
* called with big numbers.
|
||||
*/
|
||||
#ifndef PNG_USER_MEM_SUPPORTED
|
||||
PNG_UNUSED(png_ptr)
|
||||
#endif
|
||||
# ifdef PNG_MAX_MALLOC_64K
|
||||
/* This is support for legacy systems which had segmented addressing
|
||||
* limiting the maximum allocation size to 65536. It takes precedence
|
||||
* over PNG_SIZE_MAX which is set to 65535 on true 16-bit systems.
|
||||
*
|
||||
* TODO: libpng-1.8: finally remove both cases.
|
||||
*/
|
||||
if (size > 65536U) return NULL;
|
||||
# endif
|
||||
|
||||
/* Some compilers complain that this is always true. However, it
|
||||
* can be false when integer overflow happens.
|
||||
/* This is checked too because the system malloc call below takes a (size_t).
|
||||
*/
|
||||
if (size > 0 && size <= PNG_SIZE_MAX
|
||||
# ifdef PNG_MAX_MALLOC_64K
|
||||
&& size <= 65536U
|
||||
# endif
|
||||
)
|
||||
{
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (size > PNG_SIZE_MAX) return NULL;
|
||||
|
||||
# ifdef PNG_USER_MEM_SUPPORTED
|
||||
if (png_ptr != NULL && png_ptr->malloc_fn != NULL)
|
||||
return png_ptr->malloc_fn(png_constcast(png_structrp,png_ptr), size);
|
||||
# else
|
||||
PNG_UNUSED(png_ptr)
|
||||
# endif
|
||||
|
||||
else
|
||||
#endif
|
||||
return malloc((size_t)size); /* checked for truncation above */
|
||||
}
|
||||
|
||||
else
|
||||
return NULL;
|
||||
/* Use the system malloc */
|
||||
return malloc((size_t)/*SAFE*/size); /* checked for truncation above */
|
||||
}
|
||||
|
||||
#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\
|
||||
|
202
pngpread.c
202
pngpread.c
@ -1,6 +1,6 @@
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* Copyright (c) 2018-2024 Cosmin Truta
|
||||
* Copyright (c) 2018-2025 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -193,17 +193,8 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
*/
|
||||
if ((png_ptr->mode & PNG_HAVE_CHUNK_HEADER) == 0)
|
||||
{
|
||||
png_byte chunk_length[4];
|
||||
png_byte chunk_tag[4];
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_LT(8)
|
||||
png_push_fill_buffer(png_ptr, chunk_length, 4);
|
||||
png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
|
||||
png_reset_crc(png_ptr);
|
||||
png_crc_read(png_ptr, chunk_tag, 4);
|
||||
png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);
|
||||
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
|
||||
png_check_chunk_length(png_ptr, png_ptr->push_length);
|
||||
png_ptr->push_length = png_read_chunk_header(png_ptr);
|
||||
png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
|
||||
}
|
||||
|
||||
@ -238,19 +229,27 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
png_benign_error(png_ptr, "Too many IDATs found");
|
||||
}
|
||||
|
||||
else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
|
||||
{
|
||||
/* These flags must be set consistently for all non-IDAT chunks,
|
||||
* including the unknown chunks.
|
||||
*/
|
||||
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT | PNG_AFTER_IDAT;
|
||||
}
|
||||
|
||||
if (chunk_name == png_IHDR)
|
||||
{
|
||||
if (png_ptr->push_length != 13)
|
||||
png_error(png_ptr, "Invalid IHDR length");
|
||||
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length);
|
||||
png_handle_chunk(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
else if (chunk_name == png_IEND)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length);
|
||||
png_handle_chunk(png_ptr, info_ptr, png_ptr->push_length);
|
||||
|
||||
png_ptr->process_mode = PNG_READ_DONE_MODE;
|
||||
png_push_have_end(png_ptr, info_ptr);
|
||||
@ -267,12 +266,6 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
}
|
||||
#endif
|
||||
|
||||
else if (chunk_name == png_PLTE)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
else if (chunk_name == png_IDAT)
|
||||
{
|
||||
png_ptr->idat_size = png_ptr->push_length;
|
||||
@ -285,179 +278,10 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_gAMA_SUPPORTED
|
||||
else if (png_ptr->chunk_name == png_gAMA)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_sBIT_SUPPORTED
|
||||
else if (png_ptr->chunk_name == png_sBIT)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_cHRM_SUPPORTED
|
||||
else if (png_ptr->chunk_name == png_cHRM)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_cICP_SUPPORTED
|
||||
else if (png_ptr->chunk_name == png_cICP)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_cICP(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_cLLI_SUPPORTED
|
||||
else if (png_ptr->chunk_name == png_cLLI)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_cLLI(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_mDCV_SUPPORTED
|
||||
else if (png_ptr->chunk_name == png_mDCV)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_mDCV(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_eXIf_SUPPORTED
|
||||
else if (png_ptr->chunk_name == png_eXIf)
|
||||
{
|
||||
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)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_iCCP_SUPPORTED
|
||||
else if (png_ptr->chunk_name == png_iCCP)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_sPLT_SUPPORTED
|
||||
else if (chunk_name == png_sPLT)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_tRNS_SUPPORTED
|
||||
else if (chunk_name == png_tRNS)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_bKGD_SUPPORTED
|
||||
else if (chunk_name == png_bKGD)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_hIST_SUPPORTED
|
||||
else if (chunk_name == png_hIST)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_pHYs_SUPPORTED
|
||||
else if (chunk_name == png_pHYs)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_oFFs_SUPPORTED
|
||||
else if (chunk_name == png_oFFs)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_pCAL_SUPPORTED
|
||||
else if (chunk_name == png_pCAL)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_sCAL_SUPPORTED
|
||||
else if (chunk_name == png_sCAL)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_tIME_SUPPORTED
|
||||
else if (chunk_name == png_tIME)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_tEXt_SUPPORTED
|
||||
else if (chunk_name == png_tEXt)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_zTXt_SUPPORTED
|
||||
else if (chunk_name == png_zTXt)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_iTXt_SUPPORTED
|
||||
else if (chunk_name == png_iTXt)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
#endif
|
||||
|
||||
else
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length,
|
||||
PNG_HANDLE_CHUNK_AS_DEFAULT);
|
||||
png_handle_chunk(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
|
||||
|
492
pngpriv.h
492
pngpriv.h
@ -1,6 +1,6 @@
|
||||
/* pngpriv.h - private declarations for use inside libpng
|
||||
*
|
||||
* Copyright (c) 2018-2024 Cosmin Truta
|
||||
* Copyright (c) 2018-2025 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -19,8 +19,20 @@
|
||||
* they should be well aware of the issues that may arise from doing so.
|
||||
*/
|
||||
|
||||
|
||||
/* pngpriv.h must be included first in each translation unit inside libpng.
|
||||
* On the other hand, it must not be included at all, directly or indirectly,
|
||||
* by any application code that uses the libpng API.
|
||||
*/
|
||||
#ifndef PNGPRIV_H
|
||||
#define PNGPRIV_H
|
||||
# define PNGPRIV_H
|
||||
#else
|
||||
# error Duplicate inclusion of pngpriv.h; please check the libpng source files
|
||||
#endif
|
||||
|
||||
#if defined(PNG_H) || defined(PNGCONF_H) || defined(PNGLCONF_H)
|
||||
# error This file must not be included by applications; please include <png.h>
|
||||
#endif
|
||||
|
||||
/* Feature Test Macros. The following are defined here to ensure that correctly
|
||||
* implemented libraries reveal the APIs libpng needs to build and hide those
|
||||
@ -57,7 +69,6 @@
|
||||
*/
|
||||
#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
|
||||
# include <config.h>
|
||||
|
||||
/* Pick up the definition of 'restrict' from config.h if it was read: */
|
||||
# define PNG_RESTRICT restrict
|
||||
#endif
|
||||
@ -67,9 +78,7 @@
|
||||
* are not internal definitions may be required. This is handled below just
|
||||
* before png.h is included, but load the configuration now if it is available.
|
||||
*/
|
||||
#ifndef PNGLCONF_H
|
||||
# include "pnglibconf.h"
|
||||
#endif
|
||||
#include "pnglibconf.h"
|
||||
|
||||
/* Local renames may change non-exported API functions from png.h */
|
||||
#if defined(PNG_PREFIX) && !defined(PNGPREFIX_H)
|
||||
@ -134,6 +143,20 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef PNG_RISCV_RVV_OPT
|
||||
/* RISCV_RVV optimizations are being controlled by the compiler settings,
|
||||
* typically the target compiler will define __riscv but the rvv extension
|
||||
* availability has to be explicitly stated. This is why if no
|
||||
* PNG_RISCV_RVV_OPT was defined then a runtime check will be executed.
|
||||
*
|
||||
* To enable RISCV_RVV optimizations unconditionally, and compile the
|
||||
* associated code, pass --enable-riscv-rvv=yes or --enable-riscv-rvv=on
|
||||
* to configure or put -DPNG_RISCV_RVV_OPT=2 in CPPFLAGS.
|
||||
*/
|
||||
|
||||
# define PNG_RISCV_RVV_OPT 0
|
||||
#endif
|
||||
|
||||
#if PNG_ARM_NEON_OPT > 0
|
||||
/* NEON optimizations are to be at least considered by libpng, so enable the
|
||||
* callbacks to do this.
|
||||
@ -279,6 +302,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.
|
||||
@ -671,7 +704,7 @@
|
||||
#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200U
|
||||
#define PNG_FLAG_CRC_CRITICAL_USE 0x0400U
|
||||
#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800U
|
||||
#define PNG_FLAG_ASSUME_sRGB 0x1000U /* Added to libpng-1.5.4 */
|
||||
/* PNG_FLAG_ASSUME_sRGB unused 0x1000U * Added to libpng-1.5.4 */
|
||||
#define PNG_FLAG_OPTIMIZE_ALPHA 0x2000U /* Added to libpng-1.5.4 */
|
||||
#define PNG_FLAG_DETECT_UNINITIALIZED 0x4000U /* Added to libpng-1.5.4 */
|
||||
/* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000U */
|
||||
@ -802,11 +835,31 @@
|
||||
*
|
||||
* PNG_32b correctly produces a value shifted by up to 24 bits, even on
|
||||
* architectures where (int) is only 16 bits.
|
||||
*
|
||||
* 1.6.47: PNG_32b was made into a preprocessor evaluable macro by replacing the
|
||||
* static_cast with a promoting binary operation using a guaranteed 32-bit
|
||||
* (minimum) unsigned value.
|
||||
*/
|
||||
#define PNG_32b(b,s) ((png_uint_32)(b) << (s))
|
||||
#define PNG_32b(b,s) (((0xFFFFFFFFU)&(b)) << (s))
|
||||
#define PNG_U32(b1,b2,b3,b4) \
|
||||
(PNG_32b(b1,24) | PNG_32b(b2,16) | PNG_32b(b3,8) | PNG_32b(b4,0))
|
||||
|
||||
/* Chunk name validation. When using these macros all the arguments should be
|
||||
* constants, otherwise code bloat may well occur. The macros are provided
|
||||
* primarily for use in #if checks.
|
||||
*
|
||||
* PNG_32to8 produces a byte value with the right shift; used to extract the
|
||||
* byte value from a chunk name.
|
||||
*/
|
||||
#define PNG_32to8(cn,s) (((cn) >> (s)) & 0xffU)
|
||||
#define PNG_CN_VALID_UPPER(b) ((b) >= 65 && (b) <= 90) /* upper-case ASCII */
|
||||
#define PNG_CN_VALID_ASCII(b) PNG_CN_VALID_UPPER((b) & ~32U)
|
||||
#define PNG_CHUNK_NAME_VALID(cn) (\
|
||||
PNG_CN_VALID_ASCII(PNG_32to8(cn,24)) && /* critical, !ancillary */\
|
||||
PNG_CN_VALID_ASCII(PNG_32to8(cn,16)) && /* public, !privately defined */\
|
||||
PNG_CN_VALID_UPPER(PNG_32to8(cn, 8)) && /* VALID, !reserved */\
|
||||
PNG_CN_VALID_ASCII(PNG_32to8(cn, 0)) /* data-dependent, !copy ok */)
|
||||
|
||||
/* Constants for known chunk types.
|
||||
*
|
||||
* MAINTAINERS: If you need to add a chunk, define the name here.
|
||||
@ -834,11 +887,14 @@
|
||||
#define png_IEND PNG_U32( 73, 69, 78, 68)
|
||||
#define png_IHDR PNG_U32( 73, 72, 68, 82)
|
||||
#define png_PLTE PNG_U32( 80, 76, 84, 69)
|
||||
#define png_acTL PNG_U32( 97, 99, 84, 76) /* PNGv3: APNG */
|
||||
#define png_bKGD PNG_U32( 98, 75, 71, 68)
|
||||
#define png_cHRM PNG_U32( 99, 72, 82, 77)
|
||||
#define png_cICP PNG_U32( 99, 73, 67, 80) /* PNGv3 */
|
||||
#define png_cLLI PNG_U32( 99, 76, 76, 73) /* PNGv3 */
|
||||
#define png_eXIf PNG_U32(101, 88, 73, 102) /* registered July 2017 */
|
||||
#define png_fcTL PNG_U32(102, 99, 84, 76) /* PNGv3: APNG */
|
||||
#define png_fdAT PNG_U32(102, 100, 65, 84) /* PNGv3: APNG */
|
||||
#define png_fRAc PNG_U32(102, 82, 65, 99) /* registered, not defined */
|
||||
#define png_gAMA PNG_U32(103, 65, 77, 65)
|
||||
#define png_gIFg PNG_U32(103, 73, 70, 103)
|
||||
@ -888,11 +944,74 @@
|
||||
#define PNG_CHUNK_RESERVED(c) (1 & ((c) >> 13))
|
||||
#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >> 5))
|
||||
|
||||
/* Known chunks. All supported chunks must be listed here. The macro PNG_CHUNK
|
||||
* contains the four character ASCII name by which the chunk is identified. The
|
||||
* macro is implemented as required to build tables or switch statements which
|
||||
* require entries for every known chunk. The macro also contains an index
|
||||
* value which should be in order (this is checked in png.c).
|
||||
*
|
||||
* Notice that "known" does not require "SUPPORTED"; tables should be built in
|
||||
* such a way that chunks unsupported in a build require no more than the table
|
||||
* entry (which should be small.) In particular function pointers for
|
||||
* unsupported chunks should be NULL.
|
||||
*
|
||||
* At present these index values are not exported (not part of the public API)
|
||||
* so can be changed at will. For convenience the names are in lexical sort
|
||||
* order but with the critical chunks at the start in the order of occurence in
|
||||
* a PNG.
|
||||
*
|
||||
* PNG_INFO_ values do not exist for every one of these chunk handles; for
|
||||
* example PNG_INFO_{IDAT,IEND,tEXt,iTXt,zTXt} and possibly other chunks in the
|
||||
* future.
|
||||
*/
|
||||
#define PNG_KNOWN_CHUNKS\
|
||||
PNG_CHUNK(IHDR, 0)\
|
||||
PNG_CHUNK(PLTE, 1)\
|
||||
PNG_CHUNK(IDAT, 2)\
|
||||
PNG_CHUNK(IEND, 3)\
|
||||
PNG_CHUNK(acTL, 4)\
|
||||
PNG_CHUNK(bKGD, 5)\
|
||||
PNG_CHUNK(cHRM, 6)\
|
||||
PNG_CHUNK(cICP, 7)\
|
||||
PNG_CHUNK(cLLI, 8)\
|
||||
PNG_CHUNK(eXIf, 9)\
|
||||
PNG_CHUNK(fcTL, 10)\
|
||||
PNG_CHUNK(fdAT, 11)\
|
||||
PNG_CHUNK(gAMA, 12)\
|
||||
PNG_CHUNK(hIST, 13)\
|
||||
PNG_CHUNK(iCCP, 14)\
|
||||
PNG_CHUNK(iTXt, 15)\
|
||||
PNG_CHUNK(mDCV, 16)\
|
||||
PNG_CHUNK(oFFs, 17)\
|
||||
PNG_CHUNK(pCAL, 18)\
|
||||
PNG_CHUNK(pHYs, 19)\
|
||||
PNG_CHUNK(sBIT, 20)\
|
||||
PNG_CHUNK(sCAL, 21)\
|
||||
PNG_CHUNK(sPLT, 22)\
|
||||
PNG_CHUNK(sRGB, 23)\
|
||||
PNG_CHUNK(tEXt, 24)\
|
||||
PNG_CHUNK(tIME, 25)\
|
||||
PNG_CHUNK(tRNS, 26)\
|
||||
PNG_CHUNK(zTXt, 27)
|
||||
|
||||
/* Gamma values (new at libpng-1.5.4): */
|
||||
#define PNG_GAMMA_MAC_OLD 151724 /* Assume '1.8' is really 2.2/1.45! */
|
||||
#define PNG_GAMMA_MAC_INVERSE 65909
|
||||
#define PNG_GAMMA_sRGB_INVERSE 45455
|
||||
|
||||
/* gamma sanity check. libpng cannot implement gamma transforms outside a
|
||||
* certain limit because of its use of 16-bit fixed point intermediate values.
|
||||
* Gamma values that are too large or too small will zap the 16-bit values all
|
||||
* to 0 or 65535 resulting in an obvious 'bad' image.
|
||||
*
|
||||
* In libpng 1.6.0 the limits were changed from 0.07..3 to 0.01..100 to
|
||||
* accommodate the optimal 16-bit gamma of 36 and its reciprocal.
|
||||
*
|
||||
* These are png_fixed_point integral values:
|
||||
*/
|
||||
#define PNG_LIB_GAMMA_MIN 1000
|
||||
#define PNG_LIB_GAMMA_MAX 10000000
|
||||
|
||||
/* Almost everything below is C specific; the #defines above can be used in
|
||||
* non-C code (so long as it is C-preprocessed) the rest of this stuff cannot.
|
||||
*/
|
||||
@ -905,17 +1024,15 @@
|
||||
* must match that used in the build, or we must be using pnglibconf.h.prebuilt:
|
||||
*/
|
||||
#if PNG_ZLIB_VERNUM != 0 && PNG_ZLIB_VERNUM != ZLIB_VERNUM
|
||||
# error ZLIB_VERNUM != PNG_ZLIB_VERNUM \
|
||||
"-I (include path) error: see the notes in pngpriv.h"
|
||||
/* This means that when pnglibconf.h was built the copy of zlib.h that it
|
||||
* used is not the same as the one being used here. Because the build of
|
||||
* libpng makes decisions to use inflateInit2 and inflateReset2 based on the
|
||||
* zlib version number and because this affects handling of certain broken
|
||||
* PNG files the -I directives must match.
|
||||
# error The include path of <zlib.h> is incorrect
|
||||
/* When pnglibconf.h was built, the copy of zlib.h that it used was not the
|
||||
* same as the one being used here. Considering how libpng makes decisions
|
||||
* to use the zlib API based on the zlib version number, the -I options must
|
||||
* match.
|
||||
*
|
||||
* The most likely explanation is that you passed a -I in CFLAGS. This will
|
||||
* not work; all the preprocessor directives and in particular all the -I
|
||||
* directives must be in CPPFLAGS.
|
||||
* A possible cause of this mismatch is that you passed an -I option in
|
||||
* CFLAGS, which is unlikely to work. All the preprocessor options, and all
|
||||
* the -I options in particular, should be in CPPFLAGS.
|
||||
*/
|
||||
#endif
|
||||
|
||||
@ -956,7 +1073,6 @@ extern "C" {
|
||||
*
|
||||
* All of these functions must be declared with PNG_INTERNAL_FUNCTION.
|
||||
*/
|
||||
|
||||
/* Zlib support */
|
||||
#define PNG_UNEXPECTED_ZLIB_RETURN (-7)
|
||||
PNG_INTERNAL_FUNCTION(void, png_zstream_error,(png_structrp png_ptr, int ret),
|
||||
@ -996,6 +1112,25 @@ PNG_INTERNAL_FUNCTION(png_uint_32,png_fixed_ITU,(png_const_structrp png_ptr,
|
||||
PNG_INTERNAL_FUNCTION(int,png_user_version_check,(png_structrp png_ptr,
|
||||
png_const_charp user_png_ver),PNG_EMPTY);
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED /* should only be used on read */
|
||||
/* Security: read limits on the largest allocations while reading a PNG. This
|
||||
* avoids very large allocations caused by PNG files with damaged or altered
|
||||
* chunk 'length' fields.
|
||||
*/
|
||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED /* run-time limit */
|
||||
# define png_chunk_max(png_ptr) ((png_ptr)->user_chunk_malloc_max)
|
||||
|
||||
#elif PNG_USER_CHUNK_MALLOC_MAX > 0 /* compile-time limit */
|
||||
# define png_chunk_max(png_ptr) ((void)png_ptr, PNG_USER_CHUNK_MALLOC_MAX)
|
||||
|
||||
#elif (defined PNG_MAX_MALLOC_64K) /* legacy system limit */
|
||||
# define png_chunk_max(png_ptr) ((void)png_ptr, 65536U)
|
||||
|
||||
#else /* modern system limit SIZE_MAX (C99) */
|
||||
# define png_chunk_max(png_ptr) ((void)png_ptr, PNG_SIZE_MAX)
|
||||
#endif
|
||||
#endif /* READ */
|
||||
|
||||
/* Internal base allocator - no messages, NULL on failure to allocate. This
|
||||
* does, however, call the application provided allocator and that could call
|
||||
* png_error (although that would be a bug in the application implementation.)
|
||||
@ -1095,9 +1230,6 @@ PNG_INTERNAL_FUNCTION(void,png_crc_read,(png_structrp png_ptr, png_bytep buf,
|
||||
PNG_INTERNAL_FUNCTION(int,png_crc_finish,(png_structrp png_ptr,
|
||||
png_uint_32 skip),PNG_EMPTY);
|
||||
|
||||
/* Read the CRC from the file and compare it to the libpng calculated CRC */
|
||||
PNG_INTERNAL_FUNCTION(int,png_crc_error,(png_structrp png_ptr),PNG_EMPTY);
|
||||
|
||||
/* Calculate the CRC over a section of data. Note that we are only
|
||||
* passing a maximum of 64K on systems that have this as a memory limit,
|
||||
* since this is the maximum buffer size we can specify.
|
||||
@ -1175,10 +1307,10 @@ PNG_INTERNAL_FUNCTION(void,png_write_eXIf,(png_structrp png_ptr,
|
||||
|
||||
#ifdef PNG_WRITE_iCCP_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_write_iCCP,(png_structrp png_ptr,
|
||||
png_const_charp name, png_const_bytep profile), PNG_EMPTY);
|
||||
/* The profile must have been previously validated for correctness, the
|
||||
* length comes from the first four bytes. Only the base, deflate,
|
||||
* compression is supported.
|
||||
png_const_charp name, png_const_bytep profile, png_uint_32 proflen),
|
||||
PNG_EMPTY);
|
||||
/* Writes a previously 'set' profile. The profile argument is **not**
|
||||
* compressed.
|
||||
*/
|
||||
#endif
|
||||
|
||||
@ -1414,6 +1546,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);
|
||||
@ -1487,134 +1636,36 @@ PNG_INTERNAL_FUNCTION(void,png_do_bgr,(png_row_infop row_info,
|
||||
/* The following decodes the appropriate chunks, and does error correction,
|
||||
* then calls the appropriate callback for the chunk if it is valid.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
/* Result of a call to png_handle_chunk made to handle the current chunk
|
||||
* png_struct::chunk_name on read. Always informational, either the stream
|
||||
* is read for the next chunk or the routine will call png_error.
|
||||
*
|
||||
* NOTE: order is important internally. handled_saved and above are regarded
|
||||
* as handling the chunk.
|
||||
*/
|
||||
handled_error = 0, /* bad crc or known and bad format or too long */
|
||||
handled_discarded, /* not saved in the unknown chunk list */
|
||||
handled_saved, /* saved in the unknown chunk list */
|
||||
handled_ok /* known, supported and handled without error */
|
||||
} png_handle_result_code;
|
||||
|
||||
/* Decode the IHDR chunk */
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_IHDR,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_PLTE,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_IEND,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
|
||||
#ifdef PNG_READ_bKGD_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_bKGD,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_cHRM_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_cHRM,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_cICP_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_cICP,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_cLLI_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_cLLI,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_eXIf_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_eXIf,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_gAMA_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_gAMA,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_hIST_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_hIST,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_iCCP_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_iCCP,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif /* READ_iCCP */
|
||||
|
||||
#ifdef PNG_READ_iTXt_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_iTXt,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_mDCV_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_mDCV,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_oFFs_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_oFFs,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_pCAL_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_pCAL,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_pHYs_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_pHYs,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_sBIT_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_sBIT,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_sCAL_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_sCAL,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_sPLT_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_sPLT,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif /* READ_sPLT */
|
||||
|
||||
#ifdef PNG_READ_sRGB_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_sRGB,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_tEXt_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_tEXt,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_tIME_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_tIME,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_tRNS_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_tRNS,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_zTXt_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_zTXt,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
PNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_const_structrp png_ptr,
|
||||
png_uint_32 chunk_name),PNG_EMPTY);
|
||||
|
||||
PNG_INTERNAL_FUNCTION(void,png_check_chunk_length,(png_const_structrp png_ptr,
|
||||
png_uint_32 chunk_length),PNG_EMPTY);
|
||||
|
||||
PNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length, int keep),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(png_handle_result_code,png_handle_unknown,
|
||||
(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length, int keep),
|
||||
PNG_EMPTY);
|
||||
/* This is the function that gets called for unknown chunks. The 'keep'
|
||||
* argument is either non-zero for a known chunk that has been set to be
|
||||
* handled as unknown or zero for an unknown chunk. By default the function
|
||||
* just skips the chunk or errors out if it is critical.
|
||||
*/
|
||||
|
||||
PNG_INTERNAL_FUNCTION(png_handle_result_code,png_handle_chunk,
|
||||
(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
/* This handles the current chunk png_ptr->chunk_name with unread
|
||||
* data[length] and returns one of the above result codes.
|
||||
*/
|
||||
|
||||
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) ||\
|
||||
defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
|
||||
PNG_INTERNAL_FUNCTION(int,png_chunk_unknown_handling,
|
||||
@ -1654,8 +1705,6 @@ PNG_INTERNAL_FUNCTION(void,png_process_IDAT_data,(png_structrp png_ptr,
|
||||
png_bytep buffer, size_t buffer_length),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_push_process_row,(png_structrp png_ptr),
|
||||
PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_push_handle_unknown,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_push_have_info,(png_structrp png_ptr,
|
||||
png_inforp info_ptr),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_push_have_end,(png_structrp png_ptr,
|
||||
@ -1668,109 +1717,28 @@ PNG_INTERNAL_FUNCTION(void,png_process_some_data,(png_structrp png_ptr,
|
||||
png_inforp info_ptr),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_push_finish_row,(png_structrp png_ptr),
|
||||
PNG_EMPTY);
|
||||
# ifdef PNG_READ_tEXt_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_push_handle_tEXt,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_push_read_tEXt,(png_structrp png_ptr,
|
||||
png_inforp info_ptr),PNG_EMPTY);
|
||||
# endif
|
||||
# ifdef PNG_READ_zTXt_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_push_handle_zTXt,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_push_read_zTXt,(png_structrp png_ptr,
|
||||
png_inforp info_ptr),PNG_EMPTY);
|
||||
# endif
|
||||
# ifdef PNG_READ_iTXt_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_push_handle_iTXt,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_push_read_iTXt,(png_structrp png_ptr,
|
||||
png_inforp info_ptr),PNG_EMPTY);
|
||||
# endif
|
||||
|
||||
#endif /* PROGRESSIVE_READ */
|
||||
|
||||
/* Added at libpng version 1.6.0 */
|
||||
#ifdef PNG_GAMMA_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_colorspace_set_gamma,(png_const_structrp png_ptr,
|
||||
png_colorspacerp colorspace, png_fixed_point gAMA), PNG_EMPTY);
|
||||
/* Set the colorspace gamma with a value provided by the application or by
|
||||
* the gAMA chunk on read. The value will override anything set by an ICC
|
||||
* profile.
|
||||
*/
|
||||
|
||||
PNG_INTERNAL_FUNCTION(void,png_colorspace_sync_info,(png_const_structrp png_ptr,
|
||||
png_inforp info_ptr), PNG_EMPTY);
|
||||
/* Synchronize the info 'valid' flags with the colorspace */
|
||||
|
||||
PNG_INTERNAL_FUNCTION(void,png_colorspace_sync,(png_const_structrp png_ptr,
|
||||
png_inforp info_ptr), PNG_EMPTY);
|
||||
/* Copy the png_struct colorspace to the info_struct and call the above to
|
||||
* synchronize the flags. Checks for NULL info_ptr and does nothing.
|
||||
*/
|
||||
#endif
|
||||
|
||||
/* Added at libpng version 1.4.0 */
|
||||
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||
/* These internal functions are for maintaining the colorspace structure within
|
||||
* a png_info or png_struct (or, indeed, both).
|
||||
*/
|
||||
PNG_INTERNAL_FUNCTION(int,png_colorspace_set_chromaticities,
|
||||
(png_const_structrp png_ptr, png_colorspacerp colorspace, const png_xy *xy,
|
||||
int preferred), PNG_EMPTY);
|
||||
|
||||
PNG_INTERNAL_FUNCTION(int,png_colorspace_set_endpoints,
|
||||
(png_const_structrp png_ptr, png_colorspacerp colorspace, const png_XYZ *XYZ,
|
||||
int preferred), PNG_EMPTY);
|
||||
|
||||
#ifdef PNG_sRGB_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(int,png_colorspace_set_sRGB,(png_const_structrp png_ptr,
|
||||
png_colorspacerp colorspace, int intent), PNG_EMPTY);
|
||||
/* This does set the colorspace gAMA and cHRM values too, but doesn't set the
|
||||
* flags to write them, if it returns false there was a problem and an error
|
||||
* message has already been output (but the colorspace may still need to be
|
||||
* synced to record the invalid flag).
|
||||
*/
|
||||
#endif /* sRGB */
|
||||
|
||||
#ifdef PNG_iCCP_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(int,png_colorspace_set_ICC,(png_const_structrp png_ptr,
|
||||
png_colorspacerp colorspace, png_const_charp name,
|
||||
png_uint_32 profile_length, png_const_bytep profile, int color_type),
|
||||
PNG_EMPTY);
|
||||
/* The 'name' is used for information only */
|
||||
|
||||
/* Routines for checking parts of an ICC profile. */
|
||||
#ifdef PNG_READ_iCCP_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(int,png_icc_check_length,(png_const_structrp png_ptr,
|
||||
png_colorspacerp colorspace, png_const_charp name,
|
||||
png_uint_32 profile_length), PNG_EMPTY);
|
||||
png_const_charp name, png_uint_32 profile_length), PNG_EMPTY);
|
||||
#endif /* READ_iCCP */
|
||||
PNG_INTERNAL_FUNCTION(int,png_icc_check_header,(png_const_structrp png_ptr,
|
||||
png_colorspacerp colorspace, png_const_charp name,
|
||||
png_uint_32 profile_length,
|
||||
png_const_charp name, png_uint_32 profile_length,
|
||||
png_const_bytep profile /* first 132 bytes only */, int color_type),
|
||||
PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(int,png_icc_check_tag_table,(png_const_structrp png_ptr,
|
||||
png_colorspacerp colorspace, png_const_charp name,
|
||||
png_uint_32 profile_length,
|
||||
png_const_charp name, png_uint_32 profile_length,
|
||||
png_const_bytep profile /* header plus whole tag table */), PNG_EMPTY);
|
||||
#ifdef PNG_sRGB_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_icc_set_sRGB,(
|
||||
png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
png_const_bytep profile, uLong adler), PNG_EMPTY);
|
||||
/* 'adler' is the Adler32 checksum of the uncompressed profile data. It may
|
||||
* be zero to indicate that it is not available. It is used, if provided,
|
||||
* as a fast check on the profile when checking to see if it is sRGB.
|
||||
*/
|
||||
#endif
|
||||
#endif /* iCCP */
|
||||
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_colorspace_set_rgb_coefficients,
|
||||
(png_structrp png_ptr), PNG_EMPTY);
|
||||
/* Set the rgb_to_gray coefficients from the colorspace Y values */
|
||||
PNG_INTERNAL_FUNCTION(void,png_set_rgb_coefficients, (png_structrp png_ptr),
|
||||
PNG_EMPTY);
|
||||
/* Set the rgb_to_gray coefficients from the cHRM Y values (if unset) */
|
||||
#endif /* READ_RGB_TO_GRAY */
|
||||
#endif /* COLORSPACE */
|
||||
|
||||
/* Added at libpng version 1.4.0 */
|
||||
PNG_INTERNAL_FUNCTION(void,png_check_IHDR,(png_const_structrp png_ptr,
|
||||
@ -2032,8 +2000,10 @@ PNG_INTERNAL_FUNCTION(int,png_check_fp_string,(png_const_charp string,
|
||||
size_t size),PNG_EMPTY);
|
||||
#endif /* pCAL || sCAL */
|
||||
|
||||
#if defined(PNG_GAMMA_SUPPORTED) ||\
|
||||
defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED)
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) ||\
|
||||
defined(PNG_COLORSPACE_SUPPORTED) ||\
|
||||
defined(PNG_INCH_CONVERSIONS_SUPPORTED) ||\
|
||||
defined(PNG_READ_pHYs_SUPPORTED)
|
||||
/* Added at libpng version 1.5.0 */
|
||||
/* This is a utility to provide a*times/div (rounded) and indicate
|
||||
* if there is an overflow. The result is a boolean - false (0)
|
||||
@ -2042,22 +2012,14 @@ PNG_INTERNAL_FUNCTION(int,png_check_fp_string,(png_const_charp string,
|
||||
*/
|
||||
PNG_INTERNAL_FUNCTION(int,png_muldiv,(png_fixed_point_p res, png_fixed_point a,
|
||||
png_int_32 multiplied_by, png_int_32 divided_by),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)
|
||||
/* Same deal, but issue a warning on overflow and return 0. */
|
||||
PNG_INTERNAL_FUNCTION(png_fixed_point,png_muldiv_warn,
|
||||
(png_const_structrp png_ptr, png_fixed_point a, png_int_32 multiplied_by,
|
||||
png_int_32 divided_by),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_GAMMA_SUPPORTED
|
||||
/* Calculate a reciprocal - used for gamma values. This returns
|
||||
* 0 if the argument is 0 in order to maintain an undefined value;
|
||||
* there are no warnings.
|
||||
*/
|
||||
PNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal,(png_fixed_point a),
|
||||
PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
/* The same but gives a reciprocal of the product of two fixed point
|
||||
@ -2066,14 +2028,22 @@ PNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal,(png_fixed_point a),
|
||||
*/
|
||||
PNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal2,(png_fixed_point a,
|
||||
png_fixed_point b),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
/* Return true if the gamma value is significantly different from 1.0 */
|
||||
PNG_INTERNAL_FUNCTION(int,png_gamma_significant,(png_fixed_point gamma_value),
|
||||
PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
/* PNGv3: 'resolve' the file gamma according to the new PNGv3 rules for colour
|
||||
* space information.
|
||||
*
|
||||
* NOTE: this uses precisely those chunks that libpng supports. For example it
|
||||
* doesn't use iCCP and it can only use cICP for known and manageable
|
||||
* transforms. For this reason a gamma specified by png_set_gamma always takes
|
||||
* precedence.
|
||||
*/
|
||||
PNG_INTERNAL_FUNCTION(png_fixed_point,png_resolve_file_gamma,
|
||||
(png_const_structrp png_ptr),PNG_EMPTY);
|
||||
|
||||
/* Internal fixed point gamma correction. These APIs are called as
|
||||
* required to convert single values - they don't need to be fast,
|
||||
* they are not used when processing image pixel values.
|
||||
@ -2091,6 +2061,22 @@ PNG_INTERNAL_FUNCTION(void,png_destroy_gamma_table,(png_structrp png_ptr),
|
||||
PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_build_gamma_table,(png_structrp png_ptr,
|
||||
int bit_depth),PNG_EMPTY);
|
||||
#endif /* READ_GAMMA */
|
||||
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
/* Set the RGB coefficients if not already set by png_set_rgb_to_gray */
|
||||
PNG_INTERNAL_FUNCTION(void,png_set_rgb_coefficients,(png_structrp png_ptr),
|
||||
PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#if defined(PNG_cHRM_SUPPORTED) || defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
PNG_INTERNAL_FUNCTION(int,png_XYZ_from_xy,(png_XYZ *XYZ, const png_xy *xy),
|
||||
PNG_EMPTY);
|
||||
#endif /* cHRM || READ_RGB_TO_GRAY */
|
||||
|
||||
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(int,png_xy_from_XYZ,(png_xy *xy, const png_XYZ *XYZ),
|
||||
PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
/* SIMPLIFIED READ/WRITE SUPPORT */
|
||||
@ -2189,6 +2175,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);
|
||||
|
||||
@ -2224,4 +2215,3 @@ PNG_INTERNAL_FUNCTION(int,
|
||||
#endif
|
||||
|
||||
#endif /* PNG_VERSION_INFO_ONLY */
|
||||
#endif /* PNGPRIV_H */
|
||||
|
391
pngread.c
391
pngread.c
@ -131,14 +131,11 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||
}
|
||||
|
||||
/* This should be a binary subdivision search or a hash for
|
||||
* matching the chunk name rather than a linear search.
|
||||
*/
|
||||
if (chunk_name == png_IHDR)
|
||||
png_handle_IHDR(png_ptr, info_ptr, length);
|
||||
png_handle_chunk(png_ptr, info_ptr, length);
|
||||
|
||||
else if (chunk_name == png_IEND)
|
||||
png_handle_IEND(png_ptr, info_ptr, length);
|
||||
png_handle_chunk(png_ptr, info_ptr, length);
|
||||
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0)
|
||||
@ -155,8 +152,6 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else if (chunk_name == png_PLTE)
|
||||
png_handle_PLTE(png_ptr, info_ptr, length);
|
||||
|
||||
else if (chunk_name == png_IDAT)
|
||||
{
|
||||
@ -164,114 +159,8 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_bKGD_SUPPORTED
|
||||
else if (chunk_name == png_bKGD)
|
||||
png_handle_bKGD(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_cHRM_SUPPORTED
|
||||
else if (chunk_name == png_cHRM)
|
||||
png_handle_cHRM(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_cICP_SUPPORTED
|
||||
else if (chunk_name == png_cICP)
|
||||
png_handle_cICP(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_cLLI_SUPPORTED
|
||||
else if (chunk_name == png_cLLI)
|
||||
png_handle_cLLI(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_eXIf_SUPPORTED
|
||||
else if (chunk_name == png_eXIf)
|
||||
png_handle_eXIf(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_gAMA_SUPPORTED
|
||||
else if (chunk_name == png_gAMA)
|
||||
png_handle_gAMA(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_hIST_SUPPORTED
|
||||
else if (chunk_name == png_hIST)
|
||||
png_handle_hIST(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_mDCV_SUPPORTED
|
||||
else if (chunk_name == png_mDCV)
|
||||
png_handle_mDCV(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_oFFs_SUPPORTED
|
||||
else if (chunk_name == png_oFFs)
|
||||
png_handle_oFFs(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_pCAL_SUPPORTED
|
||||
else if (chunk_name == png_pCAL)
|
||||
png_handle_pCAL(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_sCAL_SUPPORTED
|
||||
else if (chunk_name == png_sCAL)
|
||||
png_handle_sCAL(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_pHYs_SUPPORTED
|
||||
else if (chunk_name == png_pHYs)
|
||||
png_handle_pHYs(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_sBIT_SUPPORTED
|
||||
else if (chunk_name == png_sBIT)
|
||||
png_handle_sBIT(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_sRGB_SUPPORTED
|
||||
else if (chunk_name == png_sRGB)
|
||||
png_handle_sRGB(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_iCCP_SUPPORTED
|
||||
else if (chunk_name == png_iCCP)
|
||||
png_handle_iCCP(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_sPLT_SUPPORTED
|
||||
else if (chunk_name == png_sPLT)
|
||||
png_handle_sPLT(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_tEXt_SUPPORTED
|
||||
else if (chunk_name == png_tEXt)
|
||||
png_handle_tEXt(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_tIME_SUPPORTED
|
||||
else if (chunk_name == png_tIME)
|
||||
png_handle_tIME(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_tRNS_SUPPORTED
|
||||
else if (chunk_name == png_tRNS)
|
||||
png_handle_tRNS(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_zTXt_SUPPORTED
|
||||
else if (chunk_name == png_zTXt)
|
||||
png_handle_zTXt(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_iTXt_SUPPORTED
|
||||
else if (chunk_name == png_iTXt)
|
||||
png_handle_iTXt(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
else
|
||||
png_handle_unknown(png_ptr, info_ptr, length,
|
||||
PNG_HANDLE_CHUNK_AS_DEFAULT);
|
||||
png_handle_chunk(png_ptr, info_ptr, length);
|
||||
}
|
||||
}
|
||||
#endif /* SEQUENTIAL_READ */
|
||||
@ -813,13 +702,18 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||
png_uint_32 chunk_name = png_ptr->chunk_name;
|
||||
|
||||
if (chunk_name != png_IDAT)
|
||||
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
|
||||
{
|
||||
/* These flags must be set consistently for all non-IDAT chunks,
|
||||
* including the unknown chunks.
|
||||
*/
|
||||
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT | PNG_AFTER_IDAT;
|
||||
}
|
||||
|
||||
if (chunk_name == png_IEND)
|
||||
png_handle_IEND(png_ptr, info_ptr, length);
|
||||
png_handle_chunk(png_ptr, info_ptr, length);
|
||||
|
||||
else if (chunk_name == png_IHDR)
|
||||
png_handle_IHDR(png_ptr, info_ptr, length);
|
||||
png_handle_chunk(png_ptr, info_ptr, length);
|
||||
|
||||
else if (info_ptr == NULL)
|
||||
png_crc_finish(png_ptr, length);
|
||||
@ -853,117 +747,9 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||
|
||||
png_crc_finish(png_ptr, length);
|
||||
}
|
||||
else if (chunk_name == png_PLTE)
|
||||
png_handle_PLTE(png_ptr, info_ptr, length);
|
||||
|
||||
#ifdef PNG_READ_bKGD_SUPPORTED
|
||||
else if (chunk_name == png_bKGD)
|
||||
png_handle_bKGD(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_cHRM_SUPPORTED
|
||||
else if (chunk_name == png_cHRM)
|
||||
png_handle_cHRM(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_cICP_SUPPORTED
|
||||
else if (chunk_name == png_cICP)
|
||||
png_handle_cICP(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_cLLI_SUPPORTED
|
||||
else if (chunk_name == png_cLLI)
|
||||
png_handle_cLLI(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_eXIf_SUPPORTED
|
||||
else if (chunk_name == png_eXIf)
|
||||
png_handle_eXIf(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_gAMA_SUPPORTED
|
||||
else if (chunk_name == png_gAMA)
|
||||
png_handle_gAMA(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_hIST_SUPPORTED
|
||||
else if (chunk_name == png_hIST)
|
||||
png_handle_hIST(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_mDCV_SUPPORTED
|
||||
else if (chunk_name == png_mDCV)
|
||||
png_handle_mDCV(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_oFFs_SUPPORTED
|
||||
else if (chunk_name == png_oFFs)
|
||||
png_handle_oFFs(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_pCAL_SUPPORTED
|
||||
else if (chunk_name == png_pCAL)
|
||||
png_handle_pCAL(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_sCAL_SUPPORTED
|
||||
else if (chunk_name == png_sCAL)
|
||||
png_handle_sCAL(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_pHYs_SUPPORTED
|
||||
else if (chunk_name == png_pHYs)
|
||||
png_handle_pHYs(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_sBIT_SUPPORTED
|
||||
else if (chunk_name == png_sBIT)
|
||||
png_handle_sBIT(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_sRGB_SUPPORTED
|
||||
else if (chunk_name == png_sRGB)
|
||||
png_handle_sRGB(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_iCCP_SUPPORTED
|
||||
else if (chunk_name == png_iCCP)
|
||||
png_handle_iCCP(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_sPLT_SUPPORTED
|
||||
else if (chunk_name == png_sPLT)
|
||||
png_handle_sPLT(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_tEXt_SUPPORTED
|
||||
else if (chunk_name == png_tEXt)
|
||||
png_handle_tEXt(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_tIME_SUPPORTED
|
||||
else if (chunk_name == png_tIME)
|
||||
png_handle_tIME(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_tRNS_SUPPORTED
|
||||
else if (chunk_name == png_tRNS)
|
||||
png_handle_tRNS(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_zTXt_SUPPORTED
|
||||
else if (chunk_name == png_zTXt)
|
||||
png_handle_zTXt(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_iTXt_SUPPORTED
|
||||
else if (chunk_name == png_iTXt)
|
||||
png_handle_iTXt(png_ptr, info_ptr, length);
|
||||
#endif
|
||||
|
||||
else
|
||||
png_handle_unknown(png_ptr, info_ptr, length,
|
||||
PNG_HANDLE_CHUNK_AS_DEFAULT);
|
||||
png_handle_chunk(png_ptr, info_ptr, length);
|
||||
} while ((png_ptr->mode & PNG_HAVE_IEND) == 0);
|
||||
}
|
||||
#endif /* SEQUENTIAL_READ */
|
||||
@ -1028,7 +814,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
|
||||
@ -1414,6 +1201,31 @@ png_image_format(png_structrp png_ptr)
|
||||
return format;
|
||||
}
|
||||
|
||||
static int
|
||||
chromaticities_match_sRGB(const png_xy *xy)
|
||||
{
|
||||
# define sRGB_TOLERANCE 1000
|
||||
static const png_xy sRGB_xy = /* From ITU-R BT.709-3 */
|
||||
{
|
||||
/* color x y */
|
||||
/* red */ 64000, 33000,
|
||||
/* green */ 30000, 60000,
|
||||
/* blue */ 15000, 6000,
|
||||
/* white */ 31270, 32900
|
||||
};
|
||||
|
||||
if (PNG_OUT_OF_RANGE(xy->whitex, sRGB_xy.whitex,sRGB_TOLERANCE) ||
|
||||
PNG_OUT_OF_RANGE(xy->whitey, sRGB_xy.whitey,sRGB_TOLERANCE) ||
|
||||
PNG_OUT_OF_RANGE(xy->redx, sRGB_xy.redx, sRGB_TOLERANCE) ||
|
||||
PNG_OUT_OF_RANGE(xy->redy, sRGB_xy.redy, sRGB_TOLERANCE) ||
|
||||
PNG_OUT_OF_RANGE(xy->greenx, sRGB_xy.greenx,sRGB_TOLERANCE) ||
|
||||
PNG_OUT_OF_RANGE(xy->greeny, sRGB_xy.greeny,sRGB_TOLERANCE) ||
|
||||
PNG_OUT_OF_RANGE(xy->bluex, sRGB_xy.bluex, sRGB_TOLERANCE) ||
|
||||
PNG_OUT_OF_RANGE(xy->bluey, sRGB_xy.bluey, sRGB_TOLERANCE))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Is the given gamma significantly different from sRGB? The test is the same
|
||||
* one used in pngrtran.c when deciding whether to do gamma correction. The
|
||||
* arithmetic optimizes the division by using the fact that the inverse of the
|
||||
@ -1422,22 +1234,44 @@ png_image_format(png_structrp png_ptr)
|
||||
static int
|
||||
png_gamma_not_sRGB(png_fixed_point g)
|
||||
{
|
||||
if (g < PNG_FP_1)
|
||||
{
|
||||
/* An uninitialized gamma is assumed to be sRGB for the simplified API. */
|
||||
if (g == 0)
|
||||
return 0;
|
||||
/* 1.6.47: use the same sanity checks as used in pngrtran.c */
|
||||
if (g < PNG_LIB_GAMMA_MIN || g > PNG_LIB_GAMMA_MAX)
|
||||
return 0; /* Includes the uninitialized value 0 */
|
||||
|
||||
return png_gamma_significant((g * 11 + 2)/5 /* i.e. *2.2, rounded */);
|
||||
}
|
||||
|
||||
return 1;
|
||||
return png_gamma_significant((g * 11 + 2)/5 /* i.e. *2.2, rounded */);
|
||||
}
|
||||
|
||||
/* Do the main body of a 'png_image_begin_read' function; read the PNG file
|
||||
* header and fill in all the information. This is executed in a safe context,
|
||||
* unlike the init routine above.
|
||||
*/
|
||||
static int
|
||||
png_image_is_not_sRGB(png_const_structrp png_ptr)
|
||||
{
|
||||
/* Does the colorspace **not** match sRGB? The flag is only set if the
|
||||
* answer can be determined reliably.
|
||||
*
|
||||
* png_struct::chromaticities always exists since the simplified API
|
||||
* requires rgb-to-gray. The mDCV, cICP and cHRM chunks may all set it to
|
||||
* a non-sRGB value, so it needs to be checked but **only** if one of
|
||||
* those chunks occured in the file.
|
||||
*/
|
||||
/* Highest priority: check to be safe. */
|
||||
if (png_has_chunk(png_ptr, cICP) || png_has_chunk(png_ptr, mDCV))
|
||||
return !chromaticities_match_sRGB(&png_ptr->chromaticities);
|
||||
|
||||
/* If the image is marked as sRGB then it is... */
|
||||
if (png_has_chunk(png_ptr, sRGB))
|
||||
return 0;
|
||||
|
||||
/* Last stop: cHRM, must check: */
|
||||
if (png_has_chunk(png_ptr, cHRM))
|
||||
return !chromaticities_match_sRGB(&png_ptr->chromaticities);
|
||||
|
||||
/* Else default to sRGB */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
png_image_read_header(png_voidp argument)
|
||||
{
|
||||
@ -1459,17 +1293,13 @@ png_image_read_header(png_voidp argument)
|
||||
|
||||
image->format = format;
|
||||
|
||||
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||
/* Does the colorspace match sRGB? If there is no color endpoint
|
||||
* (colorant) information assume yes, otherwise require the
|
||||
* 'ENDPOINTS_MATCHP_sRGB' colorspace flag to have been set. If the
|
||||
* colorspace has been determined to be invalid ignore it.
|
||||
/* Greyscale images don't (typically) have colour space information and
|
||||
* using it is pretty much impossible, so use sRGB for grayscale (it
|
||||
* doesn't matter r==g==b so the transform is irrelevant.)
|
||||
*/
|
||||
if ((format & PNG_FORMAT_FLAG_COLOR) != 0 && ((png_ptr->colorspace.flags
|
||||
& (PNG_COLORSPACE_HAVE_ENDPOINTS|PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB|
|
||||
PNG_COLORSPACE_INVALID)) == PNG_COLORSPACE_HAVE_ENDPOINTS))
|
||||
if ((format & PNG_FORMAT_FLAG_COLOR) != 0 &&
|
||||
png_image_is_not_sRGB(png_ptr))
|
||||
image->flags |= PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* We need the maximum number of entries regardless of the format the
|
||||
@ -1504,7 +1334,7 @@ png_image_read_header(png_voidp argument)
|
||||
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
int PNGAPI
|
||||
png_image_begin_read_from_stdio(png_imagep image, FILE* file)
|
||||
png_image_begin_read_from_stdio(png_imagep image, FILE *file)
|
||||
{
|
||||
if (image != NULL && image->version == PNG_IMAGE_VERSION)
|
||||
{
|
||||
@ -1657,21 +1487,18 @@ png_image_skip_unused_chunks(png_structrp png_ptr)
|
||||
* potential vulnerability to security problems in the unused chunks.
|
||||
*
|
||||
* At present the iCCP chunk data isn't used, so iCCP chunk can be ignored
|
||||
* too. This allows the simplified API to be compiled without iCCP support,
|
||||
* however if the support is there the chunk is still checked to detect
|
||||
* errors (which are unfortunately quite common.)
|
||||
* too. This allows the simplified API to be compiled without iCCP support.
|
||||
*/
|
||||
{
|
||||
static const png_byte chunks_to_process[] = {
|
||||
98, 75, 71, 68, '\0', /* bKGD */
|
||||
99, 72, 82, 77, '\0', /* cHRM */
|
||||
99, 73, 67, 80, '\0', /* cICP */
|
||||
103, 65, 77, 65, '\0', /* gAMA */
|
||||
# ifdef PNG_READ_iCCP_SUPPORTED
|
||||
105, 67, 67, 80, '\0', /* iCCP */
|
||||
# endif
|
||||
109, 68, 67, 86, '\0', /* mDCV */
|
||||
115, 66, 73, 84, '\0', /* sBIT */
|
||||
115, 82, 71, 66, '\0', /* sRGB */
|
||||
};
|
||||
};
|
||||
|
||||
/* Ignore unknown chunks and all other chunks except for the
|
||||
* IHDR, PLTE, tRNS, IDAT, and IEND chunks.
|
||||
@ -1700,7 +1527,15 @@ png_image_skip_unused_chunks(png_structrp png_ptr)
|
||||
static void
|
||||
set_file_encoding(png_image_read_control *display)
|
||||
{
|
||||
png_fixed_point g = display->image->opaque->png_ptr->colorspace.gamma;
|
||||
png_structrp png_ptr = display->image->opaque->png_ptr;
|
||||
png_fixed_point g = png_resolve_file_gamma(png_ptr);
|
||||
|
||||
/* PNGv3: the result may be 0 however the 'default_gamma' should have been
|
||||
* set before this is called so zero is an error:
|
||||
*/
|
||||
if (g == 0)
|
||||
png_error(png_ptr, "internal: default gamma not set");
|
||||
|
||||
if (png_gamma_significant(g) != 0)
|
||||
{
|
||||
if (png_gamma_not_sRGB(g) != 0)
|
||||
@ -2188,24 +2023,18 @@ png_image_read_colormap(png_voidp argument)
|
||||
/* Default the input file gamma if required - this is necessary because
|
||||
* libpng assumes that if no gamma information is present the data is in the
|
||||
* output format, but the simplified API deduces the gamma from the input
|
||||
* format.
|
||||
* format. The 'default' gamma value is also set by png_set_alpha_mode, but
|
||||
* this is happening before any such call, so:
|
||||
*
|
||||
* TODO: should be an internal API and all this code should be copied into a
|
||||
* single common gamma+colorspace file.
|
||||
*/
|
||||
if ((png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) == 0)
|
||||
{
|
||||
/* Do this directly, not using the png_colorspace functions, to ensure
|
||||
* that it happens even if the colorspace is invalid (though probably if
|
||||
* it is the setting will be ignored) Note that the same thing can be
|
||||
* achieved at the application interface with png_set_gAMA.
|
||||
*/
|
||||
if (png_ptr->bit_depth == 16 &&
|
||||
(image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0)
|
||||
png_ptr->colorspace.gamma = PNG_GAMMA_LINEAR;
|
||||
if (png_ptr->bit_depth == 16 &&
|
||||
(image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0)
|
||||
png_ptr->default_gamma = PNG_GAMMA_LINEAR;
|
||||
|
||||
else
|
||||
png_ptr->colorspace.gamma = PNG_GAMMA_sRGB_INVERSE;
|
||||
|
||||
png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
|
||||
}
|
||||
else
|
||||
png_ptr->default_gamma = PNG_GAMMA_sRGB_INVERSE;
|
||||
|
||||
/* Decide what to do based on the PNG color type of the input data. The
|
||||
* utility function png_create_colormap_entry deals with most aspects of the
|
||||
@ -2583,6 +2412,8 @@ png_image_read_colormap(png_voidp argument)
|
||||
|
||||
else
|
||||
{
|
||||
const png_fixed_point gamma = png_resolve_file_gamma(png_ptr);
|
||||
|
||||
/* Either the input or the output has no alpha channel, so there
|
||||
* will be no non-opaque pixels in the color-map; it will just be
|
||||
* grayscale.
|
||||
@ -2597,10 +2428,13 @@ png_image_read_colormap(png_voidp argument)
|
||||
* this case and doing it in the palette; this will result in
|
||||
* duplicate palette entries, but that's better than the
|
||||
* alternative of double gamma correction.
|
||||
*
|
||||
* NOTE: PNGv3: check the resolved result of all the potentially
|
||||
* different colour space chunks.
|
||||
*/
|
||||
if ((png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
|
||||
png_ptr->num_trans > 0) &&
|
||||
png_gamma_not_sRGB(png_ptr->colorspace.gamma) != 0)
|
||||
png_gamma_not_sRGB(gamma) != 0)
|
||||
{
|
||||
cmap_entries = (unsigned int)make_gray_file_colormap(display);
|
||||
data_encoding = P_FILE;
|
||||
@ -2632,8 +2466,8 @@ png_image_read_colormap(png_voidp argument)
|
||||
if (output_encoding == P_sRGB)
|
||||
gray = png_sRGB_table[gray]; /* now P_LINEAR */
|
||||
|
||||
gray = PNG_DIV257(png_gamma_16bit_correct(gray,
|
||||
png_ptr->colorspace.gamma)); /* now P_FILE */
|
||||
gray = PNG_DIV257(png_gamma_16bit_correct(gray, gamma));
|
||||
/* now P_FILE */
|
||||
|
||||
/* And make sure the corresponding palette entry contains
|
||||
* exactly the required sRGB value.
|
||||
@ -3764,6 +3598,12 @@ png_image_read_direct(png_voidp argument)
|
||||
/* Set the gamma appropriately, linear for 16-bit input, sRGB otherwise.
|
||||
*/
|
||||
{
|
||||
/* This is safe but should no longer be necessary as
|
||||
* png_ptr->default_gamma should have been set after the
|
||||
* info-before-IDAT was read in png_image_read_header.
|
||||
*
|
||||
* TODO: 1.8: remove this and see what happens.
|
||||
*/
|
||||
png_fixed_point input_gamma_default;
|
||||
|
||||
if ((base_format & PNG_FORMAT_FLAG_LINEAR) != 0 &&
|
||||
@ -3819,8 +3659,9 @@ png_image_read_direct(png_voidp argument)
|
||||
* yet; it's set below. png_struct::gamma, however, is set to the
|
||||
* final value.
|
||||
*/
|
||||
if (png_muldiv(>est, output_gamma, png_ptr->colorspace.gamma,
|
||||
PNG_FP_1) != 0 && png_gamma_significant(gtest) == 0)
|
||||
if (png_muldiv(>est, output_gamma,
|
||||
png_resolve_file_gamma(png_ptr), PNG_FP_1) != 0 &&
|
||||
png_gamma_significant(gtest) == 0)
|
||||
do_local_background = 0;
|
||||
|
||||
else if (mode == PNG_ALPHA_STANDARD)
|
||||
|
4
pngrio.c
4
pngrio.c
@ -1,6 +1,6 @@
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2018-2025 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -56,7 +56,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, size_t length)
|
||||
/* fread() returns 0 on error, so it is OK to store this in a size_t
|
||||
* instead of an int, which is what fread() actually returns.
|
||||
*/
|
||||
check = fread(data, 1, length, png_voidcast(png_FILE_p, png_ptr->io_ptr));
|
||||
check = fread(data, 1, length, png_voidcast(FILE *, png_ptr->io_ptr));
|
||||
|
||||
if (check != length)
|
||||
png_error(png_ptr, "Read Error");
|
||||
|
345
pngrtran.c
345
pngrtran.c
@ -1,6 +1,6 @@
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* Copyright (c) 2018-2024 Cosmin Truta
|
||||
* Copyright (c) 2018-2025 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -28,6 +28,12 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_RISCV_RVV_IMPLEMENTATION
|
||||
# if PNG_RISCV_RVV_IMPLEMENTATION == 1
|
||||
# define PNG_RISCV_RVV_INTRINSICS_AVAILABLE
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
|
||||
/* Set the action on getting a CRC error for an ancillary or critical chunk. */
|
||||
@ -218,9 +224,59 @@ png_set_strip_alpha(png_structrp png_ptr)
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_ALPHA_MODE_SUPPORTED) || defined(PNG_READ_GAMMA_SUPPORTED)
|
||||
/* PNGv3 conformance: this private API exists to resolve the now mandatory error
|
||||
* resolution when multiple conflicting sources of gamma or colour space
|
||||
* information are available.
|
||||
*
|
||||
* Terminology (assuming power law, "gamma", encodings):
|
||||
* "screen" gamma: a power law imposed by the output device when digital
|
||||
* samples are converted to visible light output. The EOTF - volage to
|
||||
* luminance on output.
|
||||
*
|
||||
* "file" gamma: a power law used to encode luminance levels from the input
|
||||
* data (the scene or the mastering display system) into digital voltages.
|
||||
* The OETF - luminance to voltage on input.
|
||||
*
|
||||
* gamma "correction": a power law matching the **inverse** of the overall
|
||||
* transfer function from input luminance levels to output levels. The
|
||||
* **inverse** of the OOTF; the correction "corrects" for the OOTF by aiming
|
||||
* to make the overall OOTF (including the correction) linear.
|
||||
*
|
||||
* It is important to understand this terminology because the defined terms are
|
||||
* scattered throughout the libpng code and it is very easy to end up with the
|
||||
* inverse of the power law required.
|
||||
*
|
||||
* Variable and struct::member names:
|
||||
* file_gamma OETF how the PNG data was encoded
|
||||
*
|
||||
* screen_gamma EOTF how the screen will decode digital levels
|
||||
*
|
||||
* -- not used -- OOTF the net effect OETF x EOTF
|
||||
* gamma_correction the inverse of OOTF to make the result linear
|
||||
*
|
||||
* All versions of libpng require a call to "png_set_gamma" to establish the
|
||||
* "screen" gamma, the power law representing the EOTF. png_set_gamma may also
|
||||
* set or default the "file" gamma; the OETF. gamma_correction is calculated
|
||||
* internally.
|
||||
*
|
||||
* The earliest libpng versions required file_gamma to be supplied to set_gamma.
|
||||
* Later versions started allowing png_set_gamma and, later, png_set_alpha_mode,
|
||||
* to cause defaulting from the file data.
|
||||
*
|
||||
* PNGv3 mandated a particular form for this defaulting, one that is compatible
|
||||
* with what libpng did except that if libpng detected inconsistencies it marked
|
||||
* all the chunks as "invalid". PNGv3 effectively invalidates this prior code.
|
||||
*
|
||||
* Behaviour implemented below:
|
||||
* translate_gamma_flags(gamma, is_screen)
|
||||
* The libpng-1.6 API for the gamma parameters to libpng APIs
|
||||
* (png_set_gamma and png_set_alpha_mode at present). This allows the
|
||||
* 'gamma' value to be passed as a png_fixed_point number or as one of a
|
||||
* set of integral values for specific "well known" examples of transfer
|
||||
* functions. This is compatible with PNGv3.
|
||||
*/
|
||||
static png_fixed_point
|
||||
translate_gamma_flags(png_structrp png_ptr, png_fixed_point output_gamma,
|
||||
int is_screen)
|
||||
translate_gamma_flags(png_fixed_point output_gamma, int is_screen)
|
||||
{
|
||||
/* Check for flag values. The main reason for having the old Mac value as a
|
||||
* flag is that it is pretty near impossible to work out what the correct
|
||||
@ -230,14 +286,6 @@ translate_gamma_flags(png_structrp png_ptr, png_fixed_point output_gamma,
|
||||
if (output_gamma == PNG_DEFAULT_sRGB ||
|
||||
output_gamma == PNG_FP_1 / PNG_DEFAULT_sRGB)
|
||||
{
|
||||
/* If there is no sRGB support this just sets the gamma to the standard
|
||||
* sRGB value. (This is a side effect of using this function!)
|
||||
*/
|
||||
# ifdef PNG_READ_sRGB_SUPPORTED
|
||||
png_ptr->flags |= PNG_FLAG_ASSUME_sRGB;
|
||||
# else
|
||||
PNG_UNUSED(png_ptr)
|
||||
# endif
|
||||
if (is_screen != 0)
|
||||
output_gamma = PNG_GAMMA_sRGB;
|
||||
else
|
||||
@ -279,6 +327,33 @@ convert_gamma_value(png_structrp png_ptr, double output_gamma)
|
||||
return (png_fixed_point)output_gamma;
|
||||
}
|
||||
# endif
|
||||
|
||||
static int
|
||||
unsupported_gamma(png_structrp png_ptr, png_fixed_point gamma, int warn)
|
||||
{
|
||||
/* Validate a gamma value to ensure it is in a reasonable range. The value
|
||||
* is expected to be 1 or greater, but this range test allows for some
|
||||
* viewing correction values. The intent is to weed out the API users
|
||||
* who might use the inverse of the gamma value accidentally!
|
||||
*
|
||||
* 1.6.47: apply the test in png_set_gamma as well but only warn and return
|
||||
* false if it fires.
|
||||
*
|
||||
* TODO: 1.8: make this an app_error in png_set_gamma as well.
|
||||
*/
|
||||
if (gamma < PNG_LIB_GAMMA_MIN || gamma > PNG_LIB_GAMMA_MAX)
|
||||
{
|
||||
# define msg "gamma out of supported range"
|
||||
if (warn)
|
||||
png_app_warning(png_ptr, msg);
|
||||
else
|
||||
png_app_error(png_ptr, msg);
|
||||
return 1;
|
||||
# undef msg
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif /* READ_ALPHA_MODE || READ_GAMMA */
|
||||
|
||||
#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
|
||||
@ -286,31 +361,29 @@ void PNGFAPI
|
||||
png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
|
||||
png_fixed_point output_gamma)
|
||||
{
|
||||
int compose = 0;
|
||||
png_fixed_point file_gamma;
|
||||
int compose = 0;
|
||||
|
||||
png_debug(1, "in png_set_alpha_mode_fixed");
|
||||
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
return;
|
||||
|
||||
output_gamma = translate_gamma_flags(png_ptr, output_gamma, 1/*screen*/);
|
||||
|
||||
/* Validate the value to ensure it is in a reasonable range. The value
|
||||
* is expected to be 1 or greater, but this range test allows for some
|
||||
* viewing correction values. The intent is to weed out the API users
|
||||
* who might use the inverse of the gamma value accidentally!
|
||||
*
|
||||
* 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");
|
||||
output_gamma = translate_gamma_flags(output_gamma, 1/*screen*/);
|
||||
if (unsupported_gamma(png_ptr, output_gamma, 0/*error*/))
|
||||
return;
|
||||
|
||||
/* The default file gamma is the inverse of the output gamma; the output
|
||||
* gamma may be changed below so get the file value first:
|
||||
* gamma may be changed below so get the file value first. The default_gamma
|
||||
* is set here and from the simplified API (which uses a different algorithm)
|
||||
* so don't overwrite a set value:
|
||||
*/
|
||||
file_gamma = png_reciprocal(output_gamma);
|
||||
file_gamma = png_ptr->default_gamma;
|
||||
if (file_gamma == 0)
|
||||
{
|
||||
file_gamma = png_reciprocal(output_gamma);
|
||||
png_ptr->default_gamma = file_gamma;
|
||||
}
|
||||
|
||||
/* There are really 8 possibilities here, composed of any combination
|
||||
* of:
|
||||
@ -361,17 +434,7 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
|
||||
png_error(png_ptr, "invalid alpha mode");
|
||||
}
|
||||
|
||||
/* Only set the default gamma if the file gamma has not been set (this has
|
||||
* the side effect that the gamma in a second call to png_set_alpha_mode will
|
||||
* be ignored.)
|
||||
*/
|
||||
if (png_ptr->colorspace.gamma == 0)
|
||||
{
|
||||
png_ptr->colorspace.gamma = file_gamma;
|
||||
png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
|
||||
}
|
||||
|
||||
/* But always set the output gamma: */
|
||||
/* Set the screen gamma values: */
|
||||
png_ptr->screen_gamma = output_gamma;
|
||||
|
||||
/* Finally, if pre-multiplying, set the background fields to achieve the
|
||||
@ -381,7 +444,7 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
|
||||
{
|
||||
/* And obtain alpha pre-multiplication by composing on black: */
|
||||
memset(&png_ptr->background, 0, (sizeof png_ptr->background));
|
||||
png_ptr->background_gamma = png_ptr->colorspace.gamma; /* just in case */
|
||||
png_ptr->background_gamma = file_gamma; /* just in case */
|
||||
png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_FILE;
|
||||
png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND;
|
||||
|
||||
@ -819,8 +882,8 @@ png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma,
|
||||
return;
|
||||
|
||||
/* New in libpng-1.5.4 - reserve particular negative values as flags. */
|
||||
scrn_gamma = translate_gamma_flags(png_ptr, scrn_gamma, 1/*screen*/);
|
||||
file_gamma = translate_gamma_flags(png_ptr, file_gamma, 0/*file*/);
|
||||
scrn_gamma = translate_gamma_flags(scrn_gamma, 1/*screen*/);
|
||||
file_gamma = translate_gamma_flags(file_gamma, 0/*file*/);
|
||||
|
||||
/* Checking the gamma values for being >0 was added in 1.5.4 along with the
|
||||
* premultiplied alpha support; this actually hides an undocumented feature
|
||||
@ -834,17 +897,19 @@ png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma,
|
||||
* libpng-1.6.0.
|
||||
*/
|
||||
if (file_gamma <= 0)
|
||||
png_error(png_ptr, "invalid file gamma in png_set_gamma");
|
||||
|
||||
png_app_error(png_ptr, "invalid file gamma in png_set_gamma");
|
||||
if (scrn_gamma <= 0)
|
||||
png_error(png_ptr, "invalid screen gamma in png_set_gamma");
|
||||
png_app_error(png_ptr, "invalid screen gamma in png_set_gamma");
|
||||
|
||||
/* Set the gamma values unconditionally - this overrides the value in the PNG
|
||||
* file if a gAMA chunk was present. png_set_alpha_mode provides a
|
||||
* different, easier, way to default the file gamma.
|
||||
if (unsupported_gamma(png_ptr, file_gamma, 1/*warn*/) ||
|
||||
unsupported_gamma(png_ptr, scrn_gamma, 1/*warn*/))
|
||||
return;
|
||||
|
||||
/* 1.6.47: png_struct::file_gamma and png_struct::screen_gamma are now only
|
||||
* written by this API. This removes dependencies on the order of API calls
|
||||
* and allows the complex gamma checks to be delayed until needed.
|
||||
*/
|
||||
png_ptr->colorspace.gamma = file_gamma;
|
||||
png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
|
||||
png_ptr->file_gamma = file_gamma;
|
||||
png_ptr->screen_gamma = scrn_gamma;
|
||||
}
|
||||
|
||||
@ -1022,26 +1087,9 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
|
||||
png_ptr->rgb_to_gray_coefficients_set = 1;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (red >= 0 && green >= 0)
|
||||
png_app_warning(png_ptr,
|
||||
"ignoring out of range rgb_to_gray coefficients");
|
||||
|
||||
/* Use the defaults, from the cHRM chunk if set, else the historical
|
||||
* values which are close to the sRGB/HDTV/ITU-Rec 709 values. See
|
||||
* png_do_rgb_to_gray for more discussion of the values. In this case
|
||||
* the coefficients are not marked as 'set' and are not overwritten if
|
||||
* something has already provided a default.
|
||||
*/
|
||||
if (png_ptr->rgb_to_gray_red_coeff == 0 &&
|
||||
png_ptr->rgb_to_gray_green_coeff == 0)
|
||||
{
|
||||
png_ptr->rgb_to_gray_red_coeff = 6968;
|
||||
png_ptr->rgb_to_gray_green_coeff = 23434;
|
||||
/* png_ptr->rgb_to_gray_blue_coeff = 2366; */
|
||||
}
|
||||
}
|
||||
else if (red >= 0 && green >= 0)
|
||||
png_app_warning(png_ptr,
|
||||
"ignoring out of range rgb_to_gray coefficients");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1282,6 +1330,80 @@ png_init_rgb_transformations(png_structrp png_ptr)
|
||||
#endif /* READ_EXPAND && READ_BACKGROUND */
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
png_fixed_point /* PRIVATE */
|
||||
png_resolve_file_gamma(png_const_structrp png_ptr)
|
||||
{
|
||||
png_fixed_point file_gamma;
|
||||
|
||||
/* The file gamma is determined by these precedence rules, in this order
|
||||
* (i.e. use the first value found):
|
||||
*
|
||||
* png_set_gamma; png_struct::file_gammma if not zero, then:
|
||||
* png_struct::chunk_gamma if not 0 (determined the PNGv3 rules), then:
|
||||
* png_set_gamma; 1/png_struct::screen_gamma if not zero
|
||||
*
|
||||
* 0 (i.e. do no gamma handling)
|
||||
*/
|
||||
file_gamma = png_ptr->file_gamma;
|
||||
if (file_gamma != 0)
|
||||
return file_gamma;
|
||||
|
||||
file_gamma = png_ptr->chunk_gamma;
|
||||
if (file_gamma != 0)
|
||||
return file_gamma;
|
||||
|
||||
file_gamma = png_ptr->default_gamma;
|
||||
if (file_gamma != 0)
|
||||
return file_gamma;
|
||||
|
||||
/* If png_reciprocal oveflows it returns 0 which indicates to the caller that
|
||||
* there is no usable file gamma. (The checks added to png_set_gamma and
|
||||
* png_set_alpha_mode should prevent a screen_gamma which would overflow.)
|
||||
*/
|
||||
if (png_ptr->screen_gamma != 0)
|
||||
file_gamma = png_reciprocal(png_ptr->screen_gamma);
|
||||
|
||||
return file_gamma;
|
||||
}
|
||||
|
||||
static int
|
||||
png_init_gamma_values(png_structrp png_ptr)
|
||||
{
|
||||
/* The following temporary indicates if overall gamma correction is
|
||||
* required.
|
||||
*/
|
||||
int gamma_correction = 0;
|
||||
png_fixed_point file_gamma, screen_gamma;
|
||||
|
||||
/* Resolve the file_gamma. See above: if png_ptr::screen_gamma is set
|
||||
* file_gamma will always be set here:
|
||||
*/
|
||||
file_gamma = png_resolve_file_gamma(png_ptr);
|
||||
screen_gamma = png_ptr->screen_gamma;
|
||||
|
||||
if (file_gamma > 0) /* file has been set */
|
||||
{
|
||||
if (screen_gamma > 0) /* screen set too */
|
||||
gamma_correction = png_gamma_threshold(file_gamma, screen_gamma);
|
||||
|
||||
else
|
||||
/* Assume the output matches the input; a long time default behavior
|
||||
* of libpng, although the standard has nothing to say about this.
|
||||
*/
|
||||
screen_gamma = png_reciprocal(file_gamma);
|
||||
}
|
||||
|
||||
else /* both unset, prevent corrections: */
|
||||
file_gamma = screen_gamma = PNG_FP_1;
|
||||
|
||||
png_ptr->file_gamma = file_gamma;
|
||||
png_ptr->screen_gamma = screen_gamma;
|
||||
return gamma_correction;
|
||||
|
||||
}
|
||||
#endif /* READ_GAMMA */
|
||||
|
||||
void /* PRIVATE */
|
||||
png_init_read_transformations(png_structrp png_ptr)
|
||||
{
|
||||
@ -1301,59 +1423,22 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
* the test needs to be performed later - here. In addition prior to 1.5.4
|
||||
* the tests were repeated for the PALETTE color type here - this is no
|
||||
* longer necessary (and doesn't seem to have been necessary before.)
|
||||
*
|
||||
* PNGv3: the new mandatory precedence/priority rules for colour space chunks
|
||||
* are handled here (by calling the above function).
|
||||
*
|
||||
* Turn the gamma transformation on or off as appropriate. Notice that
|
||||
* PNG_GAMMA just refers to the file->screen correction. Alpha composition
|
||||
* may independently cause gamma correction because it needs linear data
|
||||
* (e.g. if the file has a gAMA chunk but the screen gamma hasn't been
|
||||
* specified.) In any case this flag may get turned off in the code
|
||||
* immediately below if the transform can be handled outside the row loop.
|
||||
*/
|
||||
{
|
||||
/* The following temporary indicates if overall gamma correction is
|
||||
* required.
|
||||
*/
|
||||
int gamma_correction = 0;
|
||||
if (png_init_gamma_values(png_ptr) != 0)
|
||||
png_ptr->transformations |= PNG_GAMMA;
|
||||
|
||||
if (png_ptr->colorspace.gamma != 0) /* has been set */
|
||||
{
|
||||
if (png_ptr->screen_gamma != 0) /* screen set too */
|
||||
gamma_correction = png_gamma_threshold(png_ptr->colorspace.gamma,
|
||||
png_ptr->screen_gamma);
|
||||
|
||||
else
|
||||
/* Assume the output matches the input; a long time default behavior
|
||||
* of libpng, although the standard has nothing to say about this.
|
||||
*/
|
||||
png_ptr->screen_gamma = png_reciprocal(png_ptr->colorspace.gamma);
|
||||
}
|
||||
|
||||
else if (png_ptr->screen_gamma != 0)
|
||||
/* The converse - assume the file matches the screen, note that this
|
||||
* perhaps undesirable default can (from 1.5.4) be changed by calling
|
||||
* png_set_alpha_mode (even if the alpha handling mode isn't required
|
||||
* or isn't changed from the default.)
|
||||
*/
|
||||
png_ptr->colorspace.gamma = png_reciprocal(png_ptr->screen_gamma);
|
||||
|
||||
else /* neither are set */
|
||||
/* Just in case the following prevents any processing - file and screen
|
||||
* are both assumed to be linear and there is no way to introduce a
|
||||
* third gamma value other than png_set_background with 'UNIQUE', and,
|
||||
* prior to 1.5.4
|
||||
*/
|
||||
png_ptr->screen_gamma = png_ptr->colorspace.gamma = PNG_FP_1;
|
||||
|
||||
/* We have a gamma value now. */
|
||||
png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
|
||||
|
||||
/* Now turn the gamma transformation on or off as appropriate. Notice
|
||||
* that PNG_GAMMA just refers to the file->screen correction. Alpha
|
||||
* composition may independently cause gamma correction because it needs
|
||||
* linear data (e.g. if the file has a gAMA chunk but the screen gamma
|
||||
* hasn't been specified.) In any case this flag may get turned off in
|
||||
* the code immediately below if the transform can be handled outside the
|
||||
* row loop.
|
||||
*/
|
||||
if (gamma_correction != 0)
|
||||
png_ptr->transformations |= PNG_GAMMA;
|
||||
|
||||
else
|
||||
png_ptr->transformations &= ~PNG_GAMMA;
|
||||
}
|
||||
else
|
||||
png_ptr->transformations &= ~PNG_GAMMA;
|
||||
#endif
|
||||
|
||||
/* Certain transformations have the effect of preventing other
|
||||
@ -1425,7 +1510,7 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
* appropriately.
|
||||
*/
|
||||
if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0)
|
||||
png_colorspace_set_rgb_coefficients(png_ptr);
|
||||
png_set_rgb_coefficients(png_ptr);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
|
||||
@ -1568,10 +1653,10 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
*/
|
||||
if ((png_ptr->transformations & PNG_GAMMA) != 0 ||
|
||||
((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0 &&
|
||||
(png_gamma_significant(png_ptr->colorspace.gamma) != 0 ||
|
||||
(png_gamma_significant(png_ptr->file_gamma) != 0 ||
|
||||
png_gamma_significant(png_ptr->screen_gamma) != 0)) ||
|
||||
((png_ptr->transformations & PNG_COMPOSE) != 0 &&
|
||||
(png_gamma_significant(png_ptr->colorspace.gamma) != 0 ||
|
||||
(png_gamma_significant(png_ptr->file_gamma) != 0 ||
|
||||
png_gamma_significant(png_ptr->screen_gamma) != 0
|
||||
# ifdef PNG_READ_BACKGROUND_SUPPORTED
|
||||
|| (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_UNIQUE &&
|
||||
@ -1627,8 +1712,8 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
break;
|
||||
|
||||
case PNG_BACKGROUND_GAMMA_FILE:
|
||||
g = png_reciprocal(png_ptr->colorspace.gamma);
|
||||
gs = png_reciprocal2(png_ptr->colorspace.gamma,
|
||||
g = png_reciprocal(png_ptr->file_gamma);
|
||||
gs = png_reciprocal2(png_ptr->file_gamma,
|
||||
png_ptr->screen_gamma);
|
||||
break;
|
||||
|
||||
@ -1736,8 +1821,8 @@ png_init_read_transformations(png_structrp png_ptr)
|
||||
break;
|
||||
|
||||
case PNG_BACKGROUND_GAMMA_FILE:
|
||||
g = png_reciprocal(png_ptr->colorspace.gamma);
|
||||
gs = png_reciprocal2(png_ptr->colorspace.gamma,
|
||||
g = png_reciprocal(png_ptr->file_gamma);
|
||||
gs = png_reciprocal2(png_ptr->file_gamma,
|
||||
png_ptr->screen_gamma);
|
||||
break;
|
||||
|
||||
@ -1987,11 +2072,11 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
|
||||
* been called before this from png_read_update_info->png_read_start_row
|
||||
* sometimes does the gamma transform and cancels the flag.
|
||||
*
|
||||
* TODO: this looks wrong; the info_ptr should end up with a gamma equal to
|
||||
* the screen_gamma value. The following probably results in weirdness if
|
||||
* the info_ptr is used by the app after the rows have been read.
|
||||
* TODO: this is confusing. It only changes the result of png_get_gAMA and,
|
||||
* yes, it does return the value that the transformed data effectively has
|
||||
* but does any app really understand this?
|
||||
*/
|
||||
info_ptr->colorspace.gamma = png_ptr->colorspace.gamma;
|
||||
info_ptr->gamma = png_ptr->file_gamma;
|
||||
#endif
|
||||
|
||||
if (info_ptr->bit_depth == 16)
|
||||
|
1879
pngrutil.c
1879
pngrutil.c
File diff suppressed because it is too large
Load Diff
161
pngset.c
161
pngset.c
@ -41,27 +41,21 @@ png_set_cHRM_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y,
|
||||
png_fixed_point blue_x, png_fixed_point blue_y)
|
||||
{
|
||||
png_xy xy;
|
||||
|
||||
png_debug1(1, "in %s storage function", "cHRM fixed");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
xy.redx = red_x;
|
||||
xy.redy = red_y;
|
||||
xy.greenx = green_x;
|
||||
xy.greeny = green_y;
|
||||
xy.bluex = blue_x;
|
||||
xy.bluey = blue_y;
|
||||
xy.whitex = white_x;
|
||||
xy.whitey = white_y;
|
||||
info_ptr->cHRM.redx = red_x;
|
||||
info_ptr->cHRM.redy = red_y;
|
||||
info_ptr->cHRM.greenx = green_x;
|
||||
info_ptr->cHRM.greeny = green_y;
|
||||
info_ptr->cHRM.bluex = blue_x;
|
||||
info_ptr->cHRM.bluey = blue_y;
|
||||
info_ptr->cHRM.whitex = white_x;
|
||||
info_ptr->cHRM.whitey = white_y;
|
||||
|
||||
if (png_colorspace_set_chromaticities(png_ptr, &info_ptr->colorspace, &xy,
|
||||
2/* override with app values*/) != 0)
|
||||
info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM;
|
||||
|
||||
png_colorspace_sync_info(png_ptr, info_ptr);
|
||||
info_ptr->valid |= PNG_INFO_cHRM;
|
||||
}
|
||||
|
||||
void PNGFAPI
|
||||
@ -73,6 +67,7 @@ png_set_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_fixed_point int_blue_Z)
|
||||
{
|
||||
png_XYZ XYZ;
|
||||
png_xy xy;
|
||||
|
||||
png_debug1(1, "in %s storage function", "cHRM XYZ fixed");
|
||||
|
||||
@ -89,11 +84,14 @@ png_set_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
XYZ.blue_Y = int_blue_Y;
|
||||
XYZ.blue_Z = int_blue_Z;
|
||||
|
||||
if (png_colorspace_set_endpoints(png_ptr, &info_ptr->colorspace,
|
||||
&XYZ, 2) != 0)
|
||||
info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM;
|
||||
if (png_xy_from_XYZ(&xy, &XYZ) == 0)
|
||||
{
|
||||
info_ptr->cHRM = xy;
|
||||
info_ptr->valid |= PNG_INFO_cHRM;
|
||||
}
|
||||
|
||||
png_colorspace_sync_info(png_ptr, info_ptr);
|
||||
else
|
||||
png_app_error(png_ptr, "invalid cHRM XYZ");
|
||||
}
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
@ -205,8 +203,7 @@ png_set_cLLI(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
#ifdef PNG_mDCV_SUPPORTED
|
||||
static png_uint_16
|
||||
png_ITU_fixed_16(png_const_structrp png_ptr, png_fixed_point v,
|
||||
png_const_charp text)
|
||||
png_ITU_fixed_16(int *error, png_fixed_point v)
|
||||
{
|
||||
/* Return a safe uint16_t value scaled according to the ITU H273 rules for
|
||||
* 16-bit display chromaticities. Functions like the corresponding
|
||||
@ -216,11 +213,10 @@ png_ITU_fixed_16(png_const_structrp png_ptr, png_fixed_point v,
|
||||
*/
|
||||
v /= 2; /* rounds to 0 in C: avoids insignificant arithmetic errors */
|
||||
if (v > 65535 || v < 0)
|
||||
png_fixed_error(png_ptr, text);
|
||||
|
||||
# ifndef PNG_ERROR_TEXT_SUPPORTED
|
||||
PNG_UNUSED(text)
|
||||
# endif
|
||||
{
|
||||
*error = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return (png_uint_16)/*SAFE*/v;
|
||||
}
|
||||
@ -235,6 +231,7 @@ png_set_mDCV_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_uint_32 minDL)
|
||||
{
|
||||
png_uint_16 rx, ry, gx, gy, bx, by, wx, wy;
|
||||
int error;
|
||||
|
||||
png_debug1(1, "in %s storage function", "mDCV");
|
||||
|
||||
@ -242,14 +239,23 @@ png_set_mDCV_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
return;
|
||||
|
||||
/* Check the input values to ensure they are in the expected range: */
|
||||
rx = png_ITU_fixed_16(png_ptr, red_x, "png_set_mDCV(red(x))");
|
||||
ry = png_ITU_fixed_16(png_ptr, red_y, "png_set_mDCV(red(y))");
|
||||
gx = png_ITU_fixed_16(png_ptr, green_x, "png_set_mDCV(green(x))");
|
||||
gy = png_ITU_fixed_16(png_ptr, green_y, "png_set_mDCV(green(y))");
|
||||
bx = png_ITU_fixed_16(png_ptr, blue_x, "png_set_mDCV(blue(x))");
|
||||
by = png_ITU_fixed_16(png_ptr, blue_y, "png_set_mDCV(blue(y))");
|
||||
wx = png_ITU_fixed_16(png_ptr, white_x, "png_set_mDCV(white(x))");
|
||||
wy = png_ITU_fixed_16(png_ptr, white_y, "png_set_mDCV(white(y))");
|
||||
error = 0;
|
||||
rx = png_ITU_fixed_16(&error, red_x);
|
||||
ry = png_ITU_fixed_16(&error, red_y);
|
||||
gx = png_ITU_fixed_16(&error, green_x);
|
||||
gy = png_ITU_fixed_16(&error, green_y);
|
||||
bx = png_ITU_fixed_16(&error, blue_x);
|
||||
by = png_ITU_fixed_16(&error, blue_y);
|
||||
wx = png_ITU_fixed_16(&error, white_x);
|
||||
wy = png_ITU_fixed_16(&error, white_y);
|
||||
|
||||
if (error)
|
||||
{
|
||||
png_chunk_report(png_ptr,
|
||||
"mDCV chromaticities outside representable range",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Check the light level range: */
|
||||
if (maxDL > 0x7FFFFFFFU || minDL > 0x7FFFFFFFU)
|
||||
@ -294,17 +300,14 @@ png_set_mDCV(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
double maxDL, double minDL)
|
||||
{
|
||||
png_set_mDCV_fixed(png_ptr, info_ptr,
|
||||
/* The ITU approach is to scale by 50,000, not 100,000 so just divide
|
||||
* the input values by 2 and use png_fixed:
|
||||
*/
|
||||
png_fixed(png_ptr, white_x / 2, "png_set_mDCV(white(x))"),
|
||||
png_fixed(png_ptr, white_y / 2, "png_set_mDCV(white(y))"),
|
||||
png_fixed(png_ptr, red_x / 2, "png_set_mDCV(red(x))"),
|
||||
png_fixed(png_ptr, red_y / 2, "png_set_mDCV(red(y))"),
|
||||
png_fixed(png_ptr, green_x / 2, "png_set_mDCV(green(x))"),
|
||||
png_fixed(png_ptr, green_y / 2, "png_set_mDCV(green(y))"),
|
||||
png_fixed(png_ptr, blue_x / 2, "png_set_mDCV(blue(x))"),
|
||||
png_fixed(png_ptr, blue_y / 2, "png_set_mDCV(blue(y))"),
|
||||
png_fixed(png_ptr, white_x, "png_set_mDCV(white(x))"),
|
||||
png_fixed(png_ptr, white_y, "png_set_mDCV(white(y))"),
|
||||
png_fixed(png_ptr, red_x, "png_set_mDCV(red(x))"),
|
||||
png_fixed(png_ptr, red_y, "png_set_mDCV(red(y))"),
|
||||
png_fixed(png_ptr, green_x, "png_set_mDCV(green(x))"),
|
||||
png_fixed(png_ptr, green_y, "png_set_mDCV(green(y))"),
|
||||
png_fixed(png_ptr, blue_x, "png_set_mDCV(blue(x))"),
|
||||
png_fixed(png_ptr, blue_y, "png_set_mDCV(blue(y))"),
|
||||
png_fixed_ITU(png_ptr, maxDL, "png_set_mDCV(maxDL)"),
|
||||
png_fixed_ITU(png_ptr, minDL, "png_set_mDCV(minDL)"));
|
||||
}
|
||||
@ -362,8 +365,8 @@ png_set_gAMA_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_colorspace_set_gamma(png_ptr, &info_ptr->colorspace, file_gamma);
|
||||
png_colorspace_sync_info(png_ptr, info_ptr);
|
||||
info_ptr->gamma = file_gamma;
|
||||
info_ptr->valid |= PNG_INFO_gAMA;
|
||||
}
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
@ -822,8 +825,8 @@ png_set_sRGB(png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent)
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
(void)png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace, srgb_intent);
|
||||
png_colorspace_sync_info(png_ptr, info_ptr);
|
||||
info_ptr->rendering_intent = srgb_intent;
|
||||
info_ptr->valid |= PNG_INFO_sRGB;
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
@ -835,15 +838,20 @@ png_set_sRGB_gAMA_and_cHRM(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace,
|
||||
srgb_intent) != 0)
|
||||
{
|
||||
/* This causes the gAMA and cHRM to be written too */
|
||||
info_ptr->colorspace.flags |=
|
||||
PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM;
|
||||
}
|
||||
png_set_sRGB(png_ptr, info_ptr, srgb_intent);
|
||||
|
||||
png_colorspace_sync_info(png_ptr, info_ptr);
|
||||
# ifdef PNG_gAMA_SUPPORTED
|
||||
png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_sRGB_INVERSE);
|
||||
# endif /* gAMA */
|
||||
|
||||
# ifdef PNG_cHRM_SUPPORTED
|
||||
png_set_cHRM_fixed(png_ptr, info_ptr,
|
||||
/* color x y */
|
||||
/* white */ 31270, 32900,
|
||||
/* red */ 64000, 33000,
|
||||
/* green */ 30000, 60000,
|
||||
/* blue */ 15000, 6000);
|
||||
# endif /* cHRM */
|
||||
}
|
||||
#endif /* sRGB */
|
||||
|
||||
@ -866,27 +874,6 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
if (compression_type != PNG_COMPRESSION_TYPE_BASE)
|
||||
png_app_error(png_ptr, "Invalid iCCP compression method");
|
||||
|
||||
/* Set the colorspace first because this validates the profile; do not
|
||||
* override previously set app cHRM or gAMA here (because likely as not the
|
||||
* application knows better than libpng what the correct values are.) Pass
|
||||
* the info_ptr color_type field to png_colorspace_set_ICC because in the
|
||||
* write case it has not yet been stored in png_ptr.
|
||||
*/
|
||||
{
|
||||
int result = png_colorspace_set_ICC(png_ptr, &info_ptr->colorspace, name,
|
||||
proflen, profile, info_ptr->color_type);
|
||||
|
||||
png_colorspace_sync_info(png_ptr, info_ptr);
|
||||
|
||||
/* Don't do any of the copying if the profile was bad, or inconsistent. */
|
||||
if (result == 0)
|
||||
return;
|
||||
|
||||
/* But do write the gAMA and cHRM chunks from the profile. */
|
||||
info_ptr->colorspace.flags |=
|
||||
PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM;
|
||||
}
|
||||
|
||||
length = strlen(name)+1;
|
||||
new_iccp_name = png_voidcast(png_charp, png_malloc_warn(png_ptr, length));
|
||||
|
||||
@ -1841,8 +1828,24 @@ png_set_chunk_malloc_max(png_structrp png_ptr,
|
||||
{
|
||||
png_debug(1, "in png_set_chunk_malloc_max");
|
||||
|
||||
/* pngstruct::user_chunk_malloc_max is initialized to a non-zero value in
|
||||
* png.c. This API supports '0' for unlimited, make sure the correct
|
||||
* (unlimited) value is set here to avoid a need to check for 0 everywhere
|
||||
* the parameter is used.
|
||||
*/
|
||||
if (png_ptr != NULL)
|
||||
png_ptr->user_chunk_malloc_max = user_chunk_malloc_max;
|
||||
{
|
||||
if (user_chunk_malloc_max == 0U) /* unlimited */
|
||||
{
|
||||
# ifdef PNG_MAX_MALLOC_64K
|
||||
png_ptr->user_chunk_malloc_max = 65536U;
|
||||
# else
|
||||
png_ptr->user_chunk_malloc_max = PNG_SIZE_MAX;
|
||||
# endif
|
||||
}
|
||||
else
|
||||
png_ptr->user_chunk_malloc_max = user_chunk_malloc_max;
|
||||
}
|
||||
}
|
||||
#endif /* ?SET_USER_LIMITS */
|
||||
|
||||
|
111
pngstruct.h
111
pngstruct.h
@ -1,6 +1,6 @@
|
||||
/* pngstruct.h - header file for PNG reference library
|
||||
/* pngstruct.h - internal structures for libpng
|
||||
*
|
||||
* Copyright (c) 2018-2022 Cosmin Truta
|
||||
* Copyright (c) 2018-2025 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -10,11 +10,9 @@
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
/* The structure that holds the information to read and write PNG files.
|
||||
* The only people who need to care about what is inside of this are the
|
||||
* people who will be modifying the library for their own special needs.
|
||||
* It should NOT be accessed directly by an application.
|
||||
*/
|
||||
#ifndef PNGPRIV_H
|
||||
# error This file must not be included by applications; please include <png.h>
|
||||
#endif
|
||||
|
||||
#ifndef PNGSTRUCT_H
|
||||
#define PNGSTRUCT_H
|
||||
@ -69,13 +67,7 @@ typedef struct png_compression_buffer
|
||||
|
||||
/* Colorspace support; structures used in png_struct, png_info and in internal
|
||||
* functions to hold and communicate information about the color space.
|
||||
*
|
||||
* PNG_COLORSPACE_SUPPORTED is only required if the application will perform
|
||||
* colorspace corrections, otherwise all the colorspace information can be
|
||||
* skipped and the size of libpng can be reduced (significantly) by compiling
|
||||
* out the colorspace support.
|
||||
*/
|
||||
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||
/* The chromaticities of the red, green and blue colorants and the chromaticity
|
||||
* of the corresponding white point (i.e. of rgb(1.0,1.0,1.0)).
|
||||
*/
|
||||
@ -96,48 +88,36 @@ typedef struct png_XYZ
|
||||
png_fixed_point green_X, green_Y, green_Z;
|
||||
png_fixed_point blue_X, blue_Y, blue_Z;
|
||||
} png_XYZ;
|
||||
#endif /* COLORSPACE */
|
||||
|
||||
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||
/* A colorspace is all the above plus, potentially, profile information;
|
||||
* however at present libpng does not use the profile internally so it is only
|
||||
* stored in the png_info struct (if iCCP is supported.) The rendering intent
|
||||
* is retained here and is checked.
|
||||
*
|
||||
* The file gamma encoding information is also stored here and gamma correction
|
||||
* is done by libpng, whereas color correction must currently be done by the
|
||||
* application.
|
||||
/* Chunk index values as an enum, PNG_INDEX_unknown is also a count of the
|
||||
* number of chunks.
|
||||
*/
|
||||
typedef struct png_colorspace
|
||||
#define PNG_CHUNK(cHNK, i) PNG_INDEX_ ## cHNK = (i),
|
||||
typedef enum
|
||||
{
|
||||
#ifdef PNG_GAMMA_SUPPORTED
|
||||
png_fixed_point gamma; /* File gamma */
|
||||
#endif
|
||||
PNG_KNOWN_CHUNKS
|
||||
PNG_INDEX_unknown
|
||||
} png_index;
|
||||
#undef PNG_CHUNK
|
||||
|
||||
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||
png_xy end_points_xy; /* End points as chromaticities */
|
||||
png_XYZ end_points_XYZ; /* End points as CIE XYZ colorant values */
|
||||
png_uint_16 rendering_intent; /* Rendering intent of a profile */
|
||||
#endif
|
||||
/* Chunk flag values. These are (png_uint_32 values) with exactly one bit set
|
||||
* and can be combined into a flag set with bitwise 'or'.
|
||||
*
|
||||
* TODO: C23: convert these macros to C23 inlines (which are static).
|
||||
*/
|
||||
#define png_chunk_flag_from_index(i) (0x80000000U >> (31 - (i)))
|
||||
/* The flag coresponding to the given png_index enum value. This is defined
|
||||
* for png_unknown as well (until it reaches the value 32) but this should
|
||||
* not be relied on.
|
||||
*/
|
||||
|
||||
/* Flags are always defined to simplify the code. */
|
||||
png_uint_16 flags; /* As defined below */
|
||||
} png_colorspace, * PNG_RESTRICT png_colorspacerp;
|
||||
#define png_file_has_chunk(png_ptr, i)\
|
||||
(((png_ptr)->chunks & png_chunk_flag_from_index(i)) != 0)
|
||||
/* The chunk has been recorded in png_struct */
|
||||
|
||||
typedef const png_colorspace * PNG_RESTRICT png_const_colorspacerp;
|
||||
|
||||
/* General flags for the 'flags' field */
|
||||
#define PNG_COLORSPACE_HAVE_GAMMA 0x0001
|
||||
#define PNG_COLORSPACE_HAVE_ENDPOINTS 0x0002
|
||||
#define PNG_COLORSPACE_HAVE_INTENT 0x0004
|
||||
#define PNG_COLORSPACE_FROM_gAMA 0x0008
|
||||
#define PNG_COLORSPACE_FROM_cHRM 0x0010
|
||||
#define PNG_COLORSPACE_FROM_sRGB 0x0020
|
||||
#define PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB 0x0040
|
||||
#define PNG_COLORSPACE_MATCHES_sRGB 0x0080 /* exact match on profile */
|
||||
#define PNG_COLORSPACE_INVALID 0x8000
|
||||
#define PNG_COLORSPACE_CANCEL(flags) (0xffff ^ (flags))
|
||||
#endif /* COLORSPACE || GAMMA */
|
||||
#define png_file_add_chunk(pnt_ptr, i)\
|
||||
((void)((png_ptr)->chunks |= png_chunk_flag_from_index(i)))
|
||||
/* Record the chunk in the png_struct */
|
||||
|
||||
struct png_struct_def
|
||||
{
|
||||
@ -209,6 +189,11 @@ struct png_struct_def
|
||||
int zlib_set_strategy;
|
||||
#endif
|
||||
|
||||
png_uint_32 chunks; /* PNG_CF_ for every chunk read or (NYI) written */
|
||||
# define png_has_chunk(png_ptr, cHNK)\
|
||||
png_file_has_chunk(png_ptr, PNG_INDEX_ ## cHNK)
|
||||
/* Convenience accessor - use this to check for a known chunk by name */
|
||||
|
||||
png_uint_32 width; /* width of image in pixels */
|
||||
png_uint_32 height; /* height of image in pixels */
|
||||
png_uint_32 num_rows; /* number of rows in current pass */
|
||||
@ -285,9 +270,16 @@ struct png_struct_def
|
||||
png_uint_32 flush_rows; /* number of rows written since last flush */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
png_xy chromaticities; /* From mDVC, cICP, [iCCP], sRGB or cHRM */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */
|
||||
png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */
|
||||
png_fixed_point screen_gamma; /* screen gamma value (display exponent) */
|
||||
png_fixed_point file_gamma; /* file gamma value (encoding exponent) */
|
||||
png_fixed_point chunk_gamma; /* from cICP, iCCP, sRGB or gAMA */
|
||||
png_fixed_point default_gamma;/* from png_set_alpha_mode */
|
||||
|
||||
png_bytep gamma_table; /* gamma table for 8-bit depth files */
|
||||
png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
|
||||
@ -299,7 +291,7 @@ struct png_struct_def
|
||||
png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
|
||||
png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
|
||||
#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
|
||||
#endif
|
||||
#endif /* READ_GAMMA */
|
||||
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)
|
||||
png_color_8 sig_bit; /* significant bits in each available channel */
|
||||
@ -349,8 +341,8 @@ struct png_struct_def
|
||||
/* To do: remove this from libpng-1.7 */
|
||||
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
||||
char time_buffer[29]; /* String to hold RFC 1123 time text */
|
||||
#endif
|
||||
#endif
|
||||
#endif /* TIME_RFC1123 */
|
||||
#endif /* LIBPNG_VER < 10700 */
|
||||
|
||||
/* New members added in libpng-1.0.6 */
|
||||
|
||||
@ -360,8 +352,8 @@ struct png_struct_def
|
||||
png_voidp user_chunk_ptr;
|
||||
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
|
||||
#endif
|
||||
#endif
|
||||
#endif /* READ_USER_CHUNKS */
|
||||
#endif /* USER_CHUNKS */
|
||||
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
int unknown_default; /* As PNG_HANDLE_* */
|
||||
@ -383,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
|
||||
|
||||
@ -468,11 +461,5 @@ struct png_struct_def
|
||||
/* New member added in libpng-1.5.7 */
|
||||
void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,
|
||||
png_bytep row, png_const_bytep prev_row);
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||
png_colorspace colorspace;
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
#endif /* PNGSTRUCT_H */
|
||||
|
20
pngtest.c
20
pngtest.c
@ -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_46 Your_png_h_is_not_version_1_6_46;
|
||||
typedef png_libpng_version_1_6_51_git Your_png_h_is_not_version_1_6_51_git;
|
||||
|
||||
/* Ensure that all version numbers in png.h are consistent with one another. */
|
||||
#if (PNG_LIBPNG_VER != PNG_LIBPNG_VER_MAJOR * 10000 + \
|
||||
@ -60,7 +60,7 @@ typedef png_libpng_version_1_6_46 Your_png_h_is_not_version_1_6_46;
|
||||
PNG_LIBPNG_VER_MINOR) || \
|
||||
(PNG_LIBPNG_VER_SHAREDLIB != PNG_LIBPNG_VER_SONUM) || \
|
||||
(PNG_LIBPNG_VER_SHAREDLIB != PNG_LIBPNG_VER_DLLNUM)
|
||||
# error "Inconsistent version numbers in png.h"
|
||||
# error Inconsistent version numbers in "png.h"
|
||||
#endif
|
||||
|
||||
/* In version 1.6.1, we added support for the configure test harness, which
|
||||
@ -103,10 +103,6 @@ typedef png_libpng_version_1_6_46 Your_png_h_is_not_version_1_6_46;
|
||||
# define PNG_ZBUF_SIZE 8192
|
||||
#endif
|
||||
|
||||
#ifndef PNG_STDIO_SUPPORTED
|
||||
typedef FILE * png_FILE_p;
|
||||
#endif
|
||||
|
||||
#ifndef PNG_DEBUG
|
||||
# define PNG_DEBUG 0
|
||||
#endif
|
||||
@ -120,7 +116,7 @@ typedef FILE * png_FILE_p;
|
||||
# define pngtest_debug1(m, p1) ((void)0)
|
||||
# define pngtest_debug2(m, p1, p2) ((void)0)
|
||||
#else /* PNG_DEBUG < 0 */
|
||||
# error "Bad PNG_DEBUG value"
|
||||
# error Bad PNG_DEBUG value
|
||||
#endif
|
||||
|
||||
/* Turn on CPU timing
|
||||
@ -403,7 +399,7 @@ pngtest_read_data(png_structp png_ptr, png_bytep data, size_t length)
|
||||
*/
|
||||
io_ptr = png_get_io_ptr(png_ptr);
|
||||
if (io_ptr != NULL)
|
||||
check = fread(data, 1, length, (png_FILE_p)io_ptr);
|
||||
check = fread(data, 1, length, (FILE *)io_ptr);
|
||||
|
||||
if (check != length)
|
||||
png_error(png_ptr, "Read Error");
|
||||
@ -437,7 +433,7 @@ pngtest_write_data(png_structp png_ptr, png_bytep data, size_t length)
|
||||
if (png_ptr == NULL)
|
||||
png_error(png_ptr, "pngtest_write_data: bad png_ptr");
|
||||
|
||||
check = fwrite(data, 1, length, (png_FILE_p)png_get_io_ptr(png_ptr));
|
||||
check = fwrite(data, 1, length, (FILE *)png_get_io_ptr(png_ptr));
|
||||
|
||||
if (check != length)
|
||||
png_error(png_ptr, "Write Error");
|
||||
@ -858,8 +854,8 @@ pngtest_check_text_support(png_structp png_ptr, png_textp text_ptr,
|
||||
static int
|
||||
test_one_file(const char *inname, const char *outname)
|
||||
{
|
||||
static png_FILE_p fpin;
|
||||
static png_FILE_p fpout; /* "static" prevents setjmp corruption */
|
||||
static FILE *fpin;
|
||||
static FILE *fpout; /* "static" prevents setjmp corruption */
|
||||
pngtest_error_parameters error_parameters;
|
||||
png_structp read_ptr;
|
||||
png_infop read_info_ptr, end_info_ptr;
|
||||
@ -2137,6 +2133,7 @@ main(int argc, char *argv[])
|
||||
fprintf(STDERR, " libpng FAILS test\n");
|
||||
|
||||
dummy_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
||||
#ifdef PNG_USER_LIMITS_SUPPORTED
|
||||
fprintf(STDERR, " Default limits:\n");
|
||||
fprintf(STDERR, " width_max = %lu\n",
|
||||
(unsigned long) png_get_user_width_max(dummy_ptr));
|
||||
@ -2152,6 +2149,7 @@ main(int argc, char *argv[])
|
||||
else
|
||||
fprintf(STDERR, " malloc_max = %lu\n",
|
||||
(unsigned long) png_get_chunk_malloc_max(dummy_ptr));
|
||||
#endif
|
||||
png_destroy_read_struct(&dummy_ptr, NULL, NULL);
|
||||
|
||||
return (ierror != 0);
|
||||
|
8
pngwio.c
8
pngwio.c
@ -1,6 +1,6 @@
|
||||
/* pngwio.c - functions for data output
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2018-2025 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2014,2016,2018 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -54,7 +54,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, size_t length)
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr));
|
||||
check = fwrite(data, 1, length, (FILE *)png_ptr->io_ptr);
|
||||
|
||||
if (check != length)
|
||||
png_error(png_ptr, "Write Error");
|
||||
@ -77,12 +77,12 @@ png_flush(png_structrp png_ptr)
|
||||
void PNGCBAPI
|
||||
png_default_flush(png_structp png_ptr)
|
||||
{
|
||||
png_FILE_p io_ptr;
|
||||
FILE *io_ptr;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
io_ptr = png_voidcast(png_FILE_p, (png_ptr->io_ptr));
|
||||
io_ptr = png_voidcast(FILE *, png_ptr->io_ptr);
|
||||
fflush(io_ptr);
|
||||
}
|
||||
# endif
|
||||
|
41
pngwrite.c
41
pngwrite.c
@ -181,7 +181,6 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||
# ifdef PNG_WRITE_cICP_SUPPORTED /* Priority 4 */
|
||||
if ((info_ptr->valid & PNG_INFO_cICP) != 0)
|
||||
{
|
||||
@ -193,50 +192,28 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||
}
|
||||
# endif
|
||||
|
||||
/* PNG v3 change: it is now permitted to write both sRGB and ICC profiles,
|
||||
* however because the libpng code auto-generates an sRGB for the
|
||||
* corresponding ICC profiles and because PNG v2 disallowed this we need
|
||||
* to only write one.
|
||||
*
|
||||
* Remove the PNG v2 warning about writing an sRGB ICC profile as well
|
||||
* because it's invalid with PNG v3.
|
||||
*/
|
||||
# ifdef PNG_WRITE_iCCP_SUPPORTED /* Priority 3 */
|
||||
if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
|
||||
(info_ptr->valid & PNG_INFO_iCCP) != 0)
|
||||
if ((info_ptr->valid & PNG_INFO_iCCP) != 0)
|
||||
{
|
||||
png_write_iCCP(png_ptr, info_ptr->iccp_name,
|
||||
info_ptr->iccp_profile);
|
||||
info_ptr->iccp_profile, info_ptr->iccp_proflen);
|
||||
}
|
||||
# ifdef PNG_WRITE_sRGB_SUPPORTED
|
||||
else
|
||||
# endif
|
||||
# endif
|
||||
|
||||
# ifdef PNG_WRITE_sRGB_SUPPORTED /* Priority 2 */
|
||||
if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
|
||||
(info_ptr->valid & PNG_INFO_sRGB) != 0)
|
||||
png_write_sRGB(png_ptr, info_ptr->colorspace.rendering_intent);
|
||||
if ((info_ptr->valid & PNG_INFO_sRGB) != 0)
|
||||
png_write_sRGB(png_ptr, info_ptr->rendering_intent);
|
||||
# endif /* WRITE_sRGB */
|
||||
#endif /* COLORSPACE */
|
||||
|
||||
#ifdef PNG_GAMMA_SUPPORTED
|
||||
# ifdef PNG_WRITE_gAMA_SUPPORTED /* Priority 1 */
|
||||
if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_gAMA) != 0 &&
|
||||
(info_ptr->valid & PNG_INFO_gAMA) != 0)
|
||||
png_write_gAMA_fixed(png_ptr, info_ptr->colorspace.gamma);
|
||||
if ((info_ptr->valid & PNG_INFO_gAMA) != 0)
|
||||
png_write_gAMA_fixed(png_ptr, info_ptr->gamma);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||
# ifdef PNG_WRITE_cHRM_SUPPORTED /* Also priority 1 */
|
||||
if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) != 0 &&
|
||||
(info_ptr->valid & PNG_INFO_cHRM) != 0)
|
||||
png_write_cHRM_fixed(png_ptr, &info_ptr->colorspace.end_points_xy);
|
||||
if ((info_ptr->valid & PNG_INFO_cHRM) != 0)
|
||||
png_write_cHRM_fixed(png_ptr, &info_ptr->cHRM);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE;
|
||||
}
|
||||
@ -2356,7 +2333,7 @@ int PNGAPI
|
||||
png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,
|
||||
const void *buffer, png_int_32 row_stride, const void *colormap)
|
||||
{
|
||||
/* Write the image to the given (FILE*). */
|
||||
/* Write the image to the given FILE object. */
|
||||
if (image != NULL && image->version == PNG_IMAGE_VERSION)
|
||||
{
|
||||
if (file != NULL && buffer != NULL)
|
||||
|
10
pngwutil.c
10
pngwutil.c
@ -1,6 +1,6 @@
|
||||
/* pngwutil.c - utilities to write a PNG file
|
||||
*
|
||||
* Copyright (c) 2018-2024 Cosmin Truta
|
||||
* Copyright (c) 2018-2025 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -1132,10 +1132,9 @@ png_write_sRGB(png_structrp png_ptr, int srgb_intent)
|
||||
/* Write an iCCP chunk */
|
||||
void /* PRIVATE */
|
||||
png_write_iCCP(png_structrp png_ptr, png_const_charp name,
|
||||
png_const_bytep profile)
|
||||
png_const_bytep profile, png_uint_32 profile_len)
|
||||
{
|
||||
png_uint_32 name_len;
|
||||
png_uint_32 profile_len;
|
||||
png_byte new_name[81]; /* 1 byte for the compression byte */
|
||||
compression_state comp;
|
||||
png_uint_32 temp;
|
||||
@ -1148,11 +1147,12 @@ png_write_iCCP(png_structrp png_ptr, png_const_charp name,
|
||||
if (profile == NULL)
|
||||
png_error(png_ptr, "No profile for iCCP chunk"); /* internal error */
|
||||
|
||||
profile_len = png_get_uint_32(profile);
|
||||
|
||||
if (profile_len < 132)
|
||||
png_error(png_ptr, "ICC profile too short");
|
||||
|
||||
if (png_get_uint_32(profile) != profile_len)
|
||||
png_error(png_ptr, "Incorrect data in iCCP");
|
||||
|
||||
temp = (png_uint_32) (*(profile+8));
|
||||
if (temp > 3 && (profile_len & 0x03))
|
||||
png_error(png_ptr, "ICC profile length invalid (not a multiple of 4)");
|
||||
|
@ -23,7 +23,7 @@
|
||||
#if PNG_POWERPC_VSX_OPT > 0
|
||||
|
||||
#ifndef __VSX__
|
||||
# error "This code requires VSX support (POWER7 and later). Please provide -mvsx compiler flag."
|
||||
# error This code requires VSX support (POWER7 and later); please compile with -mvsx
|
||||
#endif
|
||||
|
||||
#define vec_ld_unaligned(vec,data) vec = vec_vsx_ld(0,data)
|
||||
|
@ -46,7 +46,7 @@ static int png_have_vsx(png_structp png_ptr);
|
||||
#include PNG_POWERPC_VSX_FILE
|
||||
|
||||
#else /* PNG_POWERPC_VSX_FILE */
|
||||
# error "PNG_POWERPC_VSX_FILE undefined: no support for run-time POWERPC VSX checks"
|
||||
# error PNG_POWERPC_VSX_FILE undefined: no support for run-time POWERPC VSX checks
|
||||
#endif /* PNG_POWERPC_VSX_FILE */
|
||||
#endif /* PNG_POWERPC_VSX_CHECK_SUPPORTED */
|
||||
|
||||
|
@ -66,7 +66,7 @@
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..;..\..\..\zlib"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;DEBUG;PNG_DEBUG=1;PNG_BUILD_DLL;ZLIB_DLL;_CRT_SECURE_NO_WARNINGS"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;DEBUG;PNG_BUILD_DLL;ZLIB_DLL;_CRT_SECURE_NO_WARNINGS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="3"
|
||||
@ -91,7 +91,7 @@
|
||||
Name="VCPreLinkEventTool"/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
PreprocessorDefinitions="_DEBUG,PNG_DEBUG=1"
|
||||
PreprocessorDefinitions="_DEBUG"
|
||||
Culture="1033"
|
||||
AdditionalIncludeDirectories="..\..;..\..\..\zlib;$(IntDir)"/>
|
||||
<Tool
|
||||
@ -205,7 +205,7 @@
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\..;..\..\..\zlib"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;DEBUG;PNG_DEBUG=1;_CRT_SECURE_NO_WARNINGS"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;DEBUG;_CRT_SECURE_NO_WARNINGS"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="3"
|
||||
|
8
riscv/.editorconfig
Normal file
8
riscv/.editorconfig
Normal file
@ -0,0 +1,8 @@
|
||||
# https://editorconfig.org
|
||||
|
||||
root = false
|
||||
|
||||
# FIXME
|
||||
[*.[ch]]
|
||||
max_doc_length = unset
|
||||
max_line_length = unset
|
350
riscv/filter_rvv_intrinsics.c
Normal file
350
riscv/filter_rvv_intrinsics.c
Normal file
@ -0,0 +1,350 @@
|
||||
/* 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)
|
||||
*/
|
||||
|
||||
size_t vl = __riscv_vsetvl_e8m1(bpp);
|
||||
|
||||
/* a = *row */
|
||||
vuint8m1_t a = __riscv_vle8_v_u8m1(row, vl);
|
||||
row += bpp;
|
||||
|
||||
while (row < rp_end)
|
||||
{
|
||||
/* x = *row */
|
||||
vuint8m1_t x = __riscv_vle8_v_u8m1(row, vl);
|
||||
|
||||
/* a = a + x */
|
||||
a = __riscv_vadd_vv_u8m1(a, x, vl);
|
||||
|
||||
/* *row = a */
|
||||
__riscv_vse8_v_u8m1(row, a, vl);
|
||||
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 */
|
||||
|
||||
size_t vl = __riscv_vsetvl_e8m1(bpp);
|
||||
|
||||
/* b = *prev_row */
|
||||
vuint8m1_t b = __riscv_vle8_v_u8m1(prev_row, vl);
|
||||
prev_row += bpp;
|
||||
|
||||
/* x = *row */
|
||||
vuint8m1_t x = __riscv_vle8_v_u8m1(row, vl);
|
||||
|
||||
/* b = b / 2 */
|
||||
b = __riscv_vsrl_vx_u8m1(b, 1, vl);
|
||||
|
||||
/* a = x + b */
|
||||
vuint8m1_t a = __riscv_vadd_vv_u8m1(b, x, vl);
|
||||
|
||||
/* *row = a */
|
||||
__riscv_vse8_v_u8m1(row, a, vl);
|
||||
row += bpp;
|
||||
|
||||
/* remaining pixels */
|
||||
while (row < rp_end)
|
||||
{
|
||||
/* b = *prev_row */
|
||||
b = __riscv_vle8_v_u8m1(prev_row, vl);
|
||||
prev_row += bpp;
|
||||
|
||||
/* x = *row */
|
||||
x = __riscv_vle8_v_u8m1(row, vl);
|
||||
|
||||
/* tmp = a + b */
|
||||
vuint16m2_t tmp = __riscv_vwaddu_vv_u16m2(a, b, vl);
|
||||
|
||||
/* a = tmp/2 */
|
||||
a = __riscv_vnsrl_wx_u8m1(tmp, 1, vl);
|
||||
|
||||
/* a += x */
|
||||
a = __riscv_vadd_vv_u8m1(a, x, vl);
|
||||
|
||||
/* *row = a */
|
||||
__riscv_vse8_v_u8m1(row, a, vl);
|
||||
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));
|
||||
vbool16_t mask = __riscv_vmslt_vx_i16m1_b16(diff, 0, vl);
|
||||
return __riscv_vrsub_vx_i16m1_m(mask, diff, 0, vl);
|
||||
}
|
||||
|
||||
static inline vint16m1_t
|
||||
abs_sum(vint16m1_t a, vint16m1_t b, size_t vl)
|
||||
{
|
||||
return __riscv_vadd_vv_i16m1(a, b, 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 |
|
||||
*
|
||||
* a .. [v2](e8)
|
||||
* b .. [v4](e8)
|
||||
* c .. [v6](e8)
|
||||
* x .. [v8](e8)
|
||||
* p .. [v12-v13](e16)
|
||||
* pa, pb, pc .. [v16-v17, v20-v21, v24-v25](e16)
|
||||
*/
|
||||
|
||||
/* first pixel */
|
||||
|
||||
size_t vl = __riscv_vsetvl_e8m1(bpp);
|
||||
|
||||
/* a = *row */
|
||||
vuint8m1_t a = __riscv_vle8_v_u8m1(row, vl);
|
||||
|
||||
/* c = *prev */
|
||||
vuint8m1_t c = __riscv_vle8_v_u8m1(prev, vl);
|
||||
|
||||
/* a += c */
|
||||
a = __riscv_vadd_vv_u8m1(a, c, vl);
|
||||
|
||||
/* *row = a */
|
||||
__riscv_vse8_v_u8m1(row, a, vl);
|
||||
row += bpp;
|
||||
prev += bpp;
|
||||
|
||||
/* remaining pixels */
|
||||
|
||||
while (row < rp_end)
|
||||
{
|
||||
/* b = *prev */
|
||||
vuint8m1_t b = __riscv_vle8_v_u8m1(prev, vl);
|
||||
prev += bpp;
|
||||
|
||||
/* x = *row */
|
||||
vuint8m1_t x = __riscv_vle8_v_u8m1(row, vl);
|
||||
|
||||
/* Calculate p = b - c and pc = a - c using widening subtraction */
|
||||
vuint16m2_t p_wide = __riscv_vwsubu_vv_u16m2(b, c, vl);
|
||||
vuint16m2_t pc_wide = __riscv_vwsubu_vv_u16m2(a, c, vl);
|
||||
|
||||
/* Convert to signed for easier manipulation */
|
||||
size_t vl16 = __riscv_vsetvl_e16m2(bpp);
|
||||
vint16m2_t p = __riscv_vreinterpret_v_u16m2_i16m2(p_wide);
|
||||
vint16m2_t pc = __riscv_vreinterpret_v_u16m2_i16m2(pc_wide);
|
||||
|
||||
/* pa = |p| */
|
||||
vbool8_t p_neg_mask = __riscv_vmslt_vx_i16m2_b8(p, 0, vl16);
|
||||
vint16m2_t pa = __riscv_vrsub_vx_i16m2_m(p_neg_mask, p, 0, vl16);
|
||||
|
||||
/* pb = |pc| */
|
||||
vbool8_t pc_neg_mask = __riscv_vmslt_vx_i16m2_b8(pc, 0, vl16);
|
||||
vint16m2_t pb = __riscv_vrsub_vx_i16m2_m(pc_neg_mask, pc, 0, vl16);
|
||||
|
||||
/* pc = |p + pc| */
|
||||
vint16m2_t p_plus_pc = __riscv_vadd_vv_i16m2(p, pc, vl16);
|
||||
vbool8_t p_plus_pc_neg_mask = __riscv_vmslt_vx_i16m2_b8(p_plus_pc, 0, vl16);
|
||||
pc = __riscv_vrsub_vx_i16m2_m(p_plus_pc_neg_mask, p_plus_pc, 0, vl16);
|
||||
|
||||
/*
|
||||
* The key insight is that we want the minimum of pa, pb, pc.
|
||||
* - If pa <= pb and pa <= pc, use a
|
||||
* - Else if pb <= pc, use b
|
||||
* - Else use c
|
||||
*/
|
||||
|
||||
/* Find which predictor to use based on minimum absolute difference */
|
||||
vbool8_t pa_le_pb = __riscv_vmsle_vv_i16m2_b8(pa, pb, vl16);
|
||||
vbool8_t pa_le_pc = __riscv_vmsle_vv_i16m2_b8(pa, pc, vl16);
|
||||
vbool8_t pb_le_pc = __riscv_vmsle_vv_i16m2_b8(pb, pc, vl16);
|
||||
|
||||
/* use_a = pa <= pb && pa <= pc */
|
||||
vbool8_t use_a = __riscv_vmand_mm_b8(pa_le_pb, pa_le_pc, vl16);
|
||||
|
||||
/* use_b = !use_a && pb <= pc */
|
||||
vbool8_t not_use_a = __riscv_vmnot_m_b8(use_a, vl16);
|
||||
vbool8_t use_b = __riscv_vmand_mm_b8(not_use_a, pb_le_pc, vl16);
|
||||
|
||||
/* Switch back to e8m1 for final operations */
|
||||
vl = __riscv_vsetvl_e8m1(bpp);
|
||||
|
||||
/* Start with a, then conditionally replace with b or c */
|
||||
vuint8m1_t result = a;
|
||||
result = __riscv_vmerge_vvm_u8m1(result, b, use_b, vl);
|
||||
|
||||
/* use_c = !use_a && !use_b */
|
||||
vbool8_t use_c = __riscv_vmnand_mm_b8(__riscv_vmor_mm_b8(use_a, use_b, vl), __riscv_vmor_mm_b8(use_a, use_b, vl), vl);
|
||||
result = __riscv_vmerge_vvm_u8m1(result, c, use_c, vl);
|
||||
|
||||
/* a = result + x */
|
||||
a = __riscv_vadd_vv_u8m1(result, x, vl);
|
||||
|
||||
/* *row = a */
|
||||
__riscv_vse8_v_u8m1(row, a, vl);
|
||||
row += bpp;
|
||||
|
||||
/* c = b for next iteration */
|
||||
c = b;
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
#endif /* PNG_RISCV_RVV_IMPLEMENTATION == 1 */
|
||||
#endif /* PNG_READ_SUPPORTED */
|
68
riscv/riscv_init.c
Normal file
68
riscv/riscv_init.c
Normal file
@ -0,0 +1,68 @@
|
||||
/* 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>
|
||||
|
||||
#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();
|
||||
#ifdef PNG_RISCV_RVV_FILE
|
||||
# include PNG_RISCV_RVV_FILE
|
||||
#endif
|
||||
|
||||
#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)
|
||||
{
|
||||
png_debug(1, "in png_init_filter_functions_rvv");
|
||||
|
||||
static volatile sig_atomic_t no_rvv = -1; /* not checked */
|
||||
|
||||
if (no_rvv < 0)
|
||||
no_rvv = !png_have_rvv();
|
||||
|
||||
if (no_rvv)
|
||||
return;
|
||||
|
||||
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 */
|
@ -29,6 +29,7 @@ Author List
|
||||
* Jeremy Maitin-Shepard
|
||||
* John Bowler
|
||||
* Jon Creighton
|
||||
* Joost Nieuwenhuijse
|
||||
* Kyle Bentley
|
||||
* Martin Storsjö
|
||||
* Owen Rudge
|
||||
|
45
scripts/cmake/PNGCheckLibconf.cmake
Normal file
45
scripts/cmake/PNGCheckLibconf.cmake
Normal file
@ -0,0 +1,45 @@
|
||||
# PNGConfig.cmake
|
||||
# Utility functions for configuring and building libpng
|
||||
|
||||
# Copyright (c) 2025 Cosmin Truta
|
||||
#
|
||||
# Use, modification and distribution are subject to
|
||||
# the same licensing terms and conditions as libpng.
|
||||
# Please see the copyright notice in png.h or visit
|
||||
# http://libpng.org/pub/png/src/libpng-LICENSE.txt
|
||||
#
|
||||
# SPDX-License-Identifier: libpng-2.0
|
||||
|
||||
# Check libconf file (pnglibconf.h.* or *.dfa):
|
||||
# png_check_libconf([HEADER <file>] [DFA_XTRA <file>])
|
||||
function(png_check_libconf)
|
||||
set(options)
|
||||
set(oneValueArgs HEADER DFA_XTRA)
|
||||
set(multiValueArgs)
|
||||
|
||||
cmake_parse_arguments(_CHK "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if(_CHK_HEADER AND _CHK_DFA_XTRA)
|
||||
message(FATAL_ERROR "png_check_libconf: Mutually-exclusive arguments: HEADER and DFA_XTRA")
|
||||
endif()
|
||||
|
||||
if(_CHK_HEADER)
|
||||
if(EXISTS "${_CHK_HEADER}")
|
||||
if("x${_CHK_HEADER}" STREQUAL "x${PNG_LIBCONF_HEADER_PREBUILT}")
|
||||
message(STATUS "Using standard libconf header: ${_CHK_HEADER}")
|
||||
else()
|
||||
message(STATUS "Using custom libconf header: ${_CHK_HEADER}")
|
||||
endif()
|
||||
else()
|
||||
message(SEND_ERROR "Could not find libconf header: ${_CHK_HEADER}")
|
||||
endif()
|
||||
else()
|
||||
if("x${_CHK_DFA_XTRA}" STREQUAL "x")
|
||||
message(STATUS "Creating standard configuration")
|
||||
elseif(EXISTS "${_CHK_DFA_XTRA}")
|
||||
message(STATUS "Creating custom configuration with DFA_XTRA file: ${_CHK_DFA_XTRA}")
|
||||
else()
|
||||
message(SEND_ERROR "Could not find DFA_XTRA file: ${_CHK_DFA_XTRA}")
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
@ -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()
|
||||
|
@ -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@)
|
||||
|
@ -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")
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
# Modeled after libxml-config.
|
||||
|
||||
version=1.6.46
|
||||
version=1.6.51.git
|
||||
prefix=""
|
||||
libdir=""
|
||||
libs=""
|
||||
|
@ -5,6 +5,6 @@ includedir=@includedir@/libpng16
|
||||
|
||||
Name: libpng
|
||||
Description: Loads and saves PNG files
|
||||
Version: 1.6.46
|
||||
Version: 1.6.51.git
|
||||
Libs: -L${libdir} -lpng16
|
||||
Cflags: -I${includedir}
|
||||
|
@ -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 \
|
||||
|
@ -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 \
|
||||
|
@ -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 \
|
||||
|
@ -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 \
|
||||
|
@ -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 \
|
||||
|
@ -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 \
|
||||
|
@ -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
|
||||
|
@ -711,7 +711,7 @@ option WRITE_TEXT requires WRITE_ANCILLARY_CHUNKS enables TEXT
|
||||
# processing, it just validates the data in the PNG file.
|
||||
|
||||
option GAMMA disabled
|
||||
option COLORSPACE enables GAMMA disabled
|
||||
option COLORSPACE disabled
|
||||
|
||||
# When an ICC profile is read, or png_set, it will be checked for a match
|
||||
# against known sRGB profiles if the sRGB handling is enabled. The
|
||||
@ -851,16 +851,16 @@ chunk cLLI
|
||||
chunk eXIf
|
||||
chunk gAMA enables GAMMA
|
||||
chunk hIST
|
||||
chunk iCCP enables COLORSPACE, GAMMA
|
||||
chunk iCCP enables GAMMA
|
||||
chunk iTXt enables TEXT
|
||||
chunk mDCV
|
||||
chunk mDCV enables COLORSPACE
|
||||
chunk oFFs
|
||||
chunk pCAL
|
||||
chunk pHYs
|
||||
chunk sBIT
|
||||
chunk sCAL
|
||||
chunk sPLT
|
||||
chunk sRGB enables COLORSPACE, GAMMA, SET_OPTION
|
||||
chunk sRGB enables GAMMA, SET_OPTION
|
||||
chunk tEXt requires TEXT
|
||||
chunk tIME
|
||||
chunk tRNS
|
||||
@ -995,7 +995,8 @@ option SIMPLIFIED_READ,
|
||||
READ_EXPAND, READ_16BIT, READ_EXPAND_16, READ_SCALE_16_TO_8,
|
||||
READ_RGB_TO_GRAY, READ_ALPHA_MODE, READ_BACKGROUND, READ_STRIP_ALPHA,
|
||||
READ_FILLER, READ_SWAP, READ_PACK, READ_GRAY_TO_RGB, READ_GAMMA,
|
||||
READ_tRNS, READ_bKGD, READ_gAMA, READ_cHRM, READ_sRGB, READ_sBIT
|
||||
READ_tRNS, READ_bKGD, READ_gAMA, READ_cHRM, READ_sRGB, READ_mDCV,
|
||||
READ_cICP, READ_sBIT
|
||||
|
||||
# AFIRST and BGR read options:
|
||||
# Prior to libpng 1.6.8 these were disabled but switched on if the low level
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* pnglibconf.h - library build configuration */
|
||||
|
||||
/* libpng version 1.6.46 */
|
||||
/* libpng version 1.6.51.git */
|
||||
|
||||
/* Copyright (c) 2018-2025 Cosmin Truta */
|
||||
/* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */
|
||||
|
@ -1,9 +1,9 @@
|
||||
#! /bin/sh
|
||||
# test-driver - basic testsuite driver script.
|
||||
|
||||
scriptversion=2024-06-19.01; # UTC
|
||||
scriptversion=2025-06-18.21; # UTC
|
||||
|
||||
# Copyright (C) 2011-2024 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2011-2025 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@ -152,9 +152,9 @@ echo ":copy-in-global-log: $gcopy" >> $trs_file
|
||||
# Local Variables:
|
||||
# mode: shell-script
|
||||
# sh-indentation: 2
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||
# eval: (add-hook 'before-save-hook 'time-stamp nil t)
|
||||
# time-stamp-start: "scriptversion="
|
||||
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||
# time-stamp-format: "%Y-%02m-%02d.%02H"
|
||||
# time-stamp-time-zone: "UTC0"
|
||||
# time-stamp-end: "; # UTC"
|
||||
# End:
|
||||
|
Loading…
x
Reference in New Issue
Block a user