Commit 54f2ab10 authored by mercury233's avatar mercury233 Committed by GitHub

upgrade libpng to 1.6.54, add arm neon files (#18)

parent 5597cf38
...@@ -1265,6 +1265,7 @@ ...@@ -1265,6 +1265,7 @@
<Unit filename="libpng/pngset.c"> <Unit filename="libpng/pngset.c">
<Option compilerVar="CC" /> <Option compilerVar="CC" />
</Unit> </Unit>
<Unit filename="libpng/pngstruct.h" />
<Unit filename="libpng/pngtrans.c"> <Unit filename="libpng/pngtrans.c">
<Option compilerVar="CC" /> <Option compilerVar="CC" />
</Unit> </Unit>
......
libpng 1.6.47 - February 18, 2025 libpng 1.6.54 - January 12, 2026
================================= ================================
This is a public release of libpng, intended for use in production code. This is a public release of libpng, intended for use in production code.
...@@ -7,15 +7,12 @@ This is a public release of libpng, intended for use in production code. ...@@ -7,15 +7,12 @@ This is a public release of libpng, intended for use in production code.
Files available for download Files available for download
---------------------------- ----------------------------
Source files with LF line endings (for Unix/Linux): Source files:
* libpng-1.6.47.tar.xz (LZMA-compressed, recommended) * libpng-1.6.54.tar.xz (LZMA-compressed, recommended)
* libpng-1.6.47.tar.gz (deflate-compressed) * libpng-1.6.54.tar.gz (deflate-compressed)
* lpng1654.7z (LZMA-compressed)
Source files with CRLF line endings (for Windows): * lpng1654.zip (deflate-compressed)
* lpng1647.7z (LZMA-compressed, recommended)
* lpng1647.zip (deflate-compressed)
Other information: Other information:
...@@ -25,20 +22,16 @@ Other information: ...@@ -25,20 +22,16 @@ Other information:
* TRADEMARK.md * TRADEMARK.md
Changes from version 1.6.46 to version 1.6.47 Changes from version 1.6.53 to version 1.6.54
--------------------------------------------- ---------------------------------------------
* Modified the behaviour of colorspace chunks in order to adhere * Fixed CVE-2026-22695 (medium severity):
to the new precedence rules formulated in the latest draft of Heap buffer over-read in `png_image_read_direct_scaled.
the PNG Specification. (Reported and fixed by Petr Simecek.)
(Contributed by John Bowler) * Fixed CVE-2026-22801 (medium severity):
* Fixed a latent bug in `png_write_iCCP`. Integer truncation causing heap buffer over-read in `png_image_write_*`.
This would have been a read-beyond-end-of-malloc vulnerability, * Implemented various improvements in oss-fuzz.
introduced early in the libpng-1.6.0 development, yet (fortunately!) (Contributed by Philippe Antoine.)
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)
Send comments/corrections/commendations to png-mng-implement at lists.sf.net. Send comments/corrections/commendations to png-mng-implement at lists.sf.net.
Subscription is required; visit Subscription is required; visit
......
...@@ -5,6 +5,7 @@ This is the list of PNG Reference Library ("libpng") Contributing ...@@ -5,6 +5,7 @@ This is the list of PNG Reference Library ("libpng") Contributing
Authors, for copyright and licensing purposes. Authors, for copyright and licensing purposes.
* Adam Richter * Adam Richter
* Alexander Smorkalov
* Andreas Dilger * Andreas Dilger
* Chris Blume * Chris Blume
* Cosmin Truta * Cosmin Truta
...@@ -20,17 +21,20 @@ Authors, for copyright and licensing purposes. ...@@ -20,17 +21,20 @@ Authors, for copyright and licensing purposes.
* Lucas Chollet * Lucas Chollet
* Magnus Holmgren * Magnus Holmgren
* Mandar Sahastrabuddhe * Mandar Sahastrabuddhe
* Manfred Schlaegl
* Mans Rullgard * Mans Rullgard
* Matt Sarett * Matt Sarett
* Mike Klein * Mike Klein
* Pascal Massimino * Pascal Massimino
* Paul Schmidt * Paul Schmidt
* Petr Simecek
* Philippe Antoine * Philippe Antoine
* Qiang Zhou * Qiang Zhou
* Sam Bushell * Sam Bushell
* Samuel Williams * Samuel Williams
* Simon-Pierre Cadieux * Simon-Pierre Cadieux
* Tim Wegner * Tim Wegner
* Tobias Stoeckmann
* Tom Lane * Tom Lane
* Tom Tanner * Tom Tanner
* Vadim Barkov * Vadim Barkov
...@@ -40,8 +44,9 @@ Authors, for copyright and licensing purposes. ...@@ -40,8 +44,9 @@ Authors, for copyright and licensing purposes.
- Zixu Wang (王子旭) - Zixu Wang (王子旭)
* Arm Holdings * Arm Holdings
- Richard Townsend - Richard Townsend
* Google Inc. * Google LLC
- Dan Field - Dan Field
- Dragoș Tiselice
- Leon Scroggins III - Leon Scroggins III
- Matt Sarett - Matt Sarett
- Mike Klein - Mike Klein
...@@ -51,6 +56,10 @@ Authors, for copyright and licensing purposes. ...@@ -51,6 +56,10 @@ Authors, for copyright and licensing purposes.
- GuXiWei (顾希伟) - GuXiWei (顾希伟)
- JinBo (金波) - JinBo (金波)
- ZhangLixia (张利霞) - ZhangLixia (张利霞)
* Samsung Group
- Filip Wasil
* SpacemiT Hangzhou Technology, Co.
- Liang Junzhao (梁俊钊)
The build projects, the build scripts, the test scripts, and other The build projects, the build scripts, the test scripts, and other
files in the "projects", "scripts" and "tests" directories, have files in the "projects", "scripts" and "tests" directories, have
......
...@@ -6251,6 +6251,86 @@ Version 1.6.47 [February 18, 2025] ...@@ -6251,6 +6251,86 @@ Version 1.6.47 [February 18, 2025]
colorspace precedence rules, due to pre-existing colorspace checks. colorspace precedence rules, due to pre-existing colorspace checks.
(Reported by Bob Friesenhahn; fixed by John Bowler) (Reported by Bob Friesenhahn; fixed by John Bowler)
Version 1.6.48 [April 30, 2025]
Fixed the floating-point version of the mDCv setter `png_set_mDCv`.
(Reported by Mohit Bakshi; fixed by John Bowler)
Added #error directives to discourage the inclusion of private
libpng implementation header files in PNG-supporting applications.
Added the CMake build option `PNG_LIBCONF_HEADER`, to be used as an
alternative to `DFA_XTRA`.
Removed the Travis CI configuration files, with heartfelt thanks for
their generous support of our project over the past five years!
Version 1.6.49 [June 12, 2025]
Added SIMD-optimized code for the RISC-V Vector Extension (RVV).
(Contributed by Manfred Schlaegl, Dragos Tiselice and Filip Wasil)
Added various fixes and improvements to the build scripts and to
the sample code.
Version 1.6.50 [July 1, 2025]
Improved the detection of the RVV Extension on the RISC-V platform.
(Contributed by Filip Wasil)
Replaced inline ASM with C intrinsics in the RVV code.
(Contributed by Filip Wasil)
Fixed a decoder defect in which unknown chunks trailing IDAT, set
to go through the unknown chunk handler, incorrectly triggered
out-of-place IEND errors.
(Contributed by John Bowler)
Fixed the CMake file for cross-platform builds that require `libm`.
Version 1.6.51 [November 21, 2025]
Fixed CVE-2025-64505 (moderate severity):
Heap buffer overflow in `png_do_quantize` via malformed palette index.
(Reported by Samsung; analyzed by Fabio Gritti.)
Fixed CVE-2025-64506 (moderate severity):
Heap buffer over-read in `png_write_image_8bit` with 8-bit input and
`convert_to_8bit` enabled.
(Reported by Samsung and <weijinjinnihao@users.noreply.github.com>;
analyzed by Fabio Gritti.)
Fixed CVE-2025-64720 (high severity):
Buffer overflow in `png_image_read_composite` via incorrect palette
premultiplication.
(Reported by Samsung; analyzed by John Bowler.)
Fixed CVE-2025-65018 (high severity):
Heap buffer overflow in `png_combine_row` triggered via
`png_image_finish_read`.
(Reported by <yosiimich@users.noreply.github.com>.)
Fixed a memory leak in `png_set_quantize`.
(Reported by Samsung; analyzed by Fabio Gritti.)
Removed the experimental and incomplete ERROR_NUMBERS code.
(Contributed by Tobias Stoeckmann.)
Improved the RISC-V vector extension support; required RVV 1.0 or newer.
(Contributed by Filip Wasil.)
Added GitHub Actions workflows for automated testing.
Performed various refactorings and cleanups.
Version 1.6.52 [December 3, 2025]
Fixed CVE-2025-66293 (high severity):
Out-of-bounds read in `png_image_read_composite`.
(Reported by flyfish101 <flyfish101@users.noreply.github.com>.)
Fixed the Paeth filter handling in the RISC-V RVV implementation.
(Reported by Filip Wasil; fixed by Liang Junzhao.)
Improved the performance of the RISC-V RVV implementation.
(Contributed by Liang Junzhao.)
Added allocation failure fuzzing to oss-fuzz.
(Contributed by Philippe Antoine.)
Version 1.6.53 [December 5, 2025]
Fixed a build failure on RISC-V RVV caused by a misspelled intrinsic.
(Contributed by Alexander Smorkalov.)
Fixed a build failure with CMake 4.1 or newer, on Windows, when using
Visual C++ without MASM installed.
Version 1.6.54 [January 12, 2026]
Fixed CVE-2026-22695 (medium severity):
Heap buffer over-read in `png_image_read_direct_scaled.
(Reported and fixed by Petr Simecek.)
Fixed CVE-2026-22801 (medium severity):
Integer truncation causing heap buffer over-read in `png_image_write_*`.
Implemented various improvements in oss-fuzz.
(Contributed by Philippe Antoine.)
Send comments/corrections/commendations to png-mng-implement at lists.sf.net. Send comments/corrections/commendations to png-mng-implement at lists.sf.net.
Subscription is required; visit Subscription is required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement https://lists.sourceforge.net/lists/listinfo/png-mng-implement
......
This diff is collapsed.
...@@ -136,7 +136,7 @@ Your directory structure should look like this: ...@@ -136,7 +136,7 @@ Your directory structure should look like this:
depcomp, install-sh, mkinstalldirs, test-pngtest.sh, etc. depcomp, install-sh, mkinstalldirs, test-pngtest.sh, etc.
contrib contrib
arm-neon, conftest, examples, gregbook, libtests, pngminim, arm-neon, conftest, examples, gregbook, libtests, pngminim,
pngminus, pngsuite, tools, visupng pngminus, pngsuite, tools, visupng, riscv-rvv
projects projects
owatcom, visualc71, vstudio owatcom, visualc71, vstudio
scripts scripts
...@@ -289,6 +289,7 @@ such as one of ...@@ -289,6 +289,7 @@ such as one of
--enable-mips-msa=yes --enable-mips-msa=yes
--enable-intel-sse=yes --enable-intel-sse=yes
--enable-powerpc-vsx=yes --enable-powerpc-vsx=yes
--enable-riscv-rvv=yes
or enable them all at once with or enable them all at once with
...@@ -301,6 +302,7 @@ or more of ...@@ -301,6 +302,7 @@ or more of
CPPFLAGS += "-DPNG_MIPS_MSA" CPPFLAGS += "-DPNG_MIPS_MSA"
CPPFLAGS += "-DPNG_INTEL_SSE" CPPFLAGS += "-DPNG_INTEL_SSE"
CPPFLAGS += "-DPNG_POWERPC_VSX" CPPFLAGS += "-DPNG_POWERPC_VSX"
CPPFLAGS += "-DPNG_RISCV_RVV"
See for example scripts/makefile.linux-opt See for example scripts/makefile.linux-opt
...@@ -317,13 +319,15 @@ to disable a particular one, ...@@ -317,13 +319,15 @@ to disable a particular one,
or via compiler-command options such as or via compiler-command options such as
CPPFLAGS += "-DPNG_ARM_NEON_OPT=0, -DPNG_MIPS_MSA_OPT=0, 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" If you are using cmake, hardware optimizations are "on"
by default. To disable them, use by default. To disable them, use
cmake . -DPNG_ARM_NEON=no -DPNG_INTEL_SSE=no \ 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 or disable them all at once with
......
...@@ -4,8 +4,8 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE ...@@ -4,8 +4,8 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
PNG Reference Library License version 2 PNG Reference Library License version 2
--------------------------------------- ---------------------------------------
* Copyright (c) 1995-2025 The PNG Reference Library Authors. * Copyright (c) 1995-2026 The PNG Reference Library Authors.
* Copyright (c) 2018-2025 Cosmin Truta. * Copyright (c) 2018-2026 Cosmin Truta.
* Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson. * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
* Copyright (c) 1996-1997 Andreas Dilger. * Copyright (c) 1996-1997 Andreas Dilger.
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
......
...@@ -134,13 +134,20 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += powerpc/powerpc_init.c\ ...@@ -134,13 +134,20 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += powerpc/powerpc_init.c\
powerpc/filter_vsx_intrinsics.c powerpc/filter_vsx_intrinsics.c
endif 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 if PNG_LOONGARCH_LSX
noinst_LTLIBRARIES= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la noinst_LTLIBRARIES= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_SOURCES = loongarch/loongarch_lsx_init.c\ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_SOURCES = loongarch/loongarch_lsx_init.c\
loongarch/filter_lsx_intrinsics.c loongarch/filter_lsx_intrinsics.c
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_CFLAGS = -mlsx 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_LIBADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la
# libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la
endif endif
nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
...@@ -163,6 +170,10 @@ else ...@@ -163,6 +170,10 @@ else
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.sym libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.sym
endif endif
if PNG_RISCV_RVV
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES += libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@rvv.la
endif
if PNG_LOONGARCH_LSX if PNG_LOONGARCH_LSX
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES += libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES += libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la
endif endif
......
This diff is collapsed.
README for libpng version 1.6.47 README for libpng version 1.6.54
================================ ================================
See the note about version numbers near the top of `png.h`. See the note about version numbers near the top of `png.h`.
...@@ -147,6 +147,7 @@ Files included in this distribution ...@@ -147,6 +147,7 @@ Files included in this distribution
loongarch/ => Optimized code for LoongArch LSX loongarch/ => Optimized code for LoongArch LSX
mips/ => Optimized code for MIPS MSA and MIPS MMI mips/ => Optimized code for MIPS MSA and MIPS MMI
powerpc/ => Optimized code for PowerPC VSX powerpc/ => Optimized code for PowerPC VSX
riscv/ => Optimized code for the RISC-V platform
ci/ => Scripts for continuous integration ci/ => Scripts for continuous integration
contrib/ => External contributions contrib/ => External contributions
arm-neon/ => Optimized code for the ARM-NEON platform arm-neon/ => Optimized code for the ARM-NEON platform
...@@ -162,6 +163,7 @@ Files included in this distribution ...@@ -162,6 +163,7 @@ Files included in this distribution
programs demonstrating the use of pngusr.dfa programs demonstrating the use of pngusr.dfa
pngminus/ => Simple pnm2png and png2pnm programs pngminus/ => Simple pnm2png and png2pnm programs
pngsuite/ => Test images pngsuite/ => Test images
riscv-rvv/ => Optimized code for the RISC-V Vector platform
testpngs/ => Test images testpngs/ => Test images
tools/ => Various tools tools/ => Various tools
visupng/ => VisualPng, a Windows viewer for PNG images visupng/ => VisualPng, a Windows viewer for PNG images
......
This diff is collapsed.
/* arm_init.c - NEON optimised filter functions
*
* Copyright (c) 2018-2022 Cosmin Truta
* Copyright (c) 2014,2016 Glenn Randers-Pehrson
* Written by Mans Rullgard, 2011.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*/
/* This module requires POSIX 1003.1 functions. */
#define _POSIX_SOURCE 1
#include "../pngpriv.h"
#ifdef PNG_READ_SUPPORTED
#if PNG_ARM_NEON_OPT > 0
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED /* Do run-time checks */
/* WARNING: it is strongly recommended that you do not build libpng with
* run-time checks for CPU features if at all possible. In the case of the ARM
* NEON instructions there is no processor-specific way of detecting the
* presence of the required support, therefore run-time detection is extremely
* OS specific.
*
* You may set the macro PNG_ARM_NEON_FILE to the file name of file containing
* a fragment of C source code which defines the png_have_neon function. There
* are a number of implementations in contrib/arm-neon, but the only one that
* has partial support is contrib/arm-neon/linux.c - a generic Linux
* implementation which reads /proc/cpufino.
*/
#include <signal.h> /* for sig_atomic_t */
#ifndef PNG_ARM_NEON_FILE
# if defined(__aarch64__) || defined(_M_ARM64)
/* ARM Neon is expected to be unconditionally available on ARM64. */
# error PNG_ARM_NEON_CHECK_SUPPORTED must not be defined on ARM64
# elif defined(__ARM_NEON__) || defined(__ARM_NEON)
/* ARM Neon is expected to be available on the target CPU architecture. */
# error PNG_ARM_NEON_CHECK_SUPPORTED must not be defined on this CPU arch
# elif defined(__linux__)
# define PNG_ARM_NEON_FILE "contrib/arm-neon/linux.c"
# else
# error No support for run-time ARM Neon checking; use compile-time options
# endif
#endif
static int png_have_neon(png_structp png_ptr);
#ifdef PNG_ARM_NEON_FILE
# include PNG_ARM_NEON_FILE
#endif
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
#ifndef PNG_ALIGNED_MEMORY_SUPPORTED
# error ALIGNED_MEMORY is required; please define PNG_ALIGNED_MEMORY_SUPPORTED
#endif
void
png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
{
/* The switch statement is compiled in for ARM_NEON_API, the call to
* png_have_neon is compiled in for ARM_NEON_CHECK. If both are defined
* the check is only performed if the API has not set the NEON option on
* or off explicitly. In this case the check controls what happens.
*
* If the CHECK is not compiled in and the option is UNSET the behavior prior
* to 1.6.7 was to use the NEON code - this was a bug caused by having the
* wrong order of the 'ON' and 'default' cases. UNSET now defaults to OFF,
* as documented in png.h
*/
png_debug(1, "in png_init_filter_functions_neon");
#ifdef PNG_ARM_NEON_API_SUPPORTED
switch ((pp->options >> PNG_ARM_NEON) & 3)
{
case PNG_OPTION_UNSET:
/* Allow the run-time check to execute if it has been enabled -
* thus both API and CHECK can be turned on. If it isn't supported
* this case will fall through to the 'default' below, which just
* returns.
*/
#endif /* PNG_ARM_NEON_API_SUPPORTED */
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED
{
static volatile sig_atomic_t no_neon = -1; /* not checked */
if (no_neon < 0)
no_neon = !png_have_neon(pp);
if (no_neon)
return;
}
#ifdef PNG_ARM_NEON_API_SUPPORTED
break;
#endif
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
#ifdef PNG_ARM_NEON_API_SUPPORTED
default: /* OFF or INVALID */
return;
case PNG_OPTION_ON:
/* Option turned on */
break;
}
#endif
/* IMPORTANT: any new external functions used here must be declared using
* PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the
* 'prefix' option to configure works:
*
* ./configure --with-libpng-prefix=foobar_
*
* Verify you have got this right by running the above command, doing a build
* and examining pngprefix.h; it must contain a #define for every external
* function you add. (Notice that this happens automatically for the
* initialization function.)
*/
pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_neon;
if (bpp == 3)
{
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_neon;
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_neon;
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
png_read_filter_row_paeth3_neon;
}
else if (bpp == 4)
{
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_neon;
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_neon;
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
png_read_filter_row_paeth4_neon;
}
}
#endif /* PNG_ARM_NEON_OPT > 0 */
#endif /* READ */
/* filter_neon.S - placeholder file
*
* Copyright (c) 2024 Cosmin Truta
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*/
/* IMPORTANT NOTE:
*
* Historically, the hand-coded assembler implementation of Neon optimizations
* in this module had not been in sync with the intrinsics-based implementation
* in filter_neon_intrinsics.c and palette_neon_intrinsics.c, at least since
* the introduction of riffled palette optimizations. Moreover, the assembler
* code used to work on 32-bit ARM only, and it caused problems, even if empty,
* on 64-bit ARM.
*
* All references to this module from our internal build scripts and projects
* have been removed.
*
* For the external projects that might still expect this module to be present,
* we leave this stub in place, for the remaining lifetime of libpng-1.6.x.
* Everything should continue to function normally, as long as there are no
* deliberate attempts to use the old hand-made assembler code. A build error
* will be raised otherwise.
*/
/* This is required to get the symbol renames, which are #defines, and the
* definitions (or not) of PNG_ARM_NEON_OPT and PNG_ARM_NEON_IMPLEMENTATION.
*/
#define PNG_VERSION_INFO_ONLY
#include "../pngpriv.h"
#ifdef PNG_READ_SUPPORTED
#if PNG_ARM_NEON_IMPLEMENTATION == 2 /* hand-coded assembler */
#if PNG_ARM_NEON_OPT > 0
#if defined(__clang__)
#define GNUC_VERSION 0 /* not gcc, although it might pretend to be */
#elif defined(__GNUC__)
#define GNUC_MAJOR (__GNUC__ + 0)
#define GNUC_MINOR (__GNUC_MINOR__ + 0)
#define GNUC_PATCHLEVEL (__GNUC_PATCHLEVEL__ + 0)
#define GNUC_VERSION (GNUC_MAJOR * 10000 + GNUC_MINOR * 100 + GNUC_PATCHLEVEL)
#else
#define GNUC_VERSION 0 /* not gcc */
#endif
#if (GNUC_VERSION > 0) && (GNUC_VERSION < 40300)
#error "PNG_ARM_NEON is not supported with gcc versions earlier than 4.3.0"
#elif GNUC_VERSION == 40504
#error "PNG_ARM_NEON is not supported with gcc version 4.5.4"
#else
#error "Please use 'arm/*_neon_intrinsics.c' for PNG_ARM_NEON support"
#endif
#endif /* PNG_ARM_NEON_OPT > 0 */
#endif /* PNG_ARM_NEON_IMPLEMENTATION == 2 */
#endif /* READ */
This diff is collapsed.
/* palette_neon_intrinsics.c - NEON optimised palette expansion functions
*
* Copyright (c) 2018-2019 Cosmin Truta
* Copyright (c) 2017-2018 Arm Holdings. All rights reserved.
* Written by Richard Townsend <Richard.Townsend@arm.com>, February 2017.
*
* 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"
#if PNG_ARM_NEON_IMPLEMENTATION == 1
#if defined(_MSC_VER) && !defined(__clang__) && defined(_M_ARM64)
# include <arm64_neon.h>
#else
# include <arm_neon.h>
#endif
/* Build an RGBA8 palette from the separate RGB and alpha palettes. */
void
png_riffle_palette_neon(png_structrp png_ptr)
{
png_const_colorp palette = png_ptr->palette;
png_bytep riffled_palette = png_ptr->riffled_palette;
png_const_bytep trans_alpha = png_ptr->trans_alpha;
int num_trans = png_ptr->num_trans;
int i;
/* Initially black, opaque. */
uint8x16x4_t w = {{
vdupq_n_u8(0x00),
vdupq_n_u8(0x00),
vdupq_n_u8(0x00),
vdupq_n_u8(0xff),
}};
png_debug(1, "in png_riffle_palette_neon");
/* First, riffle the RGB colours into an RGBA8 palette.
* The alpha component is set to opaque for now.
*/
for (i = 0; i < 256; i += 16)
{
uint8x16x3_t v = vld3q_u8((png_const_bytep)(palette + i));
w.val[0] = v.val[0];
w.val[1] = v.val[1];
w.val[2] = v.val[2];
vst4q_u8(riffled_palette + (i << 2), w);
}
/* Fix up the missing transparency values. */
for (i = 0; i < num_trans; i++)
riffled_palette[(i << 2) + 3] = trans_alpha[i];
}
/* Expands a palettized row into RGBA8. */
int
png_do_expand_palette_rgba8_neon(png_structrp png_ptr, png_row_infop row_info,
png_const_bytep row, png_bytepp ssp, png_bytepp ddp)
{
png_uint_32 row_width = row_info->width;
const png_uint_32 *riffled_palette =
png_aligncastconst(png_const_uint_32p, png_ptr->riffled_palette);
const png_uint_32 pixels_per_chunk = 4;
png_uint_32 i;
png_debug(1, "in png_do_expand_palette_rgba8_neon");
PNG_UNUSED(row)
if (row_width < pixels_per_chunk)
return 0;
/* This function originally gets the last byte of the output row.
* The NEON part writes forward from a given position, so we have
* to seek this back by 4 pixels x 4 bytes.
*/
*ddp = *ddp - ((pixels_per_chunk * sizeof(png_uint_32)) - 1);
for (i = 0; i < row_width; i += pixels_per_chunk)
{
uint32x4_t cur;
png_bytep sp = *ssp - i, dp = *ddp - (i << 2);
cur = vld1q_dup_u32 (riffled_palette + *(sp - 3));
cur = vld1q_lane_u32(riffled_palette + *(sp - 2), cur, 1);
cur = vld1q_lane_u32(riffled_palette + *(sp - 1), cur, 2);
cur = vld1q_lane_u32(riffled_palette + *(sp - 0), cur, 3);
vst1q_u32((void *)dp, cur);
}
if (i != row_width)
{
/* Remove the amount that wasn't processed. */
i -= pixels_per_chunk;
}
/* Decrement output pointers. */
*ssp = *ssp - i;
*ddp = *ddp - (i << 2);
return i;
}
/* Expands a palettized row into RGB8. */
int
png_do_expand_palette_rgb8_neon(png_structrp png_ptr, png_row_infop row_info,
png_const_bytep row, png_bytepp ssp, png_bytepp ddp)
{
png_uint_32 row_width = row_info->width;
png_const_bytep palette = (png_const_bytep)png_ptr->palette;
const png_uint_32 pixels_per_chunk = 8;
png_uint_32 i;
png_debug(1, "in png_do_expand_palette_rgb8_neon");
PNG_UNUSED(row)
if (row_width <= pixels_per_chunk)
return 0;
/* Seeking this back by 8 pixels x 3 bytes. */
*ddp = *ddp - ((pixels_per_chunk * sizeof(png_color)) - 1);
for (i = 0; i < row_width; i += pixels_per_chunk)
{
uint8x8x3_t cur;
png_bytep sp = *ssp - i, dp = *ddp - ((i << 1) + i);
cur = vld3_dup_u8(palette + sizeof(png_color) * (*(sp - 7)));
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 6)), cur, 1);
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 5)), cur, 2);
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 4)), cur, 3);
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 3)), cur, 4);
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 2)), cur, 5);
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 1)), cur, 6);
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 0)), cur, 7);
vst3_u8((void *)dp, cur);
}
if (i != row_width)
{
/* Remove the amount that wasn't processed. */
i -= pixels_per_chunk;
}
/* Decrement output pointers. */
*ssp = *ssp - i;
*ddp = *ddp - ((i << 1) + i);
return i;
}
#endif /* PNG_ARM_NEON_IMPLEMENTATION */
#! /bin/sh #! /bin/sh
# Wrapper for compilers which do not understand '-c -o'. # 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>. # Written by Tom Tromey <tromey@cygnus.com>.
# #
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
...@@ -37,11 +37,11 @@ IFS=" "" $nl" ...@@ -37,11 +37,11 @@ IFS=" "" $nl"
file_conv= 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 # Convert a $build file to $host form and store it in $file
# Currently only supports Windows hosts. If the determined conversion # Currently only supports Windows hosts. If the determined conversion
# type is listed in (the comma separated) LAZY, no conversion will # type is listed in (the comma separated) UNNEEDED_CONVERSIONS, no
# take place. # conversion will take place.
func_file_conv () func_file_conv ()
{ {
file=$1 file=$1
...@@ -51,9 +51,20 @@ func_file_conv () ...@@ -51,9 +51,20 @@ func_file_conv ()
# lazily determine how to convert abs files # lazily determine how to convert abs files
case `uname -s` in case `uname -s` in
MINGW*) MINGW*)
if test -n "$MSYSTEM" && (cygpath --version) >/dev/null 2>&1; then
# MSYS2 environment.
file_conv=cygwin
else
# Original MinGW environment.
file_conv=mingw file_conv=mingw
fi
;;
MSYS*)
# Old MSYS environment, or MSYS2 with 32-bit MSYS2 shell.
file_conv=cygwin
;; ;;
CYGWIN* | MSYS*) CYGWIN*)
# Cygwin environment.
file_conv=cygwin file_conv=cygwin
;; ;;
*) *)
...@@ -63,12 +74,14 @@ func_file_conv () ...@@ -63,12 +74,14 @@ func_file_conv ()
fi fi
case $file_conv/,$2, in case $file_conv/,$2, in
*,$file_conv,*) *,$file_conv,*)
# This is the optimization mentioned above:
# If UNNEEDED_CONVERSIONS contains $file_conv, don't convert.
;; ;;
mingw/*) mingw/*)
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
;; ;;
cygwin/* | msys/*) cygwin/*)
file=`cygpath -m "$file" || echo "$file"` file=`cygpath -w "$file" || echo "$file"`
;; ;;
wine/*) wine/*)
file=`winepath -w "$file" || echo "$file"` file=`winepath -w "$file" || echo "$file"`
...@@ -343,9 +356,9 @@ exit $ret ...@@ -343,9 +356,9 @@ exit $ret
# Local Variables: # Local Variables:
# mode: shell-script # mode: shell-script
# sh-indentation: 2 # 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-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-format: "%Y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0" # time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC" # time-stamp-end: "; # UTC"
# End: # End:
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# shellcheck disable=SC2006,SC2268 # see below for rationale # 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 # 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 # under the terms of the GNU General Public License as published by
...@@ -123,7 +123,7 @@ set_cc_for_build() { ...@@ -123,7 +123,7 @@ set_cc_for_build() {
dummy=$tmp/dummy dummy=$tmp/dummy
case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
,,) echo "int x;" > "$dummy.c" ,,) 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 if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
CC_FOR_BUILD=$driver CC_FOR_BUILD=$driver
break break
...@@ -634,7 +634,8 @@ EOF ...@@ -634,7 +634,8 @@ EOF
sed 's/^ //' << EOF > "$dummy.c" sed 's/^ //' << EOF > "$dummy.c"
#include <sys/systemcfg.h> #include <sys/systemcfg.h>
main() int
main ()
{ {
if (!__power_pc()) if (!__power_pc())
exit(1); exit(1);
...@@ -718,7 +719,8 @@ EOF ...@@ -718,7 +719,8 @@ EOF
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
int main () int
main ()
{ {
#if defined(_SC_KERNEL_BITS) #if defined(_SC_KERNEL_BITS)
long bits = sysconf(_SC_KERNEL_BITS); long bits = sysconf(_SC_KERNEL_BITS);
...@@ -1621,6 +1623,7 @@ cat > "$dummy.c" <<EOF ...@@ -1621,6 +1623,7 @@ cat > "$dummy.c" <<EOF
#endif #endif
#endif #endif
#endif #endif
int
main () main ()
{ {
#if defined (sony) #if defined (sony)
......
...@@ -108,6 +108,9 @@ ...@@ -108,6 +108,9 @@
/* Enable POWERPC VSX optimizations */ /* Enable POWERPC VSX optimizations */
#undef PNG_POWERPC_VSX_OPT #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 /* 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 required in a freestanding environment). This macro is provided for
backward compatibility; new code need not use it. */ backward compatibility; new code need not use it. */
......
This diff is collapsed.
This diff is collapsed.
...@@ -25,7 +25,7 @@ AC_PREREQ([2.68]) ...@@ -25,7 +25,7 @@ AC_PREREQ([2.68])
dnl Version number stuff here: dnl Version number stuff here:
AC_INIT([libpng],[1.6.47],[png-mng-implement@lists.sourceforge.net]) AC_INIT([libpng],[1.6.54],[png-mng-implement@lists.sourceforge.net])
AC_CONFIG_MACRO_DIR([scripts/autoconf]) AC_CONFIG_MACRO_DIR([scripts/autoconf])
# libpng does not follow GNU file name conventions (hence 'foreign') # 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): ...@@ -46,10 +46,10 @@ dnl automake, so the following is not necessary (and is not defined anyway):
dnl AM_PREREQ([1.11.2]) dnl AM_PREREQ([1.11.2])
dnl stop configure from automagically running automake dnl stop configure from automagically running automake
PNGLIB_VERSION=1.6.47 PNGLIB_VERSION=1.6.54
PNGLIB_MAJOR=1 PNGLIB_MAJOR=1
PNGLIB_MINOR=6 PNGLIB_MINOR=6
PNGLIB_RELEASE=47 PNGLIB_RELEASE=54
dnl End of version number stuff dnl End of version number stuff
...@@ -343,6 +343,9 @@ AC_ARG_ENABLE([hardware-optimizations], ...@@ -343,6 +343,9 @@ AC_ARG_ENABLE([hardware-optimizations],
enable_loongarch_lsx=no enable_loongarch_lsx=no
AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [0], AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [0],
[Disable LOONGARCH_LSX optimizations]) [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: # allow enabling hardware optimization on any system:
...@@ -375,6 +378,11 @@ AC_ARG_ENABLE([hardware-optimizations], ...@@ -375,6 +378,11 @@ AC_ARG_ENABLE([hardware-optimizations],
AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1], AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1],
[Enable LOONGARCH_LSX optimizations]) [Enable LOONGARCH_LSX optimizations])
;; ;;
riscv64)
enable_riscv_rvv=yes
AC_DEFINE([PNG_RISCV_RVV_OPT], [2],
[Enable RISC-V Vector optimizations])
;;
esac esac
;; ;;
esac]) esac])
...@@ -661,6 +669,72 @@ AM_CONDITIONAL([PNG_LOONGARCH_LSX], ...@@ -661,6 +669,72 @@ AM_CONDITIONAL([PNG_LOONGARCH_LSX],
*) test "$enable_loongarch_lsx" != '' ;; *) test "$enable_loongarch_lsx" != '' ;;
esac]) 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>
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]]) AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
# Config files, substituting as above # Config files, substituting as above
......
#! /bin/sh #! /bin/sh
# depcomp - compile a program generating dependencies as side-effects # 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 # 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 # it under the terms of the GNU General Public License as published by
...@@ -784,9 +784,9 @@ exit 0 ...@@ -784,9 +784,9 @@ exit 0
# Local Variables: # Local Variables:
# mode: shell-script # mode: shell-script
# sh-indentation: 2 # 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-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-format: "%Y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0" # time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC" # time-stamp-end: "; # UTC"
# End: # End:
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
/* example.c - an example of using libpng /* example.c - an example of using libpng
* *
* Maintained 2018-2024 Cosmin Truta * Maintained 2018-2025 Cosmin Truta
* Maintained 1998-2016 Glenn Randers-Pehrson * Maintained 1998-2016 Glenn Randers-Pehrson
* Maintained 1996-1997 Andreas Dilger * Maintained 1996-1997 Andreas Dilger
* Written 1995-1996 Guy Eric Schalnat, Group 42, Inc. * Written 1995-1996 Guy Eric Schalnat, Group 42, Inc.
...@@ -179,11 +179,11 @@ int main(int argc, const char **argv) ...@@ -179,11 +179,11 @@ int main(int argc, const char **argv)
* components. * components.
* *
* You do not have to read directly from a file. You can read from memory or, * 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 * on systems that support <stdio.h>, from a FILE object. This is controlled
* the particular png_image_read_from_ function you call at the start. * by the particular png_image_begin_read_from_ function you call at the start.
* Likewise, on write, you can write to a FILE* if your system supports it. * Likewise, on write, you can write to a FILE object if your system supports
* Check the macro PNG_STDIO_SUPPORTED to see if stdio support has been * <stdio.h>. The macro PNG_STDIO_SUPPORTED indicates if stdio is available
* included in your libpng build. * and accessible from your libpng build.
* *
* If you read 16-bit (PNG_FORMAT_FLAG_LINEAR) data, you may need to write it * 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 * in the 8-bit format for display. You do this by setting the convert_to_8bit
......
#!/bin/sh #!/bin/sh
# install - install a program, script, or datafile # 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 # This originates from X11R5 (mit/util/scripts/install.sh), which was
# later released in X11R6 (xc/config/util/install.sh) with the # later released in X11R6 (xc/config/util/install.sh) with the
...@@ -533,9 +533,9 @@ do ...@@ -533,9 +533,9 @@ do
done done
# Local variables: # 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-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-format: "%Y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0" # time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC" # time-stamp-end: "; # UTC"
# End: # End:
...@@ -26,29 +26,38 @@ ...@@ -26,29 +26,38 @@
* whichever of a, b, or c is closest to p=a+b-c. * whichever of a, b, or c is closest to p=a+b-c.
*/ */
static __m128i load4(const void* p) { static __m128i
load4(const void *p)
{
int tmp; int tmp;
memcpy(&tmp, p, sizeof(tmp)); memcpy(&tmp, p, sizeof(tmp));
return _mm_cvtsi32_si128(tmp); return _mm_cvtsi32_si128(tmp);
} }
static void store4(void* p, __m128i v) { static void
store4(void *p, __m128i v)
{
int tmp = _mm_cvtsi128_si32(v); int tmp = _mm_cvtsi128_si32(v);
memcpy(p, &tmp, sizeof(int)); memcpy(p, &tmp, sizeof(int));
} }
static __m128i load3(const void* p) { static __m128i
load3(const void *p)
{
png_uint_32 tmp = 0; png_uint_32 tmp = 0;
memcpy(&tmp, p, 3); memcpy(&tmp, p, 3);
return _mm_cvtsi32_si128(tmp); return _mm_cvtsi32_si128(tmp);
} }
static void store3(void* p, __m128i v) { static void
store3(void *p, __m128i v)
{
int tmp = _mm_cvtsi128_si32(v); int tmp = _mm_cvtsi128_si32(v);
memcpy(p, &tmp, 3); memcpy(p, &tmp, 3);
} }
void png_read_filter_row_sub3_sse2(png_row_infop row_info, png_bytep row, void
png_read_filter_row_sub3_sse2(png_row_infop row_info, png_bytep row,
png_const_bytep prev) png_const_bytep prev)
{ {
/* The Sub filter predicts each pixel as the previous pixel, a. /* The Sub filter predicts each pixel as the previous pixel, a.
...@@ -81,7 +90,8 @@ void png_read_filter_row_sub3_sse2(png_row_infop row_info, png_bytep row, ...@@ -81,7 +90,8 @@ void png_read_filter_row_sub3_sse2(png_row_infop row_info, png_bytep row,
PNG_UNUSED(prev) PNG_UNUSED(prev)
} }
void png_read_filter_row_sub4_sse2(png_row_infop row_info, png_bytep row, void
png_read_filter_row_sub4_sse2(png_row_infop row_info, png_bytep row,
png_const_bytep prev) png_const_bytep prev)
{ {
/* The Sub filter predicts each pixel as the previous pixel, a. /* The Sub filter predicts each pixel as the previous pixel, a.
...@@ -106,7 +116,8 @@ void png_read_filter_row_sub4_sse2(png_row_infop row_info, png_bytep row, ...@@ -106,7 +116,8 @@ void png_read_filter_row_sub4_sse2(png_row_infop row_info, png_bytep row,
PNG_UNUSED(prev) PNG_UNUSED(prev)
} }
void png_read_filter_row_avg3_sse2(png_row_infop row_info, png_bytep row, void
png_read_filter_row_avg3_sse2(png_row_infop row_info, png_bytep row,
png_const_bytep prev) png_const_bytep prev)
{ {
/* The Avg filter predicts each pixel as the (truncated) average of a and b. /* The Avg filter predicts each pixel as the (truncated) average of a and b.
...@@ -161,7 +172,8 @@ void png_read_filter_row_avg3_sse2(png_row_infop row_info, png_bytep row, ...@@ -161,7 +172,8 @@ void png_read_filter_row_avg3_sse2(png_row_infop row_info, png_bytep row,
} }
} }
void png_read_filter_row_avg4_sse2(png_row_infop row_info, png_bytep row, void
png_read_filter_row_avg4_sse2(png_row_infop row_info, png_bytep row,
png_const_bytep prev) png_const_bytep prev)
{ {
/* The Avg filter predicts each pixel as the (truncated) average of a and b. /* The Avg filter predicts each pixel as the (truncated) average of a and b.
...@@ -198,7 +210,9 @@ void png_read_filter_row_avg4_sse2(png_row_infop row_info, png_bytep row, ...@@ -198,7 +210,9 @@ void png_read_filter_row_avg4_sse2(png_row_infop row_info, png_bytep row,
} }
/* Returns |x| for 16-bit lanes. */ /* Returns |x| for 16-bit lanes. */
static __m128i abs_i16(__m128i x) { static __m128i
abs_i16(__m128i x)
{
#if PNG_INTEL_SSE_IMPLEMENTATION >= 2 #if PNG_INTEL_SSE_IMPLEMENTATION >= 2
return _mm_abs_epi16(x); return _mm_abs_epi16(x);
#else #else
...@@ -217,7 +231,9 @@ static __m128i abs_i16(__m128i x) { ...@@ -217,7 +231,9 @@ static __m128i abs_i16(__m128i x) {
} }
/* Bytewise c ? t : e. */ /* Bytewise c ? t : e. */
static __m128i if_then_else(__m128i c, __m128i t, __m128i e) { static __m128i
if_then_else(__m128i c, __m128i t, __m128i e)
{
#if PNG_INTEL_SSE_IMPLEMENTATION >= 3 #if PNG_INTEL_SSE_IMPLEMENTATION >= 3
return _mm_blendv_epi8(e,t,c); return _mm_blendv_epi8(e,t,c);
#else #else
...@@ -225,7 +241,8 @@ static __m128i if_then_else(__m128i c, __m128i t, __m128i e) { ...@@ -225,7 +241,8 @@ static __m128i if_then_else(__m128i c, __m128i t, __m128i e) {
#endif #endif
} }
void png_read_filter_row_paeth3_sse2(png_row_infop row_info, png_bytep row, void
png_read_filter_row_paeth3_sse2(png_row_infop row_info, png_bytep row,
png_const_bytep prev) png_const_bytep prev)
{ {
/* Paeth tries to predict pixel d using the pixel to the left of it, a, /* Paeth tries to predict pixel d using the pixel to the left of it, a,
...@@ -324,7 +341,8 @@ void png_read_filter_row_paeth3_sse2(png_row_infop row_info, png_bytep row, ...@@ -324,7 +341,8 @@ void png_read_filter_row_paeth3_sse2(png_row_infop row_info, png_bytep row,
} }
} }
void png_read_filter_row_paeth4_sse2(png_row_infop row_info, png_bytep row, void
png_read_filter_row_paeth4_sse2(png_row_infop row_info, png_bytep row,
png_const_bytep prev) png_const_bytep prev)
{ {
/* Paeth tries to predict pixel d using the pixel to the left of it, a, /* Paeth tries to predict pixel d using the pixel to the left of it, a,
......
...@@ -9,9 +9,9 @@ libpng-manual.txt - A description on how to use and modify libpng ...@@ -9,9 +9,9 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on: Based on:
libpng version 1.6.36, December 2018, through 1.6.47 - February 2025 libpng version 1.6.36, December 2018, through 1.6.54 - January 2026
Updated and distributed by Cosmin Truta Updated and distributed by Cosmin Truta
Copyright (c) 2018-2025 Cosmin Truta Copyright (c) 2018-2026 Cosmin Truta
libpng versions 0.97, January 1998, through 1.6.35 - July 2018 libpng versions 0.97, January 1998, through 1.6.35 - July 2018
Updated and distributed by Glenn Randers-Pehrson Updated and distributed by Glenn Randers-Pehrson
...@@ -65,18 +65,22 @@ Libpng was written as a companion to the PNG specification, as a way ...@@ -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 of reducing the amount of time and effort it takes to support the PNG
file format in application programs. 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 a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2004 (E)) at
<https://www.w3.org/TR/2003/REC-PNG-20031110/>. <https://www.w3.org/TR/2003/REC-PNG-20031110/>.
The W3C and ISO documents have identical technical content. The W3C and ISO documents have identical technical content.
The PNG-1.2 specification is available at The PNG-1.2 specification is available at
<https://png-mng.sourceforge.io/pub/png/spec/1.2/>. <https://www.libpng.org/pub/png/spec/1.2/>.
It is technically equivalent It is technically equivalent to the PNG specification (Second Edition)
to the PNG specification (second edition) but has some additional material. but has some additional material.
The PNG-1.0 specification is available as RFC 2083 at 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>. W3C Recommendation at <https://www.w3.org/TR/REC-png-961001>.
Some additional chunks are described in the special-purpose public chunks Some additional chunks are described in the special-purpose public chunks
...@@ -3351,19 +3355,6 @@ Here is an example of writing two private chunks, prVt and miNE: ...@@ -3351,19 +3355,6 @@ Here is an example of writing two private chunks, prVt and miNE:
/* Needed because miNE is not safe-to-copy */ /* Needed because miNE is not safe-to-copy */
png_set_keep_unknown_chunks(png, PNG_HANDLE_CHUNK_ALWAYS, png_set_keep_unknown_chunks(png, PNG_HANDLE_CHUNK_ALWAYS,
(png_bytep) "miNE", 1); (png_bytep) "miNE", 1);
# if PNG_LIBPNG_VER < 10600
/* Deal with unknown chunk location bug in 1.5.x and earlier */
png_set_unknown_chunk_location(png, info, 0, PNG_HAVE_IHDR);
png_set_unknown_chunk_location(png, info, 1, PNG_AFTER_IDAT);
# endif
# if PNG_LIBPNG_VER < 10500
/* PNG_AFTER_IDAT writes two copies of the chunk prior to libpng-1.5.0,
* one before IDAT and another after IDAT, so don't use it; only use
* PNG_HAVE_IHDR location. This call resets the location previously
* set by assignment and png_set_unknown_chunk_location() for chunk 1.
*/
png_set_unknown_chunk_location(png, info, 1, PNG_HAVE_IHDR);
# endif
#endif #endif
The high-level write interface The high-level write interface
...@@ -4089,7 +4080,7 @@ READ APIs ...@@ -4089,7 +4080,7 @@ READ APIs
is filled in from the PNG header in the file. is filled in from the PNG header in the file.
int png_image_begin_read_from_stdio (png_imagep image, int png_image_begin_read_from_stdio (png_imagep image,
FILE* file) FILE *file)
The PNG header is read from the stdio FILE object. The PNG header is read from the stdio FILE object.
...@@ -4164,7 +4155,7 @@ be written: ...@@ -4164,7 +4155,7 @@ be written:
int convert_to_8_bit, const void *buffer, int convert_to_8_bit, const void *buffer,
png_int_32 row_stride, const void *colormap) 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 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 (png_uint_16) data then setting convert_to_8_bit will cause the output to be
......
.TH LIBPNG 3 "February 18, 2025" .TH LIBPNG 3 "January 12, 2026"
.SH NAME .SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.47 libpng \- Portable Network Graphics (PNG) Reference Library 1.6.54
.SH SYNOPSIS .SH SYNOPSIS
\fB#include <png.h>\fP \fB#include <png.h>\fP
...@@ -223,7 +223,7 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.6.47 ...@@ -223,7 +223,7 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.6.47
\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_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 \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,9 +528,9 @@ libpng-manual.txt - A description on how to use and modify libpng ...@@ -528,9 +528,9 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on: Based on:
libpng version 1.6.36, December 2018, through 1.6.47 - February 2025 libpng version 1.6.36, December 2018, through 1.6.54 - January 2026
Updated and distributed by Cosmin Truta Updated and distributed by Cosmin Truta
Copyright (c) 2018-2025 Cosmin Truta Copyright (c) 2018-2026 Cosmin Truta
libpng versions 0.97, January 1998, through 1.6.35 - July 2018 libpng versions 0.97, January 1998, through 1.6.35 - July 2018
Updated and distributed by Glenn Randers-Pehrson Updated and distributed by Glenn Randers-Pehrson
...@@ -584,18 +584,22 @@ Libpng was written as a companion to the PNG specification, as a way ...@@ -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 of reducing the amount of time and effort it takes to support the PNG
file format in application programs. 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 a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2004 (E)) at
<https://www.w3.org/TR/2003/REC-PNG-20031110/>. <https://www.w3.org/TR/2003/REC-PNG-20031110/>.
The W3C and ISO documents have identical technical content. The W3C and ISO documents have identical technical content.
The PNG-1.2 specification is available at The PNG-1.2 specification is available at
<https://png-mng.sourceforge.io/pub/png/spec/1.2/>. <https://www.libpng.org/pub/png/spec/1.2/>.
It is technically equivalent It is technically equivalent to the PNG specification (Second Edition)
to the PNG specification (second edition) but has some additional material. but has some additional material.
The PNG-1.0 specification is available as RFC 2083 at 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>. W3C Recommendation at <https://www.w3.org/TR/REC-png-961001>.
Some additional chunks are described in the special-purpose public chunks Some additional chunks are described in the special-purpose public chunks
...@@ -3870,19 +3874,6 @@ Here is an example of writing two private chunks, prVt and miNE: ...@@ -3870,19 +3874,6 @@ Here is an example of writing two private chunks, prVt and miNE:
/* Needed because miNE is not safe-to-copy */ /* Needed because miNE is not safe-to-copy */
png_set_keep_unknown_chunks(png, PNG_HANDLE_CHUNK_ALWAYS, png_set_keep_unknown_chunks(png, PNG_HANDLE_CHUNK_ALWAYS,
(png_bytep) "miNE", 1); (png_bytep) "miNE", 1);
# if PNG_LIBPNG_VER < 10600
/* Deal with unknown chunk location bug in 1.5.x and earlier */
png_set_unknown_chunk_location(png, info, 0, PNG_HAVE_IHDR);
png_set_unknown_chunk_location(png, info, 1, PNG_AFTER_IDAT);
# endif
# if PNG_LIBPNG_VER < 10500
/* PNG_AFTER_IDAT writes two copies of the chunk prior to libpng-1.5.0,
* one before IDAT and another after IDAT, so don't use it; only use
* PNG_HAVE_IHDR location. This call resets the location previously
* set by assignment and png_set_unknown_chunk_location() for chunk 1.
*/
png_set_unknown_chunk_location(png, info, 1, PNG_HAVE_IHDR);
# endif
#endif #endif
.SS The high-level write interface .SS The high-level write interface
...@@ -4608,7 +4599,7 @@ READ APIs ...@@ -4608,7 +4599,7 @@ READ APIs
is filled in from the PNG header in the file. is filled in from the PNG header in the file.
int png_image_begin_read_from_stdio (png_imagep image, int png_image_begin_read_from_stdio (png_imagep image,
FILE* file) FILE *file)
The PNG header is read from the stdio FILE object. The PNG header is read from the stdio FILE object.
...@@ -4683,7 +4674,7 @@ be written: ...@@ -4683,7 +4674,7 @@ be written:
int convert_to_8_bit, const void *buffer, int convert_to_8_bit, const void *buffer,
png_int_32 row_stride, const void *colormap) 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 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 (png_uint_16) data then setting convert_to_8_bit will cause the output to be
......
.TH LIBPNGPF 3 "February 18, 2025" .TH LIBPNGPF 3 "January 12, 2026"
.SH NAME .SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.47 libpng \- Portable Network Graphics (PNG) Reference Library 1.6.54
(private functions)
.SH SYNOPSIS .SH SYNOPSIS
\fB#include \fI"pngpriv.h" \fB#include "pngpriv.h"\fP
\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.
.SH DESCRIPTION .SH DESCRIPTION
The functions previously listed here are used privately by libpng and are not As of libpng version 1.5.1, this manual is no longer maintained. The private
available for use by applications. They are not "exported" to applications function prototypes, declared in private header files, should not be accessed
using shared libraries. by applications.
.SH "SEE ALSO" .SH "SEE ALSO"
.BR "png"(5), " libpng"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5) .BR "libpng"(3)
.SH AUTHORS .SH AUTHORS
Cosmin Truta, Glenn Randers-Pehrson Cosmin Truta, Glenn Randers-Pehrson
#! /bin/sh #! /bin/sh
# Common wrapper for a few potentially missing GNU and other programs. # 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 # 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. # Originally written by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
# This program is free software; you can redistribute it and/or modify # This program is free software; you can redistribute it and/or modify
...@@ -228,9 +228,9 @@ give_advice "$1" | sed -e '1s/^/WARNING: /' \ ...@@ -228,9 +228,9 @@ give_advice "$1" | sed -e '1s/^/WARNING: /' \
exit $st exit $st
# Local variables: # 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-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H" # time-stamp-format: "%Y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC0" # time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC" # time-stamp-end: "; # UTC"
# End: # End:
.TH PNG 5 "February 18, 2025" .TH PNG 5 "January 12, 2026"
.SH NAME .SH NAME
png \- Portable Network Graphics (PNG) format png \- Portable Network Graphics (PNG) format
...@@ -6,59 +6,76 @@ png \- Portable Network Graphics (PNG) format ...@@ -6,59 +6,76 @@ png \- Portable Network Graphics (PNG) format
PNG (Portable Network Graphics) is an extensible file format for the PNG (Portable Network Graphics) is an extensible file format for the
lossless, portable, well-compressed storage of raster images. PNG lossless, portable, well-compressed storage of raster images. PNG
provides a patent-free replacement for GIF, and can also replace many provides a patent-free replacement for GIF, and can also replace many
common uses of TIFF. Indexed-color, grayscale, and truecolor images are common uses of TIFF. Indexed-color, grayscale, and truecolor images
supported, plus an optional alpha channel. Sample depths range from are supported, plus an optional alpha channel. Sample depths range
1 to 16 bits. from 1 to 16 bits.
.br .P
PNG is designed to work well in online viewing applications, such PNG is designed to work well in online viewing applications, such
as the World Wide Web, so it is fully streamable with a progressive as the World Wide Web, so it is fully streamable with a progressive
display option. PNG is robust, providing both full file integrity display option. PNG is robust, providing both full file integrity
checking and fast, simple detection of common transmission errors. checking and fast, simple detection of common transmission errors.
Also, PNG can store gamma and chromaticity data for improved color Also, PNG can store color space data for improved color matching on
matching on heterogeneous platforms. heterogeneous platforms.
.SH "SEE ALSO" .SH "SEE ALSO"
.BR "libpng"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5) .BR "libpng"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5)
.LP .LP
PNG Specification (Third Edition) Candidate Recommendation Draft, January 2025: Portable Network Graphics (PNG) Specification (Third Edition):
.IP .IP
.br .br
https://www.w3.org/TR/2025/CRD-png-3-20250121/ W3C Recommendation 24 June 2025
.br
https://www.w3.org/TR/2025/REC-png-3-20250624/
.LP .LP
PNG Specification (Second Edition), November 2003: Portable Network Graphics (PNG) Specification (Second Edition):
.IP .IP
.br .br
ISO/IEC 15948:2004(E)
.br
https://www.iso.org/standard/29581.html
.IP
.br
W3C Recommendation 10 November 2003
.br
https://www.w3.org/TR/2003/REC-PNG-20031110/ https://www.w3.org/TR/2003/REC-PNG-20031110/
.LP .LP
PNG 1.2 Specification, July 1999: Portable Network Graphics (PNG) Specification Version 1.2:
.IP .IP
.br .br
https://png-mng.sourceforge.io/pub/png/spec/1.2/ Published by the PNG Development Group on 14 July 1999
.br
https://www.libpng.org/pub/png/spec/1.2/
.LP .LP
PNG 1.0 Specification, October 1996: Portable Network Graphics (PNG) Specification Version 1.1:
.IP .IP
.br .br
RFC 2083 Published by the PNG Development Group on 15 February 1999
.br
https://www.libpng.org/pub/png/spec/1.1/
.LP
Portable Network Graphics (PNG) Specification Version 1.0:
.IP
.br
IETF RFC 2083, March 1997
.br .br
https://www.ietf.org/rfc/rfc2083.txt https://www.ietf.org/rfc/rfc2083.txt
.IP .IP
.br .br
or W3C Recommendation W3C Recommendation 1 October 1996
.br .br
https://www.w3.org/TR/REC-png-961001 https://www.w3.org/TR/REC-png-961001
.SH AUTHORS .SH AUTHORS
This man page: Glenn Randers-Pehrson, Cosmin Truta This man page: Glenn Randers-Pehrson, Cosmin Truta, Chris Lilley.
.LP
PNG Specification (Third Edition): Chris Blume et al.
.LP
PNG Specification (Second Edition): David Duce et al.
.LP .LP
Portable Network Graphics (PNG) Specification (Second Edition) PNG Specification Version 1.2: Glenn Randers-Pehrson et al.
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.
.LP .LP
Portable Network Graphics (PNG) Specification Version 1.2 (July 8, 1999): PNG Specification Version 1.1: Glenn Randers-Pehrson et al.
Glenn Randers-Pehrson and others.
.LP .LP
Portable Network Graphics (PNG) Specification Version 1.0 (October 1, 1996): PNG Specification Version 1.0: Thomas Boutell et al.
Thomas Boutell and others.
.\" end of man page .\" end of man page
/* png.c - location for general purpose libpng functions /* png.c - location for general purpose libpng functions
* *
* Copyright (c) 2018-2025 Cosmin Truta * Copyright (c) 2018-2026 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
#include "pngpriv.h" #include "pngpriv.h"
/* Generate a compiler error if there is an old png.h in the search path. */ /* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_6_47 Your_png_h_is_not_version_1_6_47; typedef png_libpng_version_1_6_54 Your_png_h_is_not_version_1_6_54;
/* Sanity check the chunks definitions - PNG_KNOWN_CHUNKS from pngpriv.h and the /* Sanity check the chunks definitions - PNG_KNOWN_CHUNKS from pngpriv.h and the
* corresponding macro definitions. This causes a compile time failure if * corresponding macro definitions. This causes a compile time failure if
...@@ -101,16 +101,23 @@ png_sig_cmp(png_const_bytep sig, size_t start, size_t num_to_check) ...@@ -101,16 +101,23 @@ png_sig_cmp(png_const_bytep sig, size_t start, size_t num_to_check)
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
/* Function to allocate memory for zlib */ /* Function to allocate memory for zlib */
PNG_FUNCTION(voidpf /* PRIVATE */, PNG_FUNCTION(voidpf /* PRIVATE */,
png_zalloc,(voidpf png_ptr, uInt items, uInt size),PNG_ALLOCATED) png_zalloc,(voidpf png_ptr, uInt items, uInt size),
PNG_ALLOCATED)
{ {
png_alloc_size_t num_bytes = size; png_alloc_size_t num_bytes = size;
if (png_ptr == NULL) if (png_ptr == NULL)
return NULL; return NULL;
if (items >= (~(png_alloc_size_t)0)/size) /* This check against overflow is vestigial, dating back from
* the old times when png_zalloc used to be an exported function.
* We're still keeping it here for now, as an extra-cautious
* prevention against programming errors inside zlib, although it
* should rather be a debug-time assertion instead.
*/
if (size != 0 && items >= (~(png_alloc_size_t)0) / size)
{ {
png_warning (png_voidcast(png_structrp, png_ptr), png_warning(png_voidcast(png_structrp, png_ptr),
"Potential overflow in png_zalloc()"); "Potential overflow in png_zalloc()");
return NULL; return NULL;
} }
...@@ -238,10 +245,6 @@ png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver) ...@@ -238,10 +245,6 @@ png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver)
png_warning(png_ptr, m); png_warning(png_ptr, m);
#endif #endif
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
png_ptr->flags = 0;
#endif
return 0; return 0;
} }
...@@ -255,7 +258,8 @@ png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver) ...@@ -255,7 +258,8 @@ png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver)
PNG_FUNCTION(png_structp /* PRIVATE */, PNG_FUNCTION(png_structp /* PRIVATE */,
png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr, png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr, png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED) png_malloc_ptr malloc_fn, png_free_ptr free_fn),
PNG_ALLOCATED)
{ {
png_struct create_struct; png_struct create_struct;
# ifdef PNG_SETJMP_SUPPORTED # ifdef PNG_SETJMP_SUPPORTED
...@@ -359,7 +363,8 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr, ...@@ -359,7 +363,8 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
/* Allocate the memory for an info_struct for the application. */ /* Allocate the memory for an info_struct for the application. */
PNG_FUNCTION(png_infop,PNGAPI PNG_FUNCTION(png_infop,PNGAPI
png_create_info_struct,(png_const_structrp png_ptr),PNG_ALLOCATED) png_create_info_struct,(png_const_structrp png_ptr),
PNG_ALLOCATED)
{ {
png_inforp info_ptr; png_inforp info_ptr;
...@@ -700,7 +705,7 @@ png_get_io_ptr(png_const_structrp png_ptr) ...@@ -700,7 +705,7 @@ png_get_io_ptr(png_const_structrp png_ptr)
* function of your own because "FILE *" isn't necessarily available. * function of your own because "FILE *" isn't necessarily available.
*/ */
void PNGAPI void PNGAPI
png_init_io(png_structrp png_ptr, png_FILE_p fp) png_init_io(png_structrp png_ptr, FILE *fp)
{ {
png_debug(1, "in png_init_io"); png_debug(1, "in png_init_io");
...@@ -815,8 +820,8 @@ png_get_copyright(png_const_structrp png_ptr) ...@@ -815,8 +820,8 @@ png_get_copyright(png_const_structrp png_ptr)
return PNG_STRING_COPYRIGHT return PNG_STRING_COPYRIGHT
#else #else
return PNG_STRING_NEWLINE \ return PNG_STRING_NEWLINE \
"libpng version 1.6.47" PNG_STRING_NEWLINE \ "libpng version 1.6.54" PNG_STRING_NEWLINE \
"Copyright (c) 2018-2025 Cosmin Truta" PNG_STRING_NEWLINE \ "Copyright (c) 2018-2026 Cosmin Truta" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \ "Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \
PNG_STRING_NEWLINE \ PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
...@@ -1491,7 +1496,7 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy) ...@@ -1491,7 +1496,7 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy)
} }
#endif /* COLORSPACE */ #endif /* COLORSPACE */
#ifdef PNG_iCCP_SUPPORTED #ifdef PNG_READ_iCCP_SUPPORTED
/* Error message generation */ /* Error message generation */
static char static char
png_icc_tag_char(png_uint_32 byte) png_icc_tag_char(png_uint_32 byte)
...@@ -1567,9 +1572,7 @@ png_icc_profile_error(png_const_structrp png_ptr, png_const_charp name, ...@@ -1567,9 +1572,7 @@ png_icc_profile_error(png_const_structrp png_ptr, png_const_charp name,
return 0; return 0;
} }
#endif /* iCCP */
#ifdef PNG_READ_iCCP_SUPPORTED
/* Encoded value of D50 as an ICC XYZNumber. From the ICC 2010 spec the value /* Encoded value of D50 as an ICC XYZNumber. From the ICC 2010 spec the value
* is XYZ(0.9642,1.0,0.8249), which scales to: * is XYZ(0.9642,1.0,0.8249), which scales to:
* *
...@@ -2257,8 +2260,8 @@ PNG_FP_End: ...@@ -2257,8 +2260,8 @@ PNG_FP_End:
int int
png_check_fp_string(png_const_charp string, size_t size) png_check_fp_string(png_const_charp string, size_t size)
{ {
int state=0; int state = 0;
size_t char_index=0; size_t char_index = 0;
if (png_check_fp_number(string, size, &state, &char_index) != 0 && if (png_check_fp_number(string, size, &state, &char_index) != 0 &&
(char_index == size || string[char_index] == 0)) (char_index == size || string[char_index] == 0))
...@@ -3969,7 +3972,7 @@ png_image_free_function(png_voidp argument) ...@@ -3969,7 +3972,7 @@ png_image_free_function(png_voidp argument)
# ifdef PNG_STDIO_SUPPORTED # ifdef PNG_STDIO_SUPPORTED
if (cp->owned_file != 0) if (cp->owned_file != 0)
{ {
FILE *fp = png_voidcast(FILE*, cp->png_ptr->io_ptr); FILE *fp = png_voidcast(FILE *, cp->png_ptr->io_ptr);
cp->owned_file = 0; cp->owned_file = 0;
/* Ignore errors here. */ /* Ignore errors here. */
......
This diff is collapsed.
/* pngconf.h - machine-configurable file for libpng /* pngconf.h - machine-configurable file for libpng
* *
* libpng version 1.6.47 * libpng version 1.6.54
* *
* Copyright (c) 2018-2025 Cosmin Truta * Copyright (c) 2018-2026 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson * Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
...@@ -219,25 +219,13 @@ ...@@ -219,25 +219,13 @@
/* NOTE: PNGCBAPI always defaults to PNGCAPI. */ /* NOTE: PNGCBAPI always defaults to PNGCAPI. */
# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD) # 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 # 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) # define PNG_DLL_EXPORT __declspec(dllexport)
# ifndef PNG_DLL_IMPORT # ifndef PNG_DLL_IMPORT
# define PNG_DLL_IMPORT __declspec(dllimport) # define PNG_DLL_IMPORT __declspec(dllimport)
# endif # endif
# endif /* compiler */
#else /* !Windows */ #else /* !Windows */
# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) # if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
...@@ -479,7 +467,7 @@ ...@@ -479,7 +467,7 @@
#if CHAR_BIT == 8 && UCHAR_MAX == 255 #if CHAR_BIT == 8 && UCHAR_MAX == 255
typedef unsigned char png_byte; typedef unsigned char png_byte;
#else #else
# error "libpng requires 8-bit bytes" # error libpng requires 8-bit bytes
#endif #endif
#if INT_MIN == -32768 && INT_MAX == 32767 #if INT_MIN == -32768 && INT_MAX == 32767
...@@ -487,7 +475,7 @@ ...@@ -487,7 +475,7 @@
#elif SHRT_MIN == -32768 && SHRT_MAX == 32767 #elif SHRT_MIN == -32768 && SHRT_MAX == 32767
typedef short png_int_16; typedef short png_int_16;
#else #else
# error "libpng requires a signed 16-bit type" # error libpng requires a signed 16-bit integer type
#endif #endif
#if UINT_MAX == 65535 #if UINT_MAX == 65535
...@@ -495,7 +483,7 @@ ...@@ -495,7 +483,7 @@
#elif USHRT_MAX == 65535 #elif USHRT_MAX == 65535
typedef unsigned short png_uint_16; typedef unsigned short png_uint_16;
#else #else
# error "libpng requires an unsigned 16-bit type" # error libpng requires an unsigned 16-bit integer type
#endif #endif
#if INT_MIN < -2147483646 && INT_MAX > 2147483646 #if INT_MIN < -2147483646 && INT_MAX > 2147483646
...@@ -503,7 +491,7 @@ ...@@ -503,7 +491,7 @@
#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646 #elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646
typedef long int png_int_32; typedef long int png_int_32;
#else #else
# error "libpng requires a signed 32-bit (or more) type" # error libpng requires a signed 32-bit (or longer) integer type
#endif #endif
#if UINT_MAX > 4294967294U #if UINT_MAX > 4294967294U
...@@ -511,7 +499,7 @@ ...@@ -511,7 +499,7 @@
#elif ULONG_MAX > 4294967294U #elif ULONG_MAX > 4294967294U
typedef unsigned long int png_uint_32; typedef unsigned long int png_uint_32;
#else #else
# error "libpng requires an unsigned 32-bit (or more) type" # error libpng requires an unsigned 32-bit (or longer) integer type
#endif #endif
/* Prior to 1.6.0, it was possible to disable the use of size_t and ptrdiff_t. /* 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; ...@@ -592,10 +580,6 @@ typedef const png_fixed_point * png_const_fixed_point_p;
typedef size_t * png_size_tp; typedef size_t * png_size_tp;
typedef const size_t * png_const_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 #ifdef PNG_FLOATING_POINT_SUPPORTED
typedef double * png_doublep; typedef double * png_doublep;
typedef const double * png_const_doublep; typedef const double * png_const_doublep;
...@@ -617,6 +601,15 @@ typedef double * * png_doublepp; ...@@ -617,6 +601,15 @@ typedef double * * png_doublepp;
/* Pointers to pointers to pointers; i.e., pointer to array */ /* Pointers to pointers to pointers; i.e., pointer to array */
typedef char * * * png_charppp; 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 /* PNG_BUILDING_SYMBOL_TABLE */
#endif /* PNGCONF_H */ #endif /* PNGCONF_H */
/* 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) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
...@@ -10,6 +10,10 @@ ...@@ -10,6 +10,10 @@
* and license in png.h * 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 /* Define PNG_DEBUG at compile time for debugging information. Higher
* numbers for PNG_DEBUG mean more debugging information. This has * numbers for PNG_DEBUG mean more debugging information. This has
* only been added since version 0.95 so it is not implemented throughout * only been added since version 0.95 so it is not implemented throughout
...@@ -34,9 +38,6 @@ ...@@ -34,9 +38,6 @@
#define PNGDEBUG_H #define PNGDEBUG_H
/* These settings control the formatting of messages in png.c and pngerror.c */ /* These settings control the formatting of messages in png.c and pngerror.c */
/* Moved to pngdebug.h at 1.5.0 */ /* Moved to pngdebug.h at 1.5.0 */
# ifndef PNG_LITERAL_SHARP
# define PNG_LITERAL_SHARP 0x23
# endif
# ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET # ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET
# define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b # define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b
# endif # endif
......
This diff is collapsed.
/* pngget.c - retrieval of values from info struct /* 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) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
...@@ -122,8 +122,8 @@ png_get_compression_type(png_const_structrp png_ptr, png_const_inforp info_ptr) ...@@ -122,8 +122,8 @@ png_get_compression_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
} }
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp png_get_x_pixels_per_meter(png_const_structrp png_ptr,
info_ptr) png_const_inforp info_ptr)
{ {
#ifdef PNG_pHYs_SUPPORTED #ifdef PNG_pHYs_SUPPORTED
png_debug(1, "in png_get_x_pixels_per_meter"); png_debug(1, "in png_get_x_pixels_per_meter");
...@@ -143,8 +143,8 @@ png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp ...@@ -143,8 +143,8 @@ png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
} }
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp png_get_y_pixels_per_meter(png_const_structrp png_ptr,
info_ptr) png_const_inforp info_ptr)
{ {
#ifdef PNG_pHYs_SUPPORTED #ifdef PNG_pHYs_SUPPORTED
png_debug(1, "in png_get_y_pixels_per_meter"); png_debug(1, "in png_get_y_pixels_per_meter");
...@@ -186,8 +186,8 @@ png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr) ...@@ -186,8 +186,8 @@ png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
#ifdef PNG_FLOATING_POINT_SUPPORTED #ifdef PNG_FLOATING_POINT_SUPPORTED
float PNGAPI float PNGAPI
png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp png_get_pixel_aspect_ratio(png_const_structrp png_ptr,
info_ptr) png_const_inforp info_ptr)
{ {
#ifdef PNG_READ_pHYs_SUPPORTED #ifdef PNG_READ_pHYs_SUPPORTED
png_debug(1, "in png_get_pixel_aspect_ratio"); png_debug(1, "in png_get_pixel_aspect_ratio");
...@@ -737,7 +737,6 @@ png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, ...@@ -737,7 +737,6 @@ png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
} }
return 0; return 0;
} }
#endif #endif
......
/* 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) 1998-2002,2004,2006-2013,2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
...@@ -10,43 +10,20 @@ ...@@ -10,43 +10,20 @@
* and license in png.h * and license in png.h
*/ */
/* png_info is a structure that holds the information in a PNG file so #ifndef PNGPRIV_H
* that the application can find out the characteristics of the image. # error This file must not be included by applications; please include <png.h>
* If you are reading the file, this structure will tell you what is #endif
* 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 /* INTERNAL, PRIVATE definition of a PNG.
* call png_write_info().
*
* The names chosen should be very close to the PNG specification, so
* consult that document for information about the meaning of each field.
*
* With libpng < 0.95, it was only possible to directly set and read the
* the values in the png_info_struct, which meant that the contents and
* order of the values had to remain fixed. With libpng 0.95 and later,
* however, there are now functions that abstract the contents of
* png_info_struct from the application, so this makes it easier to use
* libpng with dynamic libraries, and even makes it possible to use
* libraries that don't have all of the libpng ancillary chunk-handing
* functionality. In libpng-1.5.0 this was moved into a separate private
* file that is not visible to applications.
* *
* The following members may have allocated storage attached that should be * png_info is a modifiable description of a PNG datastream. The fields inside
* cleaned up before the structure is discarded: palette, trans, text, * this structure are accessed through png_get_<CHUNK>() functions and modified
* pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile, * using png_set_<CHUNK>() functions.
* 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 * Some functions in libpng do directly access members of png_info. However,
* change these members go through the corresponding png_set_* * this should be avoided. png_struct objects contain members which hold
* functions. A function to clear these members is available: see * caches, sometimes optimised, of the values from png_info objects, and
* png_free_data(). The png_set_* functions do not depend on being * png_info is not passed to the functions which read and write image data.
* 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.
*/ */
#ifndef PNGINFO_H #ifndef PNGINFO_H
#define PNGINFO_H #define PNGINFO_H
......
/* pnglibconf.h - library build configuration */ /* pnglibconf.h - library build configuration */
/* libpng version 1.6.47 */ /* libpng version 1.6.54 */
/* Copyright (c) 2018-2025 Cosmin Truta */ /* Copyright (c) 2018-2026 Cosmin Truta */
/* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */ /* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */
/* This code is released under the libpng license. */ /* This code is released under the libpng license. */
......
This diff is collapsed.
/* pngpread.c - read a png file in push mode /* 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) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger * Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
...@@ -229,6 +229,14 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) ...@@ -229,6 +229,14 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
png_benign_error(png_ptr, "Too many IDATs found"); 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 (chunk_name == png_IHDR)
{ {
if (png_ptr->push_length != 13) if (png_ptr->push_length != 13)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment