Browse Source

Upgrade bundled libpng from 1.6.16 to 1.6.37

Release: 1.6.37 - April 14, 2019

For further details see README.bundled-libs.txt.
pull/48/head
Albrecht Schlosser 5 years ago
parent
commit
8c4930a7d7
  1. 12
      README.bundled-libs.txt
  2. 68
      png/ANNOUNCE
  3. 1071
      png/CHANGES
  4. 15
      png/CMakeLists.txt
  5. 143
      png/INSTALL
  6. 147
      png/LICENSE
  7. 5
      png/Makefile
  8. 128
      png/README
  9. 48
      png/TODO
  10. 673
      png/libpng-manual.txt
  11. 1098
      png/libpng.3
  12. 18
      png/libpngpf.3
  13. 30
      png/makedepend
  14. 70
      png/png.5
  15. 492
      png/png.c
  16. 923
      png/png.h
  17. 93
      png/pngconf.h
  18. 9
      png/pngdebug.h
  19. 22
      png/pngerror.c
  20. 74
      png/pngget.c
  21. 21
      png/pnginfo.h
  22. 32
      png/pnglibconf.h
  23. 15
      png/pngmem.c
  24. 182
      png/pngpread.c
  25. 570
      png/pngpriv.h
  26. 294
      png/pngread.c
  27. 18
      png/pngrio.c
  28. 360
      png/pngrtran.c
  29. 507
      png/pngrutil.c
  30. 279
      png/pngset.c
  31. 70
      png/pngstruct.h
  32. 75
      png/pngtrans.c
  33. 16
      png/pngwio.c
  34. 674
      png/pngwrite.c
  35. 33
      png/pngwtran.c
  36. 1172
      png/pngwutil.c
  37. 44
      test/makedepend
  38. 2
      zlib/makedepend

12
README.bundled-libs.txt

@ -14,21 +14,21 @@ Current versions of bundled libraries: @@ -14,21 +14,21 @@ Current versions of bundled libraries:
** work in progress -- not yet completely upgraded **
Library Version Release date FLTK Version Status
Library Version Release date FLTK Version
--------------------------------------------------------------------------
jpeg jpeg-9c 2018-01-14 1.4.0
nanosvg f31098fa85 [1] 2019-05-23 1.4.0
png libpng-1.6.34 2017-09-29 1.4.0
zlib zlib-1.2.11 2017-01-15 1.4.0 DONE
png libpng-1.6.37 2019-04-14 1.4.0
zlib zlib-1.2.11 2017-01-15 1.4.0
Previous versions of bundled libraries:
Library Version Release date FLTK Version
------------------------------------------------------------------
nanosvg ce81a6577c [1] 2018-07-01 1.4.0
jpeg jpeg-9a 2014-01-19 1.3.4
png libpng-1.6.16 2014-12-22 1.3.4
zlib zlib-1.2.8 2013-04-28 1.3.4
jpeg jpeg-9a 2014-01-19 1.3.5
png libpng-1.6.16 2014-12-22 1.3.5
zlib zlib-1.2.8 2013-04-28 1.3.5
[1] Git commit in: https://github.com/fltk/nanosvg
See also git tag 'fltk_yyyy-mm-dd' where yyyy-mm-dd == "Release date".

68
png/ANNOUNCE

@ -1,41 +1,47 @@ @@ -1,41 +1,47 @@
Libpng 1.6.16 - December 22, 2014
libpng 1.6.37 - April 14, 2019
==============================
This is a public release of libpng, intended for use in production codes.
This is a public release of libpng, intended for use in production code.
Files available for download:
Source files with LF line endings (for Unix/Linux) and with a
"configure" script
Files available for download
----------------------------
libpng-1.6.16.tar.xz (LZMA-compressed, recommended)
libpng-1.6.16.tar.gz
Source files with LF line endings (for Unix/Linux):
Source files with CRLF line endings (for Windows), without the
"configure" script
* libpng-1.6.37.tar.xz (LZMA-compressed, recommended)
* libpng-1.6.37.tar.gz
lpng1616.7z (LZMA-compressed, recommended)
lpng1616.zip
Source files with CRLF line endings (for Windows):
* lp1637.7z (LZMA-compressed, recommended)
* lp1637.zip
Other information:
libpng-1.6.16-README.txt
libpng-1.6.16-LICENSE.txt
libpng-1.6.16-*.asc (armored detached GPG signatures)
Changes since the last public release (1.6.15):
Added ".align 2" to arm/filter_neon.S to support old GAS assemblers that
don't do alignment correctly.
Revised Makefile.am and scripts/*.dfn to work with MinGW/MSYS;
renamed scripts/*.dfn to scripts/*.c (Bob Friesenhahn and John Bowler).
Quiet a "comparison always true" warning in pngstest.c (John Bowler).
Restored a test on width that was removed from png.c at libpng-1.6.9
(Bug report by Alex Eubanks).
Fixed an overflow in png_combine_row with very wide interlaced images.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
to subscribe)
or to glennrp at users.sourceforge.net
* README.md
* LICENSE.md
* AUTHORS.md
* TRADEMARK.md
Changes since the previous public release (version 1.6.36)
----------------------------------------------------------
Glenn R-P
* Fixed a use-after-free vulnerability (CVE-2019-7317) in png_image_free.
* Fixed a memory leak in the ARM NEON implementation of png_do_expand_palette.
* Fixed a memory leak in pngtest.c.
* Fixed two vulnerabilities (CVE-2018-14048, CVE-2018-14550) in
contrib/pngminus; refactor.
* Changed the license of contrib/pngminus to MIT; refresh makefile and docs.
(Contributed by Willem van Schaik)
* Fixed a typo in the libpng license v2.
(Contributed by Miguel Ojeda)
* Added makefiles for AddressSanitizer-enabled builds.
* Cleaned up various makefiles.
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
to subscribe.

1071
png/CHANGES

File diff suppressed because it is too large Load Diff

15
png/CMakeLists.txt

@ -1,3 +1,18 @@ @@ -1,3 +1,18 @@
#
# PNG library CMake configuration for the Fast Light Toolkit (FLTK).
#
# Copyright 1998-2020 by Bill Spitzak and others.
#
# This library is free software. Distribution and use rights are outlined in
# the file "COPYING" which should have been included with this file. If this
# file is missing or damaged, see the license at:
#
# https://www.fltk.org/COPYING.php
#
# Please report all bugs and problems on the following page:
#
# https://www.fltk.org/str.php
#
# source files for png
set(PNG_SRCS

143
png/INSTALL

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
Installing libpng
Installing libpng
Contents
@ -10,15 +10,17 @@ Contents @@ -10,15 +10,17 @@ Contents
V. Directory structure
VI. Building with project files
VII. Building with makefiles
VIII. Configuring libpng for 16-bit platforms
VIII. Configuring libpng for 16-bit platforms
IX. Configuring for DOS
X. Configuring for Medium Model
XI. Prepending a prefix to exported symbols
XII. Configuring for compiler xxx:
XIII. Removing unwanted object code
XIV. Changes to the build and configuration of libpng in libpng-1.5.x
XV. Configuring libpng for multiprocessing
XVI. Other sources of information about libpng
XIII. Removing unwanted object code
XIV. Enabling or disabling hardware optimizations
XV. Changes to the build and configuration of libpng in libpng-1.5.x
XVI. Setjmp/longjmp issues
XVII. Common linking failures
XVIII. Other sources of information about libpng
I. Simple installation
@ -47,7 +49,9 @@ If configure does not work on your system, or if you have a need to @@ -47,7 +49,9 @@ If configure does not work on your system, or if you have a need to
change configure.ac or Makefile.am, and you have a reasonably
up-to-date set of tools, running ./autogen.sh in a git clone before
running ./configure may fix the problem. To be really sure that you
aren't using any of the included pre-built scripts, you can do this:
aren't using any of the included pre-built scripts, especially if you
are building from a tar distribution instead of a git distribution,
do this:
./configure --enable-maintainer-mode
make maintainer-clean
@ -75,8 +79,8 @@ Or you can use one of the "projects" in the "projects" directory. @@ -75,8 +79,8 @@ Or you can use one of the "projects" in the "projects" directory.
Before installing libpng, you must first install zlib, if it
is not already on your system. zlib can usually be found
wherever you got libpng; otherwise go to http://zlib.net. You can place
zlib in in the same directory as libpng or in another directory.
wherever you got libpng; otherwise go to https://zlib.net/. You can
place zlib in the same directory as libpng or in another directory.
If your system already has a preinstalled zlib you will still need
to have access to the zlib.h and zconf.h include files that
@ -87,14 +91,16 @@ standard library search path, put ZLIBLIB, ZLIBINC, CPPFLAGS, LDFLAGS, @@ -87,14 +91,16 @@ standard library search path, put ZLIBLIB, ZLIBINC, CPPFLAGS, LDFLAGS,
and LD_LIBRARY_PATH in your environment before running "make test"
or "make distcheck":
ZLIBLIB=/path/to/lib export ZLIBLIB
ZLIBINC=/path/to/include export ZLIBINC
CPPFLAGS="-I$ZLIBINC" export CPPFLAGS
LDFLAGS="-L$ZLIBLIB" export LDFLAGS
LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH
ZLIBLIB=/path/to/lib export ZLIBLIB
ZLIBINC=/path/to/include export ZLIBINC
CPPFLAGS="-I$ZLIBINC" export CPPFLAGS
LDFLAGS="-L$ZLIBLIB" export LDFLAGS
LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH
If you are using one of the makefile scripts, put ZLIBLIB and ZLIBINC
in your environment and type "make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test".
in your environment and type
make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test
IV. Using cmake
@ -160,9 +166,14 @@ VII. Building with makefiles @@ -160,9 +166,14 @@ VII. Building with makefiles
Copy the file (or files) that you need from the
scripts directory into this directory, for example
MSDOS example: copy scripts\makefile.msc makefile
MSDOS example:
copy scripts\makefile.msc makefile
copy scripts\pnglibconf.h.prebuilt pnglibconf.h
UNIX example: cp scripts/makefile.std makefile
UNIX example:
cp scripts/makefile.std makefile
cp scripts/pnglibconf.h.prebuilt pnglibconf.h
Read the makefile to see if you need to change any source or
@ -189,7 +200,7 @@ run "make install". @@ -189,7 +200,7 @@ run "make install".
VIII. Configuring libpng for 16-bit platforms
You will want to look into zconf.h to tell zlib (and thus libpng) that
it cannot allocate more then 64K at a time. Even if you can, the memory
it cannot allocate more than 64K at a time. Even if you can, the memory
won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
IX. Configuring for DOS
@ -239,7 +250,7 @@ libpng are compiled. All the defines end in _SUPPORTED. If you are @@ -239,7 +250,7 @@ libpng are compiled. All the defines end in _SUPPORTED. If you are
never going to use a capability, you can change the #define to #undef
before recompiling libpng and save yourself code and data space, or
you can turn off individual capabilities with defines that begin with
PNG_NO_.
"PNG_NO_".
In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead.
@ -271,7 +282,57 @@ library to fail if they call functions not available in your library. @@ -271,7 +282,57 @@ library to fail if they call functions not available in your library.
The size of the library itself should not be an issue, because only
those sections that are actually used will be loaded into memory.
XIV. Changes to the build and configuration of libpng in libpng-1.5.x
XIV. Enabling or disabling hardware optimizations
Certain hardware capabilities, such as the Intel SSE instructions,
are normally detected at run time. Enable them with configure options
such as one of
--enable-arm-neon=yes
--enable-mips-msa=yes
--enable-intel-sse=yes
--enable-powerpc-vsx=yes
or enable them all at once with
--enable-hardware-optimizations=yes
or, if you are not using "configure", you can use one
or more of
CPPFLAGS += "-DPNG_ARM_NEON"
CPPFLAGS += "-DPNG_MIPS_MSA"
CPPFLAGS += "-DPNG_INTEL_SSE"
CPPFLAGS += "-DPNG_POWERPC_VSX"
See for example scripts/makefile.linux-opt
If you wish to avoid using them,
you can disable them via the configure option
--disable-hardware-optimizations
to disable them all, or
--enable-intel-sse=no
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"
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
or disable them all at once with
cmake . -DPNG_HARDWARE_OPTIMIZATIONS=no
XV. Changes to the build and configuration of libpng in libpng-1.5.x
Details of internal changes to the library code can be found in the CHANGES
file and in the GIT repository logs. These will be of no concern to the vast
@ -307,7 +368,7 @@ only png_longjmp_ptr, which must match the C longjmp function.) The new @@ -307,7 +368,7 @@ only png_longjmp_ptr, which must match the C longjmp function.) The new
approach is documented in pngconf.h
Despite these changes, libpng 1.5.0 only supports the native C function
calling standard on those platforms tested so far (__cdecl on Microsoft
calling standard on those platforms tested so far ("__cdecl" on Microsoft
Windows). This is because the support requirements for alternative
calling conventions seem to no longer exist. Developers who find it
necessary to set PNG_API_RULE to 1 should advise the mailing list
@ -362,7 +423,7 @@ $PREFIX/include directory). Do not edit pnglibconf.h after you have built @@ -362,7 +423,7 @@ $PREFIX/include directory). Do not edit pnglibconf.h after you have built
libpng, because than the settings would not accurately reflect the settings
that were used to build libpng.
XV. Configuring libpng for multiprocessing
XVI. Setjmp/longjmp issues
Libpng uses setjmp()/longjmp() for error handling. Unfortunately setjmp()
is known to be not thread-safe on some platforms and we don't know of
@ -375,28 +436,30 @@ configure libpng with PNG_NO_SETJMP in your pngusr.dfa file, with @@ -375,28 +436,30 @@ configure libpng with PNG_NO_SETJMP in your pngusr.dfa file, with
in your pnglibconf.h or pngusr.h.
XVI. Other sources of information about libpng:
Starting with libpng-1.6.0, the library included a "simplified API".
This requires setjmp/longjmp, so you must either build the library
with PNG_SETJMP_SUPPORTED defined, or with PNG_SIMPLIFIED_READ_SUPPORTED
and PNG_SIMPLIFIED_WRITE_SUPPORTED undefined.
Further information can be found in the README and libpng-manual.txt
files, in the individual makefiles, in png.h, and the manual pages
libpng.3 and png.5.
XVII. Common linking failures
If your application fails to find libpng or zlib entries while linking:
Using the ./configure script -- 16 December 2002.
=================================================
Be sure "-lz" appears after "-lpng" on your linking command.
The ./configure script should work compatibly with what scripts/makefile.*
did, however there are some options you might need to add to configure
explicitly, which previously was done semi-automatically (if you didn't edit
scripts/makefile.* yourself, that is)
Be sure you have built libpng, zlib, and your application for the
same platform (e.g., 32-bit or 64-bit).
CFLAGS="-Wall -O -funroll-loops \
-malign-loops=2 -malign-functions=2" ./configure --prefix=/usr/include \
--with-pkgconfigdir=/usr/lib/pkgconfig --includedir=/usr/include
If you are using the vstudio project, observe the WARNING in
project/vstudio/README.txt.
You can alternatively specify --includedir=/usr/include, /usr/local/include,
/usr/include/libpng16, or whatever.
XVIII. Other sources of information about libpng:
If you find that the configure script is out-of-date or is not supporting
your platform properly, try running autogen.sh to regenerate "configure",
"Makefile.in", and the other configuration files. Then try configure again.
Further information can be found in the README and libpng-manual.txt
files, in the individual makefiles, in png.h, and the manual pages
libpng.3 and png.5.
Copyright (c) 1998-2002,2006-2016 Glenn Randers-Pehrson
This document is released under the libpng license.
For conditions of distribution and use, see the disclaimer
and license in png.h.

147
png/LICENSE

@ -1,53 +1,88 @@ @@ -1,53 +1,88 @@
COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
=========================================
PNG Reference Library License version 2
---------------------------------------
* Copyright (c) 1995-2019 The PNG Reference Library Authors.
* Copyright (c) 2018-2019 Cosmin Truta.
* Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
* Copyright (c) 1996-1997 Andreas Dilger.
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
The software is supplied "as is", without warranty of any kind,
express or implied, including, without limitation, the warranties
of merchantability, fitness for a particular purpose, title, and
non-infringement. In no event shall the Copyright owners, or
anyone distributing the software, be liable for any damages or
other liability, whether in contract, tort or otherwise, arising
from, out of, or in connection with the software, or the use or
other dealings in the software, even if advised of the possibility
of such damage.
Permission is hereby granted to use, copy, modify, and distribute
this software, or portions hereof, for any purpose, without fee,
subject to the following restrictions:
1. The origin of this software must not be misrepresented; you
must not claim that you wrote the original software. If you
use this software in a product, an acknowledgment in the product
documentation would be appreciated, but is not required.
2. Altered source versions must be plainly marked as such, and must
not be misrepresented as being the original software.
3. This Copyright notice may not be removed or altered from any
source or altered source distribution.
This copy of the libpng notices is provided for your convenience. In case of
any discrepancy between this copy and the notices in the file png.h that is
included in the libpng distribution, the latter shall prevail.
COPYRIGHT NOTICE, DISCLAIMER, and LICENSE:
If you modify libpng you may insert additional notices immediately following
this sentence.
This code is released under the libpng license.
libpng versions 1.2.6, August 15, 2004, through 1.6.16, December 22, 2014, are
Copyright (c) 2004, 2006-2014 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.2.5
with the following individual added to the list of Contributing Authors
Cosmin Truta
PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35)
-----------------------------------------------------------------------
libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.0.6
with the following individuals added to the list of Contributing Authors
libpng versions 1.0.7, July 1, 2000, through 1.6.35, July 15, 2018 are
Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson, are
derived from libpng-1.0.6, and are distributed according to the same
disclaimer and license as libpng-1.0.6 with the following individuals
added to the list of Contributing Authors:
Simon-Pierre Cadieux
Eric S. Raymond
Mans Rullgard
Cosmin Truta
Gilles Vollant
James Yu
Mandar Sahastrabuddhe
Google Inc.
Vadim Barkov
and with the following additions to the disclaimer:
There is no warranty against interference with your enjoyment of the
library or against infringement. There is no warranty that our
There is no warranty against interference with your enjoyment of
the library or against infringement. There is no warranty that our
efforts or the library will fulfill any of your particular purposes
or needs. This library is provided with all faults, and the entire
risk of satisfactory quality, performance, accuracy, and effort is with
the user.
risk of satisfactory quality, performance, accuracy, and effort is
with the user.
Some files in the "contrib" directory and some configure-generated
files that are distributed with libpng have other copyright owners, and
are released under other open source licenses.
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-0.96,
with the following individuals added to the list of Contributing Authors:
Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
libpng-0.96, and are distributed according to the same disclaimer and
license as libpng-0.96, with the following individuals added to the
list of Contributing Authors:
Tom Lane
Glenn Randers-Pehrson
Willem van Schaik
libpng versions 0.89, June 1996, through 0.96, May 1997, are
Copyright (c) 1996, 1997 Andreas Dilger
Distributed according to the same disclaimer and license as libpng-0.88,
with the following individuals added to the list of Contributing Authors:
Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
and are distributed according to the same disclaimer and license as
libpng-0.88, with the following individuals added to the list of
Contributing Authors:
John Bowler
Kevin Bracey
@ -56,8 +91,11 @@ with the following individuals added to the list of Contributing Authors: @@ -56,8 +91,11 @@ with the following individuals added to the list of Contributing Authors:
Greg Roelofs
Tom Tanner
Some files in the "scripts" directory have other copyright owners,
but are released under this license.
libpng versions 0.5, May 1995, through 0.88, January 1996, are
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
For the purposes of this copyright and license, "Contributing Authors"
is defined as the following set of individuals:
@ -68,44 +106,29 @@ is defined as the following set of individuals: @@ -68,44 +106,29 @@ is defined as the following set of individuals:
Paul Schmidt
Tim Wegner
The PNG Reference Library is supplied "AS IS". The Contributing Authors
and Group 42, Inc. disclaim all warranties, expressed or implied,
including, without limitation, the warranties of merchantability and of
fitness for any purpose. The Contributing Authors and Group 42, Inc.
assume no liability for direct, indirect, incidental, special, exemplary,
or consequential damages, which may result from the use of the PNG
Reference Library, even if advised of the possibility of such damage.
The PNG Reference Library is supplied "AS IS". The Contributing
Authors and Group 42, Inc. disclaim all warranties, expressed or
implied, including, without limitation, the warranties of
merchantability and of fitness for any purpose. The Contributing
Authors and Group 42, Inc. assume no liability for direct, indirect,
incidental, special, exemplary, or consequential damages, which may
result from the use of the PNG Reference Library, even if advised of
the possibility of such damage.
Permission is hereby granted to use, copy, modify, and distribute this
source code, or portions hereof, for any purpose, without fee, subject
to the following restrictions:
1. The origin of this source code must not be misrepresented.
1. The origin of this source code must not be misrepresented.
2. Altered versions must be plainly marked as such and must not
2. Altered versions must be plainly marked as such and must not
be misrepresented as being the original source.
3. This Copyright notice may not be removed or altered from any
3. This Copyright notice may not be removed or altered from any
source or altered source distribution.
The Contributing Authors and Group 42, Inc. specifically permit, without
fee, and encourage the use of this source code as a component to
supporting the PNG file format in commercial products. If you use this
source code in a product, acknowledgment is not required but would be
appreciated.
A "png_get_copyright" function is available, for convenient use in "about"
boxes and the like:
printf("%s",png_get_copyright(NULL));
Also, the PNG logo (in PNG format, of course) is supplied in the
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
certification mark of the Open Source Initiative.
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
December 22, 2014
The Contributing Authors and Group 42, Inc. specifically permit,
without fee, and encourage the use of this source code as a component
to supporting the PNG file format in commercial products. If you use
this source code in a product, acknowledgment is not required but would
be appreciated.

5
png/Makefile

@ -1,9 +1,8 @@ @@ -1,9 +1,8 @@
#
# "$Id$"
#
# PNG library makefile for the Fast Light Toolkit (FLTK).
# PNG library Makefile for the Fast Light Toolkit (FLTK).
#
# Copyright 1997-2011 by Easy Software Products.
# Copyright 2012-2020 by Bill Spitzak and others.
#
# This library is free software. Distribution and use rights are outlined in
# the file "COPYING" which should have been included with this file. If this

128
png/README

@ -1,15 +1,16 @@ @@ -1,15 +1,16 @@
README for libpng version 1.6.16 - December 22, 2014 (shared library 16.0)
See the note about version numbers near the top of png.h
README for libpng version 1.6.37 - April 14, 2019
=================================================
See the note about version numbers near the top of png.h.
See INSTALL for instructions on how to install libpng.
Libpng comes in several distribution formats. Get libpng-*.tar.gz or
libpng-*.tar.xz or if you want UNIX-style line endings in the text files,
or lpng*.7z or lpng*.zip if you want DOS-style line endings.
libpng-*.tar.xz or if you want UNIX-style line endings in the text
files, or lpng*.7z or lpng*.zip if you want DOS-style line endings.
Version 0.89 was the first official release of libpng. Don't let the
fact that it's the first release fool you. The libpng library has been in
extensive use and testing since mid-1995. By late 1997 it had
fact that it's the first release fool you. The libpng library has been
in extensive use and testing since mid-1995. By late 1997 it had
finally gotten to the stage where there hadn't been significant
changes to the API in some time, and people have a bad feeling about
libraries with versions < 1.0. Version 1.0.0 was released in
@ -23,7 +24,7 @@ earlier versions if you are using a shared library. The type of the @@ -23,7 +24,7 @@ earlier versions if you are using a shared library. The type of the
png_uint_32, which will affect shared-library applications that use
this function.
To avoid problems with changes to the internals of png info_struct,
To avoid problems with changes to the internals of the png info_struct,
new APIs have been made available in 0.95 to avoid direct application
access to info_ptr. These functions are the png_set_<chunk> and
png_get_<chunk> functions. These functions should be used when
@ -60,94 +61,59 @@ the library action on the detection of chunk CRC errors. It is possible @@ -60,94 +61,59 @@ the library action on the detection of chunk CRC errors. It is possible
to set different actions based on whether the CRC error occurred in a
critical or an ancillary chunk.
The changes made to the library, and bugs fixed are based on discussions
on the PNG-implement mailing list and not on material submitted
privately to Guy, Andreas, or Glenn. They will forward any good
suggestions to the list.
For a detailed description on using libpng, read libpng-manual.txt. For
examples of libpng in a program, see example.c and pngtest.c. For usage
information and restrictions (what little they are) on libpng, see
png.h. For a description on using zlib (the compression library used by
libpng) and zlib's restrictions, see zlib.h
For a detailed description on using libpng, read libpng-manual.txt.
For examples of libpng in a program, see example.c and pngtest.c. For
usage information and restrictions (what little they are) on libpng,
see png.h. For a description on using zlib (the compression library
used by libpng) and zlib's restrictions, see zlib.h
I have included a general makefile, as well as several machine and
compiler specific ones, but you may have to modify one for your own needs.
compiler specific ones, but you may have to modify one for your own
needs.
You should use zlib 1.0.4 or later to run this, but it MAY work with
versions as old as zlib 0.95. Even so, there are bugs in older zlib
versions which can cause the output of invalid compression streams for
some images. You will definitely need zlib 1.0.4 or later if you are
taking advantage of the MS-DOS "far" structure allocation for the small
and medium memory models. You should also note that zlib is a
compression library that is useful for more things than just PNG files.
You can use zlib as a drop-in replacement for fread() and fwrite() if
you are so inclined.
some images.
You should also note that zlib is a compression library that is useful
for more things than just PNG files. You can use zlib as a drop-in
replacement for fread() and fwrite(), if you are so inclined.
zlib should be available at the same place that libpng is, or at zlib.net.
zlib should be available at the same place that libpng is, or at
https://zlib.net.
You may also want a copy of the PNG specification. It is available
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
these at http://www.libpng.org/pub/png/documents/
This code is currently being archived at libpng.sf.net in the
[DOWNLOAD] area, and at ftp://ftp.simplesystems.org. If you can't find it
in any of those places, e-mail me, and I'll help you find it.
I am not a lawyer, but I believe that the Export Control Classification
Number (ECCN) for libpng is EAR99, which means not subject to export
controls or International Traffic in Arms Regulations (ITAR) because it
is open source, publicly available software, that does not contain any
encryption software. See the EAR, paragraphs 734.3(b)(3) and 734.7(b).
If you have any code changes, requests, problems, etc., please e-mail
them to me. Also, I'd appreciate any make files or project files,
and any modifications you needed to make to get libpng to compile,
along with a #define variable to tell what compiler/system you are on.
If you needed to add transformations to libpng, or wish libpng would
provide the image in a different way, drop me a note (and code, if
possible), so I can consider supporting the transformation.
Finally, if you get any warning messages when compiling libpng
(note: not zlib), and they are easy to fix, I'd appreciate the
fix. Please mention "libpng" somewhere in the subject line. Thanks.
This release was created and will be supported by myself (of course
based in a large way on Guy's and Andreas' earlier work), and the PNG
these at http://www.libpng.org/pub/png/pngdocs.html .
This code is currently being archived at libpng.sourceforge.io in the
[DOWNLOAD] area, and at http://libpng.download/src .
This release, based in a large way on Glenn's, Guy's and Andreas'
earlier work, was created and will be supported by myself and the PNG
development group.
Send comments/corrections/commendations to png-mng-implement at
lists.sourceforge.net (subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
to subscribe) or to glennrp at users.sourceforge.net
to subscribe).
You can't reach Guy, the original libpng author, at the addresses
given in previous versions of this document. He and Andreas will
read mail addressed to the png-implement list, however.
Please do not send general questions about PNG. Send them to
png-mng-misc at lists.sf.net (subscription required; visit
Send general questions about the PNG specification to png-mng-misc
at lists.sourceforge.net (subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-misc to
subscribe). If you have a question about something
in the PNG specification that is related to using libpng, send it
to me. Send me any questions that start with "I was using libpng,
and ...". If in doubt, send questions to me. I'll bounce them
to others, if necessary.
Please do not send suggestions on how to change PNG. We have
been discussing PNG for nineteen years now, and it is official and
finished. If you have suggestions for libpng, however, I'll
gladly listen. Even if your suggestion is not used immediately,
it may be used later.
subscribe).
Files in this distribution:
ANNOUNCE => Announcement of this version, with recent changes
AUTHORS => List of contributing authors
CHANGES => Description of changes between libpng versions
KNOWNBUG => List of known bugs and deficiencies
LICENSE => License to use and redistribute libpng
README => This file
TODO => Things not implemented in the current library
Y2KINFO => Statement of Y2K compliance
TRADEMARK => Trademark information
example.c => Example code for using libpng functions
libpng.3 => manual page for libpng (includes libpng-manual.txt)
libpng-manual.txt => Description of libpng and its functions
@ -179,18 +145,25 @@ Files in this distribution: @@ -179,18 +145,25 @@ Files in this distribution:
pngwtran.c => Write data transformations
pngwutil.c => Write utility functions
arm => Contains optimized code for the ARM platform
powerpc => Contains optimized code for the PowerPC platform
contrib => Contributions
arm-neon => Optimized code for ARM-NEON platform
powerpc-vsx => Optimized code for POWERPC-VSX platform
examples => Example programs
gregbook => source code for PNG reading and writing, from
Greg Roelofs' "PNG: The Definitive Guide",
O'Reilly, 1999
libtests => Test programs
mips-msa => Optimized code for MIPS-MSA platform
pngminim => Minimal decoder, encoder, and progressive decoder
programs demonstrating use of pngusr.dfa
pngminus => Simple pnm2png and png2pnm programs
pngsuite => Test images
testpngs
tools => Various tools
visupng => Contains a MSVC workspace for VisualPng
intel => Optimized code for INTEL-SSE2 platform
mips => Optimized code for MIPS platform
projects => Contains project files and workspaces for
building a DLL
owatcom => Contains a WATCOM project for building libpng
@ -201,15 +174,10 @@ Files in this distribution: @@ -201,15 +174,10 @@ Files in this distribution:
scripts => Directory containing scripts for building libpng:
(see scripts/README.txt for the list of scripts)
Good luck, and happy coding.
-Glenn Randers-Pehrson (current maintainer, since 1998)
Internet: glennrp at users.sourceforge.net
-Andreas Eric Dilger (former maintainer, 1996-1997)
Internet: adilger at enel.ucalgary.ca
Web: http://www-mddsp.enel.ucalgary.ca/People/adilger/
Good luck, and happy coding!
-Guy Eric Schalnat (original author and former maintainer, 1995-1996)
(formerly of Group 42, Inc)
Internet: gschal at infinet.com
* Cosmin Truta (current maintainer, since 2018)
* Glenn Randers-Pehrson (former maintainer, 1998-2018)
* Andreas Eric Dilger (former maintainer, 1996-1997)
* Guy Eric Schalnat (original author and former maintainer, 1995-1996)
(formerly of Group 42, Inc.)

48
png/TODO

@ -1,29 +1,23 @@ @@ -1,29 +1,23 @@
/*
TODO - list of things to do for libpng:
Final bug fixes.
Better C++ wrapper/full C++ implementation?
Fix problem with C++ and EXTERN "C".
cHRM transformation.
Remove setjmp/longjmp usage in favor of returning error codes.
Palette creation.
Add "grayscale->palette" transformation and "palette->grayscale" detection.
Improved dithering.
Multi-lingual error and warning message support.
Complete sRGB transformation (presently it simply uses gamma=0.45455).
Make profile checking optional via a png_set_something() call.
Man pages for function calls.
Better documentation.
Better filter selection
(counting huffman bits/precompression? filter inertia? filter costs?).
Histogram creation.
Text conversion between different code pages (Latin-1 -> Mac and DOS).
Avoid building gamma tables whenever possible.
Use greater precision when changing to linear gamma for compositing against
background and doing rgb-to-gray transformation.
Investigate pre-incremented loop counters and other loop constructions.
Add interpolated method of handling interlacing.
Switch to the simpler zlib (zlib/libpng) license if legally possible.
Extend pngvalid.c to validate more of the libpng transformations.
*/
* Fix all defects (duh!)
* Better C++ wrapper / full C++ implementation (?)
* Fix the problems with C++ and 'extern "C"'.
* cHRM transformation.
* Palette creation.
* "grayscale->palette" transformation and "palette->grayscale" detection.
* Improved dithering.
* Multi-lingual error and warning message support.
* Complete sRGB transformation. (Currently it simply uses gamma=0.45455.)
* Man pages for function calls.
* Better documentation.
* Better filter selection
(e.g., counting huffman bits/precompression; filter inertia; filter costs).
* Histogram creation.
* Text conversion between different code pages (e.g., Latin-1 -> Mac).
* Avoid building gamma tables whenever possible.
* Greater precision in changing to linear gamma for compositing against
background, and in doing rgb-to-gray transformations.
* Investigate pre-incremented loop counters and other loop constructions.
* Interpolated method of handling interlacing.
* More validations for libpng transformations.

673
png/libpng-manual.txt

File diff suppressed because it is too large Load Diff

1098
png/libpng.3

File diff suppressed because it is too large Load Diff

18
png/libpngpf.3

@ -1,18 +1,24 @@ @@ -1,18 +1,24 @@
.TH LIBPNGPF 3 "December 22, 2014"
.TH LIBPNGPF 3 "April 14, 2019"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.16
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.37
(private functions)
.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 pngpriv.h and not accessible to applications. Look in pngpriv.h for the prototypes and a short description of each \fIfunction.
\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
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.
.SH SEE ALSO
.SH "SEE ALSO"
.BR "png"(5), " libpng"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5)
.SH AUTHOR
Glenn Randers-Pehrson
.SH AUTHORS
Cosmin Truta, Glenn Randers-Pehrson

30
png/makedepend

@ -1,32 +1,32 @@ @@ -1,32 +1,32 @@
# DO NOT DELETE
png.o: pngpriv.h png.h pnglibconf.h pngconf.h pnginfo.h pngstruct.h
png.o: pngpriv.h pnglibconf.h png.h pngconf.h pngstruct.h pnginfo.h
png.o: pngdebug.h
pngset.o: pngpriv.h png.h pnglibconf.h pngconf.h pnginfo.h pngstruct.h
pngset.o: pngpriv.h pnglibconf.h png.h pngconf.h pngstruct.h pnginfo.h
pngset.o: pngdebug.h
pngget.o: pngpriv.h png.h pnglibconf.h pngconf.h pnginfo.h pngstruct.h
pngget.o: pngpriv.h pnglibconf.h png.h pngconf.h pngstruct.h pnginfo.h
pngget.o: pngdebug.h
pngrutil.o: pngpriv.h png.h pnglibconf.h pngconf.h pnginfo.h pngstruct.h
pngrutil.o: pngpriv.h pnglibconf.h png.h pngconf.h pngstruct.h pnginfo.h
pngrutil.o: pngdebug.h
pngtrans.o: pngpriv.h png.h pnglibconf.h pngconf.h pnginfo.h pngstruct.h
pngtrans.o: pngpriv.h pnglibconf.h png.h pngconf.h pngstruct.h pnginfo.h
pngtrans.o: pngdebug.h
pngwutil.o: pngpriv.h png.h pnglibconf.h pngconf.h pnginfo.h pngstruct.h
pngwutil.o: pngpriv.h pnglibconf.h png.h pngconf.h pngstruct.h pnginfo.h
pngwutil.o: pngdebug.h
pngread.o: pngpriv.h png.h pnglibconf.h pngconf.h pnginfo.h pngstruct.h
pngread.o: pngpriv.h pnglibconf.h png.h pngconf.h pngstruct.h pnginfo.h
pngread.o: pngdebug.h
pngrio.o: pngpriv.h png.h pnglibconf.h pngconf.h pnginfo.h pngstruct.h
pngrio.o: pngpriv.h pnglibconf.h png.h pngconf.h pngstruct.h pnginfo.h
pngrio.o: pngdebug.h
pngwio.o: pngpriv.h png.h pnglibconf.h pngconf.h pnginfo.h pngstruct.h
pngwio.o: pngpriv.h pnglibconf.h png.h pngconf.h pngstruct.h pnginfo.h
pngwio.o: pngdebug.h
pngwrite.o: pngpriv.h png.h pnglibconf.h pngconf.h pnginfo.h pngstruct.h
pngwrite.o: pngpriv.h pnglibconf.h png.h pngconf.h pngstruct.h pnginfo.h
pngwrite.o: pngdebug.h
pngrtran.o: pngpriv.h png.h pnglibconf.h pngconf.h pnginfo.h pngstruct.h
pngrtran.o: pngpriv.h pnglibconf.h png.h pngconf.h pngstruct.h pnginfo.h
pngrtran.o: pngdebug.h
pngwtran.o: pngpriv.h png.h pnglibconf.h pngconf.h pnginfo.h pngstruct.h
pngwtran.o: pngpriv.h pnglibconf.h png.h pngconf.h pngstruct.h pnginfo.h
pngwtran.o: pngdebug.h
pngmem.o: pngpriv.h png.h pnglibconf.h pngconf.h pnginfo.h pngstruct.h
pngmem.o: pngpriv.h pnglibconf.h png.h pngconf.h pngstruct.h pnginfo.h
pngmem.o: pngdebug.h
pngerror.o: pngpriv.h png.h pnglibconf.h pngconf.h pnginfo.h pngstruct.h
pngerror.o: pngpriv.h pnglibconf.h png.h pngconf.h pngstruct.h pnginfo.h
pngerror.o: pngdebug.h
pngpread.o: pngpriv.h png.h pnglibconf.h pngconf.h pnginfo.h pngstruct.h
pngpread.o: pngpriv.h pnglibconf.h png.h pngconf.h pngstruct.h pnginfo.h
pngpread.o: pngdebug.h

70
png/png.5

@ -1,47 +1,49 @@ @@ -1,47 +1,49 @@
.TH PNG 5 "December 22, 2014"
.TH PNG 5 "April 14, 2019"
.SH NAME
png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION
PNG (Portable Network Graphics) is an extensible file format for the
lossless, portable, well-compressed storage of raster images. PNG provides
a patent-free replacement for GIF and can also replace many
lossless, portable, well-compressed storage of raster images. PNG
provides a patent-free replacement for GIF, and can also replace many
common uses of TIFF. Indexed-color, grayscale, and truecolor images are
supported, plus an optional alpha channel. Sample depths range from
1 to 16 bits.
.br
PNG is designed to work well in online viewing applications, such as the
World Wide Web, so it is fully streamable with a progressive display
option. PNG is robust, providing both full file integrity checking and
fast, simple detection of common transmission errors. Also, PNG can store
gamma and chromaticity data for improved color matching on heterogeneous
platforms.
PNG is designed to work well in online viewing applications, such
as the World Wide Web, so it is fully streamable with a progressive
display option. PNG is robust, providing both full file integrity
checking and fast, simple detection of common transmission errors.
Also, PNG can store gamma and chromaticity data for improved color
matching on heterogeneous platforms.
.SH "SEE ALSO"
.BR "libpng"(3), " libpngpf"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5)
.LP
PNG specification (second edition), November 2003:
PNG Specification (Second Edition), November 2003:
.IP
.br
<http://www.w3.org/TR/2003/REC-PNG-20031110/
PNG 1.2 specification, July 1999:
https://www.w3.org/TR/2003/REC-PNG-20031110/
.LP
PNG 1.2 Specification, July 1999:
.IP
.br
http://www.libpng.org/pub/png
https://png-mng.sourceforge.io/pub/png/spec/1.2/
.LP
PNG 1.0 specification, October 1996:
PNG 1.0 Specification, October 1996:
.IP
.br
RFC 2083
.IP
.br
ftp://ds.internic.net/rfc/rfc2083.txt
https://www.ietf.org/rfc/rfc2083.txt
.IP
.br
or (as a W3C Recommendation) at
or W3C Recommendation
.br
http://www.w3.org/TR/REC-png.html
https://www.w3.org/TR/REC-png-961001
.SH AUTHORS
This man page: Glenn Randers-Pehrson
This man page: Cosmin Truta, Glenn Randers-Pehrson
.LP
Portable Network Graphics (PNG) Specification (Second Edition)
Information technology - Computer graphics and image processing -
@ -53,22 +55,30 @@ Glenn Randers-Pehrson and others (png-list). @@ -53,22 +55,30 @@ Glenn Randers-Pehrson and others (png-list).
.LP
Portable Network Graphics (PNG) Specification Version 1.0 (October 1, 1996):
Thomas Boutell and others (png-list).
.LP
.SH COPYRIGHT NOTICE
.SH COPYRIGHT
.LP
This man page is Copyright (c) 1998-2006 Glenn Randers-Pehrson. See png.h
for conditions of use and distribution.
This man page is
.br
Copyright (c) 2018-2019 Cosmin Truta.
.br
Copyright (c) 1998-2006 Glenn Randers-Pehrson.
.br
See png.h for conditions of use and distribution.
.LP
The PNG Specification (Second Edition) is
.br
Copyright (c) 2003 W3C. (MIT, ERCIM, Keio), All Rights Reserved.
.LP
The PNG-1.2 specification is copyright (c) 1999 Glenn Randers-Pehrson.
The PNG-1.2 Specification is
.br
Copyright (c) 1999 Glenn Randers-Pehrson.
.br
See the specification for conditions of use and distribution.
.LP
The PNG-1.0 specification is copyright (c) 1996 Massachusetts Institute of
Technology. See the specification for conditions of use and distribution.
.LP
The PNG-1.0 Specification is
.br
Copyright (c) 1996 Massachusetts Institute of Technology.
.br
See the specification for conditions of use and distribution.
.\" end of man page

492
png/png.c

File diff suppressed because it is too large Load Diff

923
png/png.h

File diff suppressed because it is too large Load Diff

93
png/pngconf.h

@ -1,19 +1,18 @@ @@ -1,19 +1,18 @@
/* pngconf.h - machine configurable file for libpng
/* pngconf.h - machine-configurable file for libpng
*
* libpng version 1.6.16,December 22, 2014
* libpng version 1.6.37
*
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* Copyright (c) 2018-2019 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.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*
*/
/* Any machine specific code is near the front of this file, so if you
* Any machine specific code is near the front of this file, so if you
* are configuring libpng for a machine, you may want to read the section
* starting here down to where it starts to typedef png_color, png_text,
* and png_info.
@ -22,26 +21,6 @@ @@ -22,26 +21,6 @@
#ifndef PNGCONF_H
#define PNGCONF_H
/* To do: Do all of this in scripts/pnglibconf.dfa */
#ifdef PNG_SAFE_LIMITS_SUPPORTED
# ifdef PNG_USER_WIDTH_MAX
# undef PNG_USER_WIDTH_MAX
# define PNG_USER_WIDTH_MAX 1000000L
# endif
# ifdef PNG_USER_HEIGHT_MAX
# undef PNG_USER_HEIGHT_MAX
# define PNG_USER_HEIGHT_MAX 1000000L
# endif
# ifdef PNG_USER_CHUNK_MALLOC_MAX
# undef PNG_USER_CHUNK_MALLOC_MAX
# define PNG_USER_CHUNK_MALLOC_MAX 4000000L
# endif
# ifdef PNG_USER_CHUNK_CACHE_MAX
# undef PNG_USER_CHUNK_CACHE_MAX
# define PNG_USER_CHUNK_CACHE_MAX 128
# endif
#endif
#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */
/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C
@ -79,14 +58,13 @@ @@ -79,14 +58,13 @@
#endif /* PNG_BUILDING_SYMBOL_TABLE */
/* Prior to 1.6.0 it was possible to turn off 'const' in declarations using
* PNG_NO_CONST; this is no longer supported except for data declarations which
* apparently still cause problems in 2011 on some compilers.
/* Prior to 1.6.0, it was possible to turn off 'const' in declarations,
* using PNG_NO_CONST. This is no longer supported.
*/
#define PNG_CONST const /* backward compatibility only */
/* This controls optimization of the reading of 16 and 32 bit values
* from PNG files. It can be set on a per-app-file basis - it
/* This controls optimization of the reading of 16-bit and 32-bit
* values from PNG files. It can be set on a per-app-file basis: it
* just changes whether a macro is used when the function is called.
* The library builder sets the default; if read functions are not
* built into the library the macro implementation is forced on.
@ -149,7 +127,7 @@ @@ -149,7 +127,7 @@
*
* These cases only differ if the operating system does not use the C
* calling convention, at present this just means the above cases
* (x86 DOS/Windows sytems) and, even then, this does not apply to
* (x86 DOS/Windows systems) and, even then, this does not apply to
* Cygwin running on those systems.
*
* Note that the value must be defined in pnglibconf.h so that what
@ -317,11 +295,11 @@ @@ -317,11 +295,11 @@
* table entries, so we discard it here. See the .dfn files in the
* scripts directory.
*/
#ifndef PNG_EXPORTA
# define PNG_EXPORTA(ordinal, type, name, args, attributes)\
PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \
extern attributes)
#ifndef PNG_EXPORTA
# define PNG_EXPORTA(ordinal, type, name, args, attributes) \
PNG_FUNCTION(PNG_EXPORT_TYPE(type), (PNGAPI name), PNGARG(args), \
PNG_LINKAGE_API attributes)
#endif
/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
@ -329,7 +307,7 @@ @@ -329,7 +307,7 @@
*/
#define PNG_EMPTY /*empty list*/
#define PNG_EXPORT(ordinal, type, name, args)\
#define PNG_EXPORT(ordinal, type, name, args) \
PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)
/* Use PNG_REMOVED to comment out a removed interface. */
@ -502,7 +480,7 @@ @@ -502,7 +480,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
@ -510,7 +488,7 @@ @@ -510,7 +488,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 type"
#endif
#if UINT_MAX == 65535
@ -518,7 +496,7 @@ @@ -518,7 +496,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 type"
#endif
#if INT_MIN < -2147483646 && INT_MAX > 2147483646
@ -526,19 +504,21 @@ @@ -526,19 +504,21 @@
#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 more) type"
#endif
#if UINT_MAX > 4294967294
#if UINT_MAX > 4294967294U
typedef unsigned int png_uint_32;
#elif ULONG_MAX > 4294967294
#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 more) type"
#endif
/* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however,
* requires an ISOC90 compiler and relies on consistent behavior of sizeof.
/* Prior to 1.6.0, it was possible to disable the use of size_t and ptrdiff_t.
* From 1.6.0 onwards, an ISO C90 compiler, as well as a standard-compliant
* behavior of sizeof and ptrdiff_t are required.
* The legacy typedefs are provided here for backwards compatibility.
*/
typedef size_t png_size_t;
typedef ptrdiff_t png_ptrdiff_t;
@ -559,13 +539,12 @@ typedef ptrdiff_t png_ptrdiff_t; @@ -559,13 +539,12 @@ typedef ptrdiff_t png_ptrdiff_t;
# endif
#endif
/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no
* smaller than png_uint_32. Casts from png_size_t or png_uint_32 to
* png_alloc_size_t are not necessary; in fact, it is recommended not to use
* them at all so that the compiler can complain when something turns out to be
* problematic.
/* png_alloc_size_t is guaranteed to be no smaller than size_t, and no smaller
* than png_uint_32. Casts from size_t or png_uint_32 to png_alloc_size_t are
* not necessary; in fact, it is recommended not to use them at all, so that
* the compiler can complain when something turns out to be problematic.
*
* Casts in the other direction (from png_alloc_size_t to png_size_t or
* Casts in the other direction (from png_alloc_size_t to size_t or
* png_uint_32) should be explicitly applied; however, we do not expect to
* encounter practical situations that require such conversions.
*
@ -575,7 +554,7 @@ typedef ptrdiff_t png_ptrdiff_t; @@ -575,7 +554,7 @@ typedef ptrdiff_t png_ptrdiff_t;
#ifdef PNG_SMALL_SIZE_T
typedef png_uint_32 png_alloc_size_t;
#else
typedef png_size_t png_alloc_size_t;
typedef size_t png_alloc_size_t;
#endif
/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler
@ -611,8 +590,8 @@ typedef char * png_charp; @@ -611,8 +590,8 @@ typedef char * png_charp;
typedef const char * png_const_charp;
typedef png_fixed_point * png_fixed_point_p;
typedef const png_fixed_point * png_const_fixed_point_p;
typedef png_size_t * png_size_tp;
typedef const png_size_t * png_const_size_tp;
typedef size_t * png_size_tp;
typedef const size_t * png_const_size_tp;
#ifdef PNG_STDIO_SUPPORTED
typedef FILE * png_FILE_p;

9
png/pngdebug.h

@ -1,11 +1,10 @@ @@ -1,11 +1,10 @@
/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c
*
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
* Last changed in libpng 1.6.8 [December 19, 2013]
* Copyright (c) 2018 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.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer

22
png/pngerror.c

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
* Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* Copyright (c) 2018 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.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -44,7 +44,7 @@ png_error,(png_const_structrp png_ptr, png_const_charp error_message), @@ -44,7 +44,7 @@ png_error,(png_const_structrp png_ptr, png_const_charp error_message),
if (png_ptr != NULL)
{
if ((png_ptr->flags &
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0
(PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0)
{
if (*error_message == PNG_LITERAL_SHARP)
{
@ -163,7 +163,7 @@ png_format_number(png_const_charp start, png_charp end, int format, @@ -163,7 +163,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
case PNG_NUMBER_FORMAT_02u:
/* Expects at least 2 digits. */
mincount = 2;
/* FALL THROUGH */
/* FALLTHROUGH */
case PNG_NUMBER_FORMAT_u:
*--end = digits[number % 10];
@ -173,7 +173,7 @@ png_format_number(png_const_charp start, png_charp end, int format, @@ -173,7 +173,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
case PNG_NUMBER_FORMAT_02x:
/* This format expects at least two digits */
mincount = 2;
/* FALL THROUGH */
/* FALLTHROUGH */
case PNG_NUMBER_FORMAT_x:
*--end = digits[number & 0xf];
@ -425,7 +425,7 @@ png_app_error(png_const_structrp png_ptr, png_const_charp error_message) @@ -425,7 +425,7 @@ png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
* if the character is invalid.
*/
#define isnonalpha(c) ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
static PNG_CONST char png_digit[16] = {
static const char png_digit[16] = {
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'A', 'B', 'C', 'D', 'E', 'F'
};
@ -573,7 +573,7 @@ png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN) @@ -573,7 +573,7 @@ png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN)
{
# define fixed_message "fixed point overflow in "
# define fixed_message_ln ((sizeof fixed_message)-1)
int iin;
unsigned int iin;
char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT];
memcpy(msg, fixed_message, fixed_message_ln);
iin = 0;
@ -885,7 +885,7 @@ PNG_FUNCTION(void /* PRIVATE */, (PNGCBAPI @@ -885,7 +885,7 @@ PNG_FUNCTION(void /* PRIVATE */, (PNGCBAPI
png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message),
PNG_NORETURN)
{
const png_const_structrp png_ptr = png_nonconst_ptr;
png_const_structrp png_ptr = png_nonconst_ptr;
png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
/* An error is always logged here, overwriting anything (typically a warning)
@ -920,7 +920,7 @@ png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message), @@ -920,7 +920,7 @@ png_safe_error),(png_structp png_nonconst_ptr, png_const_charp error_message),
void /* PRIVATE */ PNGCBAPI
png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message)
{
const png_const_structrp png_ptr = png_nonconst_ptr;
png_const_structrp png_ptr = png_nonconst_ptr;
png_imagep image = png_voidcast(png_imagep, png_ptr->error_ptr);
/* A warning is only logged if there is no prior warning or error. */

74
png/pngget.c

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
/* pngget.c - retrieval of values from info struct
*
* Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* Copyright (c) 2018 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.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -26,7 +26,7 @@ png_get_valid(png_const_structrp png_ptr, png_const_inforp info_ptr, @@ -26,7 +26,7 @@ png_get_valid(png_const_structrp png_ptr, png_const_inforp info_ptr,
return(0);
}
png_size_t PNGAPI
size_t PNGAPI
png_get_rowbytes(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
@ -338,7 +338,7 @@ ppi_from_ppm(png_uint_32 ppm) @@ -338,7 +338,7 @@ ppi_from_ppm(png_uint_32 ppm)
png_fixed_point result;
if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127,
5000) != 0)
return result;
return (png_uint_32)result;
/* Overflow. */
return 0;
@ -367,7 +367,7 @@ png_get_y_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr) @@ -367,7 +367,7 @@ png_get_y_pixels_per_inch(png_const_structrp png_ptr, png_const_inforp info_ptr)
static png_fixed_point
png_fixed_inches_from_microns(png_const_structrp png_ptr, png_int_32 microns)
{
/* Convert from metres * 1,000,000 to inches * 100,000, meters to
/* Convert from meters * 1,000,000 to inches * 100,000, meters to
* inches is simply *(100/2.54), so we want *(10/2.54) == 500/127.
* Notice that this can overflow - a warning is output and 0 is
* returned.
@ -741,8 +741,7 @@ png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, @@ -741,8 +741,7 @@ png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_iCCP) != 0 &&
name != NULL && compression_type != NULL && profile != NULL &&
proflen != NULL)
name != NULL && profile != NULL && proflen != NULL)
{
*name = info_ptr->iccp_name;
*profile = info_ptr->iccp_profile;
@ -750,11 +749,13 @@ png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, @@ -750,11 +749,13 @@ png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
/* This is somewhat irrelevant since the profile data returned has
* actually been uncompressed.
*/
if (compression_type != NULL)
*compression_type = PNG_COMPRESSION_TYPE_BASE;
return (PNG_INFO_iCCP);
}
return (0);
}
#endif
@ -773,6 +774,35 @@ png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr, @@ -773,6 +774,35 @@ png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr,
}
#endif
#ifdef PNG_eXIf_SUPPORTED
png_uint_32 PNGAPI
png_get_eXIf(png_const_structrp png_ptr, png_inforp info_ptr,
png_bytep *exif)
{
png_warning(png_ptr, "png_get_eXIf does not work; use png_get_eXIf_1");
PNG_UNUSED(info_ptr)
PNG_UNUSED(exif)
return 0;
}
png_uint_32 PNGAPI
png_get_eXIf_1(png_const_structrp png_ptr, png_const_inforp info_ptr,
png_uint_32 *num_exif, png_bytep *exif)
{
png_debug1(1, "in %s retrieval function", "eXIf");
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_eXIf) != 0 && exif != NULL)
{
*num_exif = info_ptr->num_exif;
*exif = info_ptr->exif;
return (PNG_INFO_eXIf);
}
return (0);
}
#endif
#ifdef PNG_hIST_SUPPORTED
png_uint_32 PNGAPI
png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
@ -799,13 +829,19 @@ png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr, @@ -799,13 +829,19 @@ png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr,
{
png_debug1(1, "in %s retrieval function", "IHDR");
if (png_ptr == NULL || info_ptr == NULL || width == NULL ||
height == NULL || bit_depth == NULL || color_type == NULL)
if (png_ptr == NULL || info_ptr == NULL)
return (0);
if (width != NULL)
*width = info_ptr->width;
if (height != NULL)
*height = info_ptr->height;
if (bit_depth != NULL)
*bit_depth = info_ptr->bit_depth;
if (color_type != NULL)
*color_type = info_ptr->color_type;
if (compression_type != NULL)
@ -1129,27 +1165,27 @@ png_get_user_chunk_ptr(png_const_structrp png_ptr) @@ -1129,27 +1165,27 @@ png_get_user_chunk_ptr(png_const_structrp png_ptr)
}
#endif
png_size_t PNGAPI
size_t PNGAPI
png_get_compression_buffer_size(png_const_structrp png_ptr)
{
if (png_ptr == NULL)
return 0;
# ifdef PNG_WRITE_SUPPORTED
#ifdef PNG_WRITE_SUPPORTED
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
# endif
#endif
{
# ifdef PNG_SEQUENTIAL_READ_SUPPORTED
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
return png_ptr->IDAT_read_size;
# else
#else
return PNG_IDAT_READ_SIZE;
# endif
#endif
}
# ifdef PNG_WRITE_SUPPORTED
#ifdef PNG_WRITE_SUPPORTED
else
return png_ptr->zbuffer_size;
# endif
#endif
}
#ifdef PNG_SET_USER_LIMITS_SUPPORTED

21
png/pnginfo.h

@ -1,11 +1,10 @@ @@ -1,11 +1,10 @@
/* pnginfo.h - header file for PNG reference library
*
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
* Last changed in libpng 1.6.1 [March 28, 2013]
* Copyright (c) 2018 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.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -59,7 +58,7 @@ struct png_info_def @@ -59,7 +58,7 @@ struct png_info_def
png_uint_32 width; /* width of image in pixels (from IHDR) */
png_uint_32 height; /* height of image in pixels (from IHDR) */
png_uint_32 valid; /* valid chunk data (see PNG_INFO_ below) */
png_size_t rowbytes; /* bytes needed to hold an untransformed row */
size_t rowbytes; /* bytes needed to hold an untransformed row */
png_colorp palette; /* array of color values (valid & PNG_INFO_PLTE) */
png_uint_16 num_palette; /* number of color entries in "palette" (PLTE) */
png_uint_16 num_trans; /* number of transparent palette color (tRNS) */
@ -186,6 +185,14 @@ defined(PNG_READ_BACKGROUND_SUPPORTED) @@ -186,6 +185,14 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
png_byte phys_unit_type; /* resolution type (see PNG_RESOLUTION_ below) */
#endif
#ifdef PNG_eXIf_SUPPORTED
int 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
/* The hIST chunk contains the relative frequency or importance of the
* various palette entries, so that a viewer can intelligently select a
@ -240,7 +247,7 @@ defined(PNG_READ_BACKGROUND_SUPPORTED) @@ -240,7 +247,7 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
/* The sCAL chunk describes the actual physical dimensions of the
* subject matter of the graphic. The chunk contains a unit specification
* a byte value, and two ASCII strings representing floating-point
* values. The values are width and height corresponsing to one pixel
* values. The values are width and height corresponding to one pixel
* in the image. Data values are valid if (valid & PNG_INFO_sCAL) is
* non-zero.
*/

32
png/pnglibconf.h

@ -1,8 +1,13 @@ @@ -1,8 +1,13 @@
/*
** FLTK specific PNG lib configuration file -- see README.bundled-libs.txt
*/
/* pnglibconf.h - library build configuration */
/* libpng version 1.6.16,December 22, 2014 */
/* libpng version 1.6.37 */
/* Copyright (c) 1998-2014 Glenn Randers-Pehrson */
/* Copyright (c) 2018-2019 Cosmin Truta */
/* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */
/* This code is released under the libpng license. */
/* For conditions of distribution and use, see the disclaimer */
@ -42,6 +47,8 @@ @@ -42,6 +47,8 @@
#define PNG_IO_STATE_SUPPORTED
#define PNG_MNG_FEATURES_SUPPORTED
#define PNG_POINTER_INDEXING_SUPPORTED
/*#undef PNG_POWERPC_VSX_API_SUPPORTED*/
/*#undef PNG_POWERPC_VSX_CHECK_SUPPORTED*/
#define PNG_PROGRESSIVE_READ_SUPPORTED
#define PNG_READ_16BIT_SUPPORTED
#define PNG_READ_ALPHA_MODE_SUPPORTED
@ -80,6 +87,7 @@ @@ -80,6 +87,7 @@
#define PNG_READ_USER_TRANSFORM_SUPPORTED
#define PNG_READ_bKGD_SUPPORTED
#define PNG_READ_cHRM_SUPPORTED
#define PNG_READ_eXIf_SUPPORTED
#define PNG_READ_gAMA_SUPPORTED
#define PNG_READ_hIST_SUPPORTED
#define PNG_READ_iCCP_SUPPORTED
@ -95,13 +103,10 @@ @@ -95,13 +103,10 @@
#define PNG_READ_tIME_SUPPORTED
#define PNG_READ_tRNS_SUPPORTED
#define PNG_READ_zTXt_SUPPORTED
/*#undef PNG_SAFE_LIMITS_SUPPORTED*/
#define PNG_SAVE_INT_32_SUPPORTED
#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_SEQUENTIAL_READ_SUPPORTED
#define PNG_SETJMP_SUPPORTED
#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED
#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
#define PNG_SET_OPTION_SUPPORTED
#define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_SET_USER_LIMITS_SUPPORTED
@ -110,6 +115,7 @@ @@ -110,6 +115,7 @@
#define PNG_SIMPLIFIED_READ_SUPPORTED
#define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
#define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED
#define PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
#define PNG_SIMPLIFIED_WRITE_SUPPORTED
#define PNG_STDIO_SUPPORTED
#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
@ -127,6 +133,7 @@ @@ -127,6 +133,7 @@
#define PNG_WRITE_BGR_SUPPORTED
#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
#define PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
#define PNG_WRITE_FILLER_SUPPORTED
#define PNG_WRITE_FILTER_SUPPORTED
@ -150,6 +157,7 @@ @@ -150,6 +157,7 @@
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
#define PNG_WRITE_bKGD_SUPPORTED
#define PNG_WRITE_cHRM_SUPPORTED
#define PNG_WRITE_eXIf_SUPPORTED
#define PNG_WRITE_gAMA_SUPPORTED
#define PNG_WRITE_hIST_SUPPORTED
#define PNG_WRITE_iCCP_SUPPORTED
@ -167,6 +175,7 @@ @@ -167,6 +175,7 @@
#define PNG_WRITE_zTXt_SUPPORTED
#define PNG_bKGD_SUPPORTED
#define PNG_cHRM_SUPPORTED
#define PNG_eXIf_SUPPORTED
#define PNG_gAMA_SUPPORTED
#define PNG_hIST_SUPPORTED
#define PNG_iCCP_SUPPORTED
@ -185,21 +194,26 @@ @@ -185,21 +194,26 @@
/* end of options */
/* settings */
#define PNG_API_RULE 0
#define PNG_COST_SHIFT 3
#define PNG_DEFAULT_READ_MACROS 1
#define PNG_GAMMA_THRESHOLD_FIXED 5000
#define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE
#define PNG_INFLATE_BUF_SIZE 1024
#define PNG_LINKAGE_API extern
#define PNG_LINKAGE_CALLBACK extern
#define PNG_LINKAGE_DATA extern
#define PNG_LINKAGE_FUNCTION extern
#define PNG_MAX_GAMMA_8 11
#define PNG_QUANTIZE_BLUE_BITS 5
#define PNG_QUANTIZE_GREEN_BITS 5
#define PNG_QUANTIZE_RED_BITS 5
#define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1)
#define PNG_TEXT_Z_DEFAULT_STRATEGY 0
#define PNG_WEIGHT_SHIFT 8
#define PNG_USER_CHUNK_CACHE_MAX 1000
#define PNG_USER_CHUNK_MALLOC_MAX 8000000
#define PNG_USER_HEIGHT_MAX 1000000
#define PNG_USER_WIDTH_MAX 1000000
#define PNG_ZBUF_SIZE 8192
/* #define PNG_ZLIB_VERNUM 0x1270 */
#define PNG_ZLIB_VERNUM 0x0 /* FLTK: disable check */
#define PNG_ZLIB_VERNUM 0x12b0
#define PNG_Z_DEFAULT_COMPRESSION (-1)
#define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0
#define PNG_Z_DEFAULT_STRATEGY 1

15
png/pngmem.c

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
/* pngmem.c - stub functions for memory allocation
*
* Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* Copyright (c) 2018 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.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -41,7 +41,7 @@ png_destroy_png_struct(png_structrp png_ptr) @@ -41,7 +41,7 @@ png_destroy_png_struct(png_structrp png_ptr)
}
/* Allocate memory. For reasonable files, size should never exceed
* 64K. However, zlib may allocate more then 64K if you don't tell
* 64K. However, zlib may allocate more than 64K if you don't tell
* it not to. See zconf.h and png.h for more information. zlib does
* need to allocate exactly 64K, so whatever you call here must
* have the ability to do that.
@ -77,6 +77,9 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size), @@ -77,6 +77,9 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
PNG_UNUSED(png_ptr)
#endif
/* Some compilers complain that this is always true. However, it
* can be false when integer overflow happens.
*/
if (size > 0 && size <= PNG_SIZE_MAX
# ifdef PNG_MAX_MALLOC_64K
&& size <= 65536U
@ -106,7 +109,7 @@ static png_voidp @@ -106,7 +109,7 @@ static png_voidp
png_malloc_array_checked(png_const_structrp png_ptr, int nelements,
size_t element_size)
{
png_alloc_size_t req = nelements; /* known to be > 0 */
png_alloc_size_t req = (png_alloc_size_t)nelements; /* known to be > 0 */
if (req <= PNG_SIZE_MAX/element_size)
return png_malloc_base(png_ptr, req * element_size);

182
png/pngpread.c

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
/* pngpread.c - read a png file in push mode
*
* Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* Copyright (c) 2018 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.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -19,7 +19,6 @@ @@ -19,7 +19,6 @@
#define PNG_READ_SIG_MODE 0
#define PNG_READ_CHUNK_MODE 1
#define PNG_READ_IDAT_MODE 2
#define PNG_SKIP_MODE 3
#define PNG_READ_tEXt_MODE 4
#define PNG_READ_zTXt_MODE 5
#define PNG_READ_DONE_MODE 6
@ -35,7 +34,7 @@ if (png_ptr->buffer_size < N) \ @@ -35,7 +34,7 @@ if (png_ptr->buffer_size < N) \
void PNGAPI
png_process_data(png_structrp png_ptr, png_inforp info_ptr,
png_bytep buffer, png_size_t buffer_size)
png_bytep buffer, size_t buffer_size)
{
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -48,7 +47,7 @@ png_process_data(png_structrp png_ptr, png_inforp info_ptr, @@ -48,7 +47,7 @@ png_process_data(png_structrp png_ptr, png_inforp info_ptr,
}
}
png_size_t PNGAPI
size_t PNGAPI
png_process_data_pause(png_structrp png_ptr, int save)
{
if (png_ptr != NULL)
@ -61,7 +60,7 @@ png_process_data_pause(png_structrp png_ptr, int save) @@ -61,7 +60,7 @@ png_process_data_pause(png_structrp png_ptr, int save)
else
{
/* This includes any pending saved bytes: */
png_size_t remaining = png_ptr->buffer_size;
size_t remaining = png_ptr->buffer_size;
png_ptr->buffer_size = 0;
/* So subtract the saved buffer size, unless all the data
@ -78,32 +77,14 @@ png_process_data_pause(png_structrp png_ptr, int save) @@ -78,32 +77,14 @@ png_process_data_pause(png_structrp png_ptr, int save)
png_uint_32 PNGAPI
png_process_data_skip(png_structrp png_ptr)
{
png_uint_32 remaining = 0;
if (png_ptr != NULL && png_ptr->process_mode == PNG_SKIP_MODE &&
png_ptr->skip_length > 0)
{
/* At the end of png_process_data the buffer size must be 0 (see the loop
* above) so we can detect a broken call here:
/* TODO: Deprecate and remove this API.
* Somewhere the implementation of this seems to have been lost,
* or abandoned. It was only to support some internal back-door access
* to png_struct) in libpng-1.4.x.
*/
if (png_ptr->buffer_size != 0)
png_error(png_ptr,
"png_process_data_skip called inside png_process_data");
/* If is impossible for there to be a saved buffer at this point -
* otherwise we could not be in SKIP mode. This will also happen if
* png_process_skip is called inside png_process_data (but only very
* rarely.)
*/
if (png_ptr->save_buffer_size != 0)
png_error(png_ptr, "png_process_data_skip called with saved data");
remaining = png_ptr->skip_length;
png_ptr->skip_length = 0;
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
}
return remaining;
png_app_warning(png_ptr,
"png_process_data_skip is not implemented in any current version of libpng");
return 0;
}
/* What we do with the incoming data depends on what we were previously
@ -135,12 +116,6 @@ png_process_some_data(png_structrp png_ptr, png_inforp info_ptr) @@ -135,12 +116,6 @@ png_process_some_data(png_structrp png_ptr, png_inforp info_ptr)
break;
}
case PNG_SKIP_MODE:
{
png_push_crc_finish(png_ptr);
break;
}
default:
{
png_ptr->buffer_size = 0;
@ -158,8 +133,8 @@ png_process_some_data(png_structrp png_ptr, png_inforp info_ptr) @@ -158,8 +133,8 @@ png_process_some_data(png_structrp png_ptr, png_inforp info_ptr)
void /* PRIVATE */
png_push_read_sig(png_structrp png_ptr, png_inforp info_ptr)
{
png_size_t num_checked = png_ptr->sig_bytes, /* SAFE, does not exceed 8 */
num_to_check = 8 - num_checked;
size_t num_checked = png_ptr->sig_bytes; /* SAFE, does not exceed 8 */
size_t num_to_check = 8 - num_checked;
if (png_ptr->buffer_size < num_to_check)
{
@ -214,6 +189,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) @@ -214,6 +189,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_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->mode |= PNG_HAVE_CHUNK_HEADER;
}
@ -235,13 +211,15 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) @@ -235,13 +211,15 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
(png_ptr->mode & PNG_HAVE_PLTE) == 0)
png_error(png_ptr, "Missing PLTE before IDAT");
png_ptr->mode |= PNG_HAVE_IDAT;
png_ptr->process_mode = PNG_READ_IDAT_MODE;
if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
if ((png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) == 0)
if (png_ptr->push_length == 0)
return;
png_ptr->mode |= PNG_HAVE_IDAT;
if ((png_ptr->mode & PNG_AFTER_IDAT) != 0)
png_benign_error(png_ptr, "Too many IDATs found");
}
@ -439,71 +417,8 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr) @@ -439,71 +417,8 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
}
void /* PRIVATE */
png_push_crc_skip(png_structrp png_ptr, png_uint_32 skip)
{
png_ptr->process_mode = PNG_SKIP_MODE;
png_ptr->skip_length = skip;
}
void /* PRIVATE */
png_push_crc_finish(png_structrp png_ptr)
{
if (png_ptr->skip_length != 0 && png_ptr->save_buffer_size != 0)
{
png_size_t save_size = png_ptr->save_buffer_size;
png_uint_32 skip_length = png_ptr->skip_length;
/* We want the smaller of 'skip_length' and 'save_buffer_size', but
* they are of different types and we don't know which variable has the
* fewest bits. Carefully select the smaller and cast it to the type of
* the larger - this cannot overflow. Do not cast in the following test
* - it will break on either 16 or 64 bit platforms.
*/
if (skip_length < save_size)
save_size = (png_size_t)skip_length;
else
skip_length = (png_uint_32)save_size;
png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size);
png_ptr->skip_length -= skip_length;
png_ptr->buffer_size -= save_size;
png_ptr->save_buffer_size -= save_size;
png_ptr->save_buffer_ptr += save_size;
}
if (png_ptr->skip_length != 0 && png_ptr->current_buffer_size != 0)
{
png_size_t save_size = png_ptr->current_buffer_size;
png_uint_32 skip_length = png_ptr->skip_length;
/* We want the smaller of 'skip_length' and 'current_buffer_size', here,
* the same problem exists as above and the same solution.
*/
if (skip_length < save_size)
save_size = (png_size_t)skip_length;
else
skip_length = (png_uint_32)save_size;
png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size);
png_ptr->skip_length -= skip_length;
png_ptr->buffer_size -= save_size;
png_ptr->current_buffer_size -= save_size;
png_ptr->current_buffer_ptr += save_size;
}
if (png_ptr->skip_length == 0)
{
PNG_PUSH_SAVE_BUFFER_IF_LT(4)
png_crc_finish(png_ptr, 0);
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
}
}
void PNGCBAPI
png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, size_t length)
{
png_bytep ptr;
@ -513,7 +428,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) @@ -513,7 +428,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
ptr = buffer;
if (png_ptr->save_buffer_size != 0)
{
png_size_t save_size;
size_t save_size;
if (length < png_ptr->save_buffer_size)
save_size = length;
@ -530,7 +445,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length) @@ -530,7 +445,7 @@ png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
}
if (length != 0 && png_ptr->current_buffer_size != 0)
{
png_size_t save_size;
size_t save_size;
if (length < png_ptr->current_buffer_size)
save_size = length;
@ -552,7 +467,7 @@ png_push_save_buffer(png_structrp png_ptr) @@ -552,7 +467,7 @@ png_push_save_buffer(png_structrp png_ptr)
{
if (png_ptr->save_buffer_ptr != png_ptr->save_buffer)
{
png_size_t i, istop;
size_t i, istop;
png_bytep sp;
png_bytep dp;
@ -567,7 +482,7 @@ png_push_save_buffer(png_structrp png_ptr) @@ -567,7 +482,7 @@ png_push_save_buffer(png_structrp png_ptr)
if (png_ptr->save_buffer_size + png_ptr->current_buffer_size >
png_ptr->save_buffer_max)
{
png_size_t new_max;
size_t new_max;
png_bytep old_buffer;
if (png_ptr->save_buffer_size > PNG_SIZE_MAX -
@ -579,18 +494,19 @@ png_push_save_buffer(png_structrp png_ptr) @@ -579,18 +494,19 @@ png_push_save_buffer(png_structrp png_ptr)
new_max = png_ptr->save_buffer_size + png_ptr->current_buffer_size + 256;
old_buffer = png_ptr->save_buffer;
png_ptr->save_buffer = (png_bytep)png_malloc_warn(png_ptr,
(png_size_t)new_max);
(size_t)new_max);
if (png_ptr->save_buffer == NULL)
{
png_free(png_ptr, old_buffer);
old_buffer = NULL;
png_error(png_ptr, "Insufficient memory for save_buffer");
}
if (old_buffer)
memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
else if (png_ptr->save_buffer_size)
png_error(png_ptr, "save_buffer error");
png_free(png_ptr, old_buffer);
old_buffer = NULL;
png_ptr->save_buffer_max = new_max;
}
if (png_ptr->current_buffer_size)
@ -606,7 +522,7 @@ png_push_save_buffer(png_structrp png_ptr) @@ -606,7 +522,7 @@ png_push_save_buffer(png_structrp png_ptr)
void /* PRIVATE */
png_push_restore_buffer(png_structrp png_ptr, png_bytep buffer,
png_size_t buffer_length)
size_t buffer_length)
{
png_ptr->current_buffer = buffer;
png_ptr->current_buffer_size = buffer_length;
@ -646,17 +562,17 @@ png_push_read_IDAT(png_structrp png_ptr) @@ -646,17 +562,17 @@ png_push_read_IDAT(png_structrp png_ptr)
if (png_ptr->idat_size != 0 && png_ptr->save_buffer_size != 0)
{
png_size_t save_size = png_ptr->save_buffer_size;
size_t save_size = png_ptr->save_buffer_size;
png_uint_32 idat_size = png_ptr->idat_size;
/* We want the smaller of 'idat_size' and 'current_buffer_size', but they
* are of different types and we don't know which variable has the fewest
* bits. Carefully select the smaller and cast it to the type of the
* larger - this cannot overflow. Do not cast in the following test - it
* will break on either 16 or 64 bit platforms.
* will break on either 16-bit or 64-bit platforms.
*/
if (idat_size < save_size)
save_size = (png_size_t)idat_size;
save_size = (size_t)idat_size;
else
idat_size = (png_uint_32)save_size;
@ -673,7 +589,7 @@ png_push_read_IDAT(png_structrp png_ptr) @@ -673,7 +589,7 @@ png_push_read_IDAT(png_structrp png_ptr)
if (png_ptr->idat_size != 0 && png_ptr->current_buffer_size != 0)
{
png_size_t save_size = png_ptr->current_buffer_size;
size_t save_size = png_ptr->current_buffer_size;
png_uint_32 idat_size = png_ptr->idat_size;
/* We want the smaller of 'idat_size' and 'current_buffer_size', but they
@ -682,7 +598,7 @@ png_push_read_IDAT(png_structrp png_ptr) @@ -682,7 +598,7 @@ png_push_read_IDAT(png_structrp png_ptr)
* larger - this cannot overflow.
*/
if (idat_size < save_size)
save_size = (png_size_t)idat_size;
save_size = (size_t)idat_size;
else
idat_size = (png_uint_32)save_size;
@ -696,6 +612,7 @@ png_push_read_IDAT(png_structrp png_ptr) @@ -696,6 +612,7 @@ png_push_read_IDAT(png_structrp png_ptr)
png_ptr->current_buffer_size -= save_size;
png_ptr->current_buffer_ptr += save_size;
}
if (png_ptr->idat_size == 0)
{
PNG_PUSH_SAVE_BUFFER_IF_LT(4)
@ -708,7 +625,7 @@ png_push_read_IDAT(png_structrp png_ptr) @@ -708,7 +625,7 @@ png_push_read_IDAT(png_structrp png_ptr)
void /* PRIVATE */
png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
png_size_t buffer_length)
size_t buffer_length)
{
/* The caller checks for a non-zero buffer length. */
if (!(buffer_length > 0) || buffer == NULL)
@ -726,7 +643,7 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer, @@ -726,7 +643,7 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
* or the stream marked as finished.
*/
while (png_ptr->zstream.avail_in > 0 &&
!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0)
{
int ret;
@ -751,7 +668,7 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer, @@ -751,7 +668,7 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
* change the current behavior (see comments in inflate.c
* for why this doesn't happen at present with zlib 1.2.5).
*/
ret = inflate(&png_ptr->zstream, Z_SYNC_FLUSH);
ret = PNG_INFLATE(png_ptr, Z_SYNC_FLUSH);
/* Check for any failure before proceeding. */
if (ret != Z_OK && ret != Z_STREAM_END)
@ -767,8 +684,13 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer, @@ -767,8 +684,13 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
png_ptr->pass > 6)
png_warning(png_ptr, "Truncated compressed data in IDAT");
else
{
if (ret == Z_DATA_ERROR)
png_benign_error(png_ptr, "IDAT: ADLER32 checksum mismatch");
else
png_error(png_ptr, "Decompression error in IDAT");
}
/* Skip the check on unprocessed input */
return;
@ -1036,6 +958,7 @@ png_push_process_row(png_structrp png_ptr) @@ -1036,6 +958,7 @@ png_push_process_row(png_structrp png_ptr)
}
}
else
#endif
{
png_push_have_row(png_ptr, png_ptr->row_buf + 1);
png_read_push_finish_row(png_ptr);
@ -1045,23 +968,24 @@ png_push_process_row(png_structrp png_ptr) @@ -1045,23 +968,24 @@ png_push_process_row(png_structrp png_ptr)
void /* PRIVATE */
png_read_push_finish_row(png_structrp png_ptr)
{
#ifdef PNG_READ_INTERLACING_SUPPORTED
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
/* Start of interlace block */
static PNG_CONST png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
static const png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
/* Offset to next interlace block */
static PNG_CONST png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
static const png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
/* Start of interlace block in the y direction */
static PNG_CONST png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
static const png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
/* Offset to next interlace block in the y direction */
static PNG_CONST png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
static const png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
/* Height of interlace block. This is not currently used - if you need
* it, uncomment it here and in png.h
static PNG_CONST png_byte png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
static const png_byte png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
*/
#endif
@ -1069,6 +993,7 @@ png_read_push_finish_row(png_structrp png_ptr) @@ -1069,6 +993,7 @@ png_read_push_finish_row(png_structrp png_ptr)
if (png_ptr->row_number < png_ptr->num_rows)
return;
#ifdef PNG_READ_INTERLACING_SUPPORTED
if (png_ptr->interlaced != 0)
{
png_ptr->row_number = 0;
@ -1103,6 +1028,7 @@ png_read_push_finish_row(png_structrp png_ptr) @@ -1103,6 +1028,7 @@ png_read_push_finish_row(png_structrp png_ptr)
} while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0);
}
#endif /* READ_INTERLACING */
}
void /* PRIVATE */
@ -1127,6 +1053,7 @@ png_push_have_row(png_structrp png_ptr, png_bytep row) @@ -1127,6 +1053,7 @@ png_push_have_row(png_structrp png_ptr, png_bytep row)
(int)png_ptr->pass);
}
#ifdef PNG_READ_INTERLACING_SUPPORTED
void PNGAPI
png_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row,
png_const_bytep new_row)
@ -1141,6 +1068,7 @@ png_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row, @@ -1141,6 +1068,7 @@ png_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row,
if (new_row != NULL)
png_combine_row(png_ptr, old_row, 1/*blocky display*/);
}
#endif /* READ_INTERLACING */
void PNGAPI
png_set_progressive_read_fn(png_structrp png_ptr, png_voidp progressive_ptr,

570
png/pngpriv.h

@ -1,12 +1,10 @@ @@ -1,12 +1,10 @@
/* pngpriv.h - private declarations for use inside libpng
*
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
* Last changed in libpng 1.6.10 [March 6, 1014]]
* Copyright (c) 2018-2019 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.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -37,7 +35,9 @@ @@ -37,7 +35,9 @@
* Windows/Visual Studio) there is no effect; the OS specific tests below are
* still required (as of 2011-05-02.)
*/
#define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */
#ifndef _POSIX_SOURCE
# define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */
#endif
#ifndef PNG_VERSION_INFO_ONLY
/* Standard library headers not required by png.h: */
@ -120,8 +120,12 @@ @@ -120,8 +120,12 @@
* to compile with an appropriate #error if ALIGNED_MEMORY has been turned
* off.
*
* Note that gcc-4.9 defines __ARM_NEON instead of __ARM_NEON__, so we
* check both variants.
* Note that gcc-4.9 defines __ARM_NEON instead of the deprecated
* __ARM_NEON__, so we check both variants.
*
* To disable ARM_NEON optimizations entirely, and skip compiling the
* associated assembler code, pass --enable-arm-neon=no to configure
* or put -DPNG_ARM_NEON_OPT=0 in CPPFLAGS.
*/
# if (defined(__ARM_NEON__) || defined(__ARM_NEON)) && \
defined(PNG_ALIGNED_MEMORY_SUPPORTED)
@ -170,7 +174,10 @@ @@ -170,7 +174,10 @@
# else /* !defined __ARM_NEON__ */
/* The 'intrinsics' code simply won't compile without this -mfpu=neon:
*/
# if !defined(__aarch64__)
/* The assembler code currently does not work on ARM64 */
# define PNG_ARM_NEON_IMPLEMENTATION 2
# endif /* __aarch64__ */
# endif /* __ARM_NEON__ */
# endif /* !PNG_ARM_NEON_IMPLEMENTATION */
@ -180,6 +187,90 @@ @@ -180,6 +187,90 @@
# endif
#endif /* PNG_ARM_NEON_OPT > 0 */
#ifndef PNG_MIPS_MSA_OPT
# if defined(__mips_msa) && (__mips_isa_rev >= 5) && defined(PNG_ALIGNED_MEMORY_SUPPORTED)
# define PNG_MIPS_MSA_OPT 2
# else
# define PNG_MIPS_MSA_OPT 0
# endif
#endif
#ifndef PNG_POWERPC_VSX_OPT
# if defined(__PPC64__) && defined(__ALTIVEC__) && defined(__VSX__)
# define PNG_POWERPC_VSX_OPT 2
# else
# define PNG_POWERPC_VSX_OPT 0
# endif
#endif
#ifndef PNG_INTEL_SSE_OPT
# ifdef PNG_INTEL_SSE
/* Only check for SSE if the build configuration has been modified to
* enable SSE optimizations. This means that these optimizations will
* be off by default. See contrib/intel for more details.
*/
# if defined(__SSE4_1__) || defined(__AVX__) || defined(__SSSE3__) || \
defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) || \
(defined(_M_IX86_FP) && _M_IX86_FP >= 2)
# define PNG_INTEL_SSE_OPT 1
# else
# define PNG_INTEL_SSE_OPT 0
# endif
# else
# define PNG_INTEL_SSE_OPT 0
# endif
#endif
#if PNG_INTEL_SSE_OPT > 0
# ifndef PNG_INTEL_SSE_IMPLEMENTATION
# if defined(__SSE4_1__) || defined(__AVX__)
/* We are not actually using AVX, but checking for AVX is the best
way we can detect SSE4.1 and SSSE3 on MSVC.
*/
# define PNG_INTEL_SSE_IMPLEMENTATION 3
# elif defined(__SSSE3__)
# define PNG_INTEL_SSE_IMPLEMENTATION 2
# elif defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) || \
(defined(_M_IX86_FP) && _M_IX86_FP >= 2)
# define PNG_INTEL_SSE_IMPLEMENTATION 1
# else
# define PNG_INTEL_SSE_IMPLEMENTATION 0
# endif
# endif
# if PNG_INTEL_SSE_IMPLEMENTATION > 0
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_sse2
# endif
#else
# define PNG_INTEL_SSE_IMPLEMENTATION 0
#endif
#if PNG_MIPS_MSA_OPT > 0
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_msa
# ifndef PNG_MIPS_MSA_IMPLEMENTATION
# if defined(__mips_msa)
# if defined(__clang__)
# elif defined(__GNUC__)
# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
# define PNG_MIPS_MSA_IMPLEMENTATION 2
# endif /* no GNUC support */
# endif /* __GNUC__ */
# else /* !defined __mips_msa */
# define PNG_MIPS_MSA_IMPLEMENTATION 2
# endif /* __mips_msa */
# endif /* !PNG_MIPS_MSA_IMPLEMENTATION */
# ifndef PNG_MIPS_MSA_IMPLEMENTATION
# define PNG_MIPS_MSA_IMPLEMENTATION 1
# endif
#endif /* PNG_MIPS_MSA_OPT > 0 */
#if PNG_POWERPC_VSX_OPT > 0
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_vsx
# define PNG_POWERPC_VSX_IMPLEMENTATION 1
#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.
@ -250,17 +341,18 @@ @@ -250,17 +341,18 @@
* always be used to declare an extern data or function object in this file.
*/
#ifndef PNG_INTERNAL_DATA
# define PNG_INTERNAL_DATA(type, name, array) extern type name array
# define PNG_INTERNAL_DATA(type, name, array) PNG_LINKAGE_DATA type name array
#endif
#ifndef PNG_INTERNAL_FUNCTION
# define PNG_INTERNAL_FUNCTION(type, name, args, attributes)\
extern PNG_FUNCTION(type, name, args, PNG_EMPTY attributes)
PNG_LINKAGE_FUNCTION PNG_FUNCTION(type, name, args, PNG_EMPTY attributes)
#endif
#ifndef PNG_INTERNAL_CALLBACK
# define PNG_INTERNAL_CALLBACK(type, name, args, attributes)\
extern PNG_FUNCTION(type, (PNGCBAPI name), args, PNG_EMPTY attributes)
PNG_LINKAGE_CALLBACK PNG_FUNCTION(type, (PNGCBAPI name), args,\
PNG_EMPTY attributes)
#endif
/* If floating or fixed point APIs are disabled they may still be compiled
@ -298,48 +390,27 @@ @@ -298,48 +390,27 @@
# define PNG_DLL_EXPORT
#endif
/* SECURITY and SAFETY:
/* This is a global switch to set the compilation for an installed system
* (a release build). It can be set for testing debug builds to ensure that
* they will compile when the build type is switched to RC or STABLE, the
* default is just to use PNG_LIBPNG_BUILD_BASE_TYPE. Set this in CPPFLAGS
* with either:
*
* By default libpng is built without any internal limits on image size,
* individual heap (png_malloc) allocations or the total amount of memory used.
* If PNG_SAFE_LIMITS_SUPPORTED is defined, however, the limits below are used
* (unless individually overridden). These limits are believed to be fairly
* safe, but builders of secure systems should verify the values against the
* real system capabilities.
*/
#ifdef PNG_SAFE_LIMITS_SUPPORTED
/* 'safe' limits */
# ifndef PNG_USER_WIDTH_MAX
# define PNG_USER_WIDTH_MAX 1000000
# endif
# ifndef PNG_USER_HEIGHT_MAX
# define PNG_USER_HEIGHT_MAX 1000000
# endif
# ifndef PNG_USER_CHUNK_CACHE_MAX
# define PNG_USER_CHUNK_CACHE_MAX 128
# endif
# ifndef PNG_USER_CHUNK_MALLOC_MAX
# define PNG_USER_CHUNK_MALLOC_MAX 8000000
# endif
#else
/* values for no limits */
# ifndef PNG_USER_WIDTH_MAX
# define PNG_USER_WIDTH_MAX 0x7fffffff
# endif
# ifndef PNG_USER_HEIGHT_MAX
# define PNG_USER_HEIGHT_MAX 0x7fffffff
# endif
# ifndef PNG_USER_CHUNK_CACHE_MAX
# define PNG_USER_CHUNK_CACHE_MAX 0
# endif
# ifndef PNG_USER_CHUNK_MALLOC_MAX
# define PNG_USER_CHUNK_MALLOC_MAX 0
# endif
* -DPNG_RELEASE_BUILD Turns on the release compile path
* -DPNG_RELEASE_BUILD=0 Turns it off
* or in your pngusr.h with
* #define PNG_RELEASE_BUILD=1 Turns on the release compile path
* #define PNG_RELEASE_BUILD=0 Turns it off
*/
#ifndef PNG_RELEASE_BUILD
# define PNG_RELEASE_BUILD (PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC)
#endif
/* Moved to pngpriv.h at libpng-1.5.0 */
/* NOTE: some of these may have been used in external applications as
* these definitions were exposed in pngconf.h prior to 1.5.
/* SECURITY and SAFETY:
*
* libpng is built with support for internal limits on image dimensions and
* memory usage. These are documented in scripts/pnglibconf.dfa of the
* source and recorded in the machine generated header file pnglibconf.h.
*/
/* If you are running on a machine where you cannot allocate more
@ -392,6 +463,21 @@ @@ -392,6 +463,21 @@
# define png_fixed_error(s1,s2) png_err(s1)
#endif
/* Some fixed point APIs are still required even if not exported because
* they get used by the corresponding floating point APIs. This magic
* deals with this:
*/
#ifdef PNG_FIXED_POINT_SUPPORTED
# define PNGFAPI PNGAPI
#else
# define PNGFAPI /* PRIVATE */
#endif
#ifndef PNG_VERSION_INFO_ONLY
/* Other defines specific to compilers can go here. Try to keep
* them inside an appropriate ifdef/endif pair for portability.
*/
/* C allows up-casts from (void*) to any pointer and (const void*) to any
* pointer to a const object. C++ regards this as a type error and requires an
* explicit, static, cast and provides the static_cast<> rune to ensure that
@ -406,25 +492,20 @@ @@ -406,25 +492,20 @@
static_cast<type>(static_cast<const void*>(value))
#else
# define png_voidcast(type, value) (value)
# define png_constcast(type, value) ((type)(value))
# ifdef _WIN64
# ifdef __GNUC__
typedef unsigned long long png_ptruint;
# else
typedef unsigned __int64 png_ptruint;
# endif
# else
typedef unsigned long png_ptruint;
# endif
# define png_constcast(type, value) ((type)(png_ptruint)(const void*)(value))
# define png_aligncast(type, value) ((void*)(value))
# define png_aligncastconst(type, value) ((const void*)(value))
#endif /* __cplusplus */
/* Some fixed point APIs are still required even if not exported because
* they get used by the corresponding floating point APIs. This magic
* deals with this:
*/
#ifdef PNG_FIXED_POINT_SUPPORTED
# define PNGFAPI PNGAPI
#else
# define PNGFAPI /* PRIVATE */
#endif
#ifndef PNG_VERSION_INFO_ONLY
/* Other defines specific to compilers can go here. Try to keep
* them inside an appropriate ifdef/endif pair for portability.
*/
#if defined(PNG_FLOATING_POINT_SUPPORTED) ||\
defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)
/* png.c requires the following ANSI-C constants if the conversion of
@ -522,7 +603,8 @@ @@ -522,7 +603,8 @@
/* This implicitly assumes alignment is always to a power of 2. */
#ifdef png_alignof
# define png_isaligned(ptr, type)\
((((const char*)ptr-(const char*)0) & (png_alignof(type)-1)) == 0)
(((type)((const char*)ptr-(const char*)0) & \
(type)(png_alignof(type)-1)) == 0)
#else
# define png_isaligned(ptr, type) 0
#endif
@ -539,96 +621,92 @@ @@ -539,96 +621,92 @@
* are defined in png.h because they need to be visible to applications
* that call png_set_unknown_chunk().
*/
/* #define PNG_HAVE_IHDR 0x01 (defined in png.h) */
/* #define PNG_HAVE_PLTE 0x02 (defined in png.h) */
#define PNG_HAVE_IDAT 0x04
/* #define PNG_AFTER_IDAT 0x08 (defined in png.h) */
#define PNG_HAVE_IEND 0x10
/* 0x20 (unused) */
/* 0x40 (unused) */
/* 0x80 (unused) */
#define PNG_HAVE_CHUNK_HEADER 0x100
#define PNG_WROTE_tIME 0x200
#define PNG_WROTE_INFO_BEFORE_PLTE 0x400
#define PNG_BACKGROUND_IS_GRAY 0x800
#define PNG_HAVE_PNG_SIGNATURE 0x1000
#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */
/* 0x4000 (unused) */
#define PNG_IS_READ_STRUCT 0x8000 /* Else is a write struct */
/* #define PNG_HAVE_IHDR 0x01U (defined in png.h) */
/* #define PNG_HAVE_PLTE 0x02U (defined in png.h) */
#define PNG_HAVE_IDAT 0x04U
/* #define PNG_AFTER_IDAT 0x08U (defined in png.h) */
#define PNG_HAVE_IEND 0x10U
/* 0x20U (unused) */
/* 0x40U (unused) */
/* 0x80U (unused) */
#define PNG_HAVE_CHUNK_HEADER 0x100U
#define PNG_WROTE_tIME 0x200U
#define PNG_WROTE_INFO_BEFORE_PLTE 0x400U
#define PNG_BACKGROUND_IS_GRAY 0x800U
#define PNG_HAVE_PNG_SIGNATURE 0x1000U
#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000U /* Have another chunk after IDAT */
/* 0x4000U (unused) */
#define PNG_IS_READ_STRUCT 0x8000U /* Else is a write struct */
/* Flags for the transformations the PNG library does on the image data */
#define PNG_BGR 0x0001
#define PNG_INTERLACE 0x0002
#define PNG_PACK 0x0004
#define PNG_SHIFT 0x0008
#define PNG_SWAP_BYTES 0x0010
#define PNG_INVERT_MONO 0x0020
#define PNG_QUANTIZE 0x0040
#define PNG_COMPOSE 0x0080 /* Was PNG_BACKGROUND */
#define PNG_BACKGROUND_EXPAND 0x0100
#define PNG_EXPAND_16 0x0200 /* Added to libpng 1.5.2 */
#define PNG_16_TO_8 0x0400 /* Becomes 'chop' in 1.5.4 */
#define PNG_RGBA 0x0800
#define PNG_EXPAND 0x1000
#define PNG_GAMMA 0x2000
#define PNG_GRAY_TO_RGB 0x4000
#define PNG_FILLER 0x8000
#define PNG_PACKSWAP 0x10000
#define PNG_SWAP_ALPHA 0x20000
#define PNG_STRIP_ALPHA 0x40000
#define PNG_INVERT_ALPHA 0x80000
#define PNG_USER_TRANSFORM 0x100000
#define PNG_RGB_TO_GRAY_ERR 0x200000
#define PNG_RGB_TO_GRAY_WARN 0x400000
#define PNG_RGB_TO_GRAY 0x600000 /* two bits, RGB_TO_GRAY_ERR|WARN */
#define PNG_ENCODE_ALPHA 0x800000 /* Added to libpng-1.5.4 */
#define PNG_ADD_ALPHA 0x1000000 /* Added to libpng-1.2.7 */
#define PNG_EXPAND_tRNS 0x2000000 /* Added to libpng-1.2.9 */
#define PNG_SCALE_16_TO_8 0x4000000 /* Added to libpng-1.5.4 */
/* 0x8000000 unused */
/* 0x10000000 unused */
/* 0x20000000 unused */
/* 0x40000000 unused */
#define PNG_BGR 0x0001U
#define PNG_INTERLACE 0x0002U
#define PNG_PACK 0x0004U
#define PNG_SHIFT 0x0008U
#define PNG_SWAP_BYTES 0x0010U
#define PNG_INVERT_MONO 0x0020U
#define PNG_QUANTIZE 0x0040U
#define PNG_COMPOSE 0x0080U /* Was PNG_BACKGROUND */
#define PNG_BACKGROUND_EXPAND 0x0100U
#define PNG_EXPAND_16 0x0200U /* Added to libpng 1.5.2 */
#define PNG_16_TO_8 0x0400U /* Becomes 'chop' in 1.5.4 */
#define PNG_RGBA 0x0800U
#define PNG_EXPAND 0x1000U
#define PNG_GAMMA 0x2000U
#define PNG_GRAY_TO_RGB 0x4000U
#define PNG_FILLER 0x8000U
#define PNG_PACKSWAP 0x10000U
#define PNG_SWAP_ALPHA 0x20000U
#define PNG_STRIP_ALPHA 0x40000U
#define PNG_INVERT_ALPHA 0x80000U
#define PNG_USER_TRANSFORM 0x100000U
#define PNG_RGB_TO_GRAY_ERR 0x200000U
#define PNG_RGB_TO_GRAY_WARN 0x400000U
#define PNG_RGB_TO_GRAY 0x600000U /* two bits, RGB_TO_GRAY_ERR|WARN */
#define PNG_ENCODE_ALPHA 0x800000U /* Added to libpng-1.5.4 */
#define PNG_ADD_ALPHA 0x1000000U /* Added to libpng-1.2.7 */
#define PNG_EXPAND_tRNS 0x2000000U /* Added to libpng-1.2.9 */
#define PNG_SCALE_16_TO_8 0x4000000U /* Added to libpng-1.5.4 */
/* 0x8000000U unused */
/* 0x10000000U unused */
/* 0x20000000U unused */
/* 0x40000000U unused */
/* Flags for png_create_struct */
#define PNG_STRUCT_PNG 0x0001
#define PNG_STRUCT_INFO 0x0002
/* Scaling factor for filter heuristic weighting calculations */
#define PNG_WEIGHT_FACTOR (1<<(PNG_WEIGHT_SHIFT))
#define PNG_COST_FACTOR (1<<(PNG_COST_SHIFT))
#define PNG_STRUCT_PNG 0x0001U
#define PNG_STRUCT_INFO 0x0002U
/* Flags for the png_ptr->flags rather than declaring a byte for each one */
#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001
#define PNG_FLAG_ZSTREAM_INITIALIZED 0x0002 /* Added to libpng-1.6.0 */
/* 0x0004 unused */
#define PNG_FLAG_ZSTREAM_ENDED 0x0008 /* Added to libpng-1.6.0 */
/* 0x0010 unused */
/* 0x0020 unused */
#define PNG_FLAG_ROW_INIT 0x0040
#define PNG_FLAG_FILLER_AFTER 0x0080
#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100
#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200
#define PNG_FLAG_CRC_CRITICAL_USE 0x0400
#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800
#define PNG_FLAG_ASSUME_sRGB 0x1000 /* Added to libpng-1.5.4 */
#define PNG_FLAG_OPTIMIZE_ALPHA 0x2000 /* Added to libpng-1.5.4 */
#define PNG_FLAG_DETECT_UNINITIALIZED 0x4000 /* Added to libpng-1.5.4 */
/* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000 */
/* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000 */
#define PNG_FLAG_LIBRARY_MISMATCH 0x20000
#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000
#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000
#define PNG_FLAG_BENIGN_ERRORS_WARN 0x100000 /* Added to libpng-1.4.0 */
#define PNG_FLAG_APP_WARNINGS_WARN 0x200000 /* Added to libpng-1.6.0 */
#define PNG_FLAG_APP_ERRORS_WARN 0x400000 /* Added to libpng-1.6.0 */
/* 0x800000 unused */
/* 0x1000000 unused */
/* 0x2000000 unused */
/* 0x4000000 unused */
/* 0x8000000 unused */
/* 0x10000000 unused */
/* 0x20000000 unused */
/* 0x40000000 unused */
#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001U
#define PNG_FLAG_ZSTREAM_INITIALIZED 0x0002U /* Added to libpng-1.6.0 */
/* 0x0004U unused */
#define PNG_FLAG_ZSTREAM_ENDED 0x0008U /* Added to libpng-1.6.0 */
/* 0x0010U unused */
/* 0x0020U unused */
#define PNG_FLAG_ROW_INIT 0x0040U
#define PNG_FLAG_FILLER_AFTER 0x0080U
#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100U
#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 */
#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 */
/* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000U */
#define PNG_FLAG_LIBRARY_MISMATCH 0x20000U
#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000U
#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000U
#define PNG_FLAG_BENIGN_ERRORS_WARN 0x100000U /* Added to libpng-1.4.0 */
#define PNG_FLAG_APP_WARNINGS_WARN 0x200000U /* Added to libpng-1.6.0 */
#define PNG_FLAG_APP_ERRORS_WARN 0x400000U /* Added to libpng-1.6.0 */
/* 0x800000U unused */
/* 0x1000000U unused */
/* 0x2000000U unused */
/* 0x4000000U unused */
/* 0x8000000U unused */
/* 0x10000000U unused */
/* 0x20000000U unused */
/* 0x40000000U unused */
#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
PNG_FLAG_CRC_ANCILLARY_NOWARN)
@ -659,8 +737,26 @@ @@ -659,8 +737,26 @@
/* Added to libpng-1.2.6 JB */
#define PNG_ROWBYTES(pixel_bits, width) \
((pixel_bits) >= 8 ? \
((png_size_t)(width) * (((png_size_t)(pixel_bits)) >> 3)) : \
(( ((png_size_t)(width) * ((png_size_t)(pixel_bits))) + 7) >> 3) )
((size_t)(width) * (((size_t)(pixel_bits)) >> 3)) : \
(( ((size_t)(width) * ((size_t)(pixel_bits))) + 7) >> 3) )
/* This returns the number of trailing bits in the last byte of a row, 0 if the
* last byte is completely full of pixels. It is, in principle, (pixel_bits x
* width) % 8, but that would overflow for large 'width'. The second macro is
* the same except that it returns the number of unused bits in the last byte;
* (8-TRAILBITS), but 0 when TRAILBITS is 0.
*
* NOTE: these macros are intended to be self-evidently correct and never
* overflow on the assumption that pixel_bits is in the range 0..255. The
* arguments are evaluated only once and they can be signed (e.g. as a result of
* the integral promotions). The result of the expression always has type
* (png_uint_32), however the compiler always knows it is in the range 0..7.
*/
#define PNG_TRAILBITS(pixel_bits, width) \
(((pixel_bits) * ((width) % (png_uint_32)8)) % 8)
#define PNG_PADBITS(pixel_bits, width) \
((8 - PNG_TRAILBITS(pixel_bits, width)) % 8)
/* PNG_OUT_OF_RANGE returns true if value is outside the range
* ideal-delta..ideal+delta. Each argument is evaluated twice.
@ -687,7 +783,7 @@ @@ -687,7 +783,7 @@
/* The fixed point conversion performs range checking and evaluates
* its argument multiple times, so must be used with care. The
* range checking uses the PNG specification values for a signed
* 32 bit fixed point value except that the values are deliberately
* 32-bit fixed point value except that the values are deliberately
* rounded-to-zero to an integral value - 21474 (21474.83 is roughly
* (2^31-1) * 100000). 's' is a string that describes the value being
* converted.
@ -755,6 +851,7 @@ @@ -755,6 +851,7 @@
#define png_PLTE PNG_U32( 80, 76, 84, 69)
#define png_bKGD PNG_U32( 98, 75, 71, 68)
#define png_cHRM PNG_U32( 99, 72, 82, 77)
#define png_eXIf PNG_U32(101, 88, 73, 102) /* registered July 2017 */
#define png_fRAc PNG_U32(102, 82, 65, 99) /* registered, not defined */
#define png_gAMA PNG_U32(103, 65, 77, 65)
#define png_gIFg PNG_U32(103, 73, 70, 103)
@ -780,15 +877,17 @@ @@ -780,15 +877,17 @@
* macro will fail on top-bit-set values because of the sign extension.
*/
#define PNG_CHUNK_FROM_STRING(s)\
PNG_U32(0xff&(s)[0], 0xff&(s)[1], 0xff&(s)[2], 0xff&(s)[3])
PNG_U32(0xff & (s)[0], 0xff & (s)[1], 0xff & (s)[2], 0xff & (s)[3])
/* This uses (char), not (png_byte) to avoid warnings on systems where (char) is
* signed and the argument is a (char[]) This macro will fail miserably on
* systems where (char) is more than 8 bits.
*/
#define PNG_STRING_FROM_CHUNK(s,c)\
(void)(((char*)(s))[0]=(char)((c)>>24), ((char*)(s))[1]=(char)((c)>>16),\
((char*)(s))[2]=(char)((c)>>8), ((char*)(s))[3]=(char)((c)))
(void)(((char*)(s))[0]=(char)(((c)>>24) & 0xff), \
((char*)(s))[1]=(char)(((c)>>16) & 0xff),\
((char*)(s))[2]=(char)(((c)>>8) & 0xff), \
((char*)(s))[3]=(char)((c & 0xff)))
/* Do the same but terminate with a null character. */
#define PNG_CSTRING_FROM_CHUNK(s,c)\
@ -827,12 +926,12 @@ @@ -827,12 +926,12 @@
* PNG files the -I directives must match.
*
* The most likely explanation is that you passed a -I in CFLAGS. This will
* not work; all the preprocessor directories and in particular all the -I
* not work; all the preprocessor directives and in particular all the -I
* directives must be in CPPFLAGS.
*/
#endif
/* This is used for 16 bit gamma tables -- only the top level pointers are
/* This is used for 16-bit gamma tables -- only the top level pointers are
* const; this could be changed:
*/
typedef const png_uint_16p * png_const_uint_16pp;
@ -850,8 +949,9 @@ PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_table, [256]); @@ -850,8 +949,9 @@ PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_table, [256]);
PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_base, [512]);
PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]);
#define PNG_sRGB_FROM_LINEAR(linear) ((png_byte)((png_sRGB_base[(linear)>>15] +\
((((linear)&0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8))
#define PNG_sRGB_FROM_LINEAR(linear) \
((png_byte)(0xff & ((png_sRGB_base[(linear)>>15] \
+ ((((linear) & 0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8)))
/* Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB
* encoded value with maximum error 0.646365. Note that the input is not a
* 16-bit value; it has been multiplied by 255! */
@ -955,15 +1055,15 @@ PNG_INTERNAL_FUNCTION(void,png_zfree,(voidpf png_ptr, voidpf ptr),PNG_EMPTY); @@ -955,15 +1055,15 @@ PNG_INTERNAL_FUNCTION(void,png_zfree,(voidpf png_ptr, voidpf ptr),PNG_EMPTY);
*/
PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_read_data,(png_structp png_ptr,
png_bytep data, png_size_t length),PNG_EMPTY);
png_bytep data, size_t length),PNG_EMPTY);
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_push_fill_buffer,(png_structp png_ptr,
png_bytep buffer, png_size_t length),PNG_EMPTY);
png_bytep buffer, size_t length),PNG_EMPTY);
#endif
PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_write_data,(png_structp png_ptr,
png_bytep data, png_size_t length),PNG_EMPTY);
png_bytep data, size_t length),PNG_EMPTY);
#ifdef PNG_WRITE_FLUSH_SUPPORTED
# ifdef PNG_STDIO_SUPPORTED
@ -977,7 +1077,7 @@ PNG_INTERNAL_FUNCTION(void,png_reset_crc,(png_structrp png_ptr),PNG_EMPTY); @@ -977,7 +1077,7 @@ PNG_INTERNAL_FUNCTION(void,png_reset_crc,(png_structrp png_ptr),PNG_EMPTY);
/* Write the "data" buffer to whatever output you are using */
PNG_INTERNAL_FUNCTION(void,png_write_data,(png_structrp png_ptr,
png_const_bytep data, png_size_t length),PNG_EMPTY);
png_const_bytep data, size_t length),PNG_EMPTY);
/* Read and check the PNG file signature */
PNG_INTERNAL_FUNCTION(void,png_read_sig,(png_structrp png_ptr,
@ -989,7 +1089,7 @@ PNG_INTERNAL_FUNCTION(png_uint_32,png_read_chunk_header,(png_structrp png_ptr), @@ -989,7 +1089,7 @@ PNG_INTERNAL_FUNCTION(png_uint_32,png_read_chunk_header,(png_structrp png_ptr),
/* Read data from whatever input you are using into the "data" buffer */
PNG_INTERNAL_FUNCTION(void,png_read_data,(png_structrp png_ptr, png_bytep data,
png_size_t length),PNG_EMPTY);
size_t length),PNG_EMPTY);
/* Read bytes into buf, and update png_ptr->crc */
PNG_INTERNAL_FUNCTION(void,png_crc_read,(png_structrp png_ptr, png_bytep buf,
@ -1007,7 +1107,7 @@ PNG_INTERNAL_FUNCTION(int,png_crc_error,(png_structrp png_ptr),PNG_EMPTY); @@ -1007,7 +1107,7 @@ PNG_INTERNAL_FUNCTION(int,png_crc_error,(png_structrp png_ptr),PNG_EMPTY);
* since this is the maximum buffer size we can specify.
*/
PNG_INTERNAL_FUNCTION(void,png_calculate_crc,(png_structrp png_ptr,
png_const_bytep ptr, png_size_t length),PNG_EMPTY);
png_const_bytep ptr, size_t length),PNG_EMPTY);
#ifdef PNG_WRITE_FLUSH_SUPPORTED
PNG_INTERNAL_FUNCTION(void,png_flush,(png_structrp png_ptr),PNG_EMPTY);
@ -1052,6 +1152,11 @@ PNG_INTERNAL_FUNCTION(void,png_write_sRGB,(png_structrp png_ptr, @@ -1052,6 +1152,11 @@ PNG_INTERNAL_FUNCTION(void,png_write_sRGB,(png_structrp png_ptr,
int intent),PNG_EMPTY);
#endif
#ifdef PNG_WRITE_eXIf_SUPPORTED
PNG_INTERNAL_FUNCTION(void,png_write_eXIf,(png_structrp png_ptr,
png_bytep exif, int num_exif),PNG_EMPTY);
#endif
#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);
@ -1085,7 +1190,7 @@ PNG_INTERNAL_FUNCTION(void,png_write_hIST,(png_structrp png_ptr, @@ -1085,7 +1190,7 @@ PNG_INTERNAL_FUNCTION(void,png_write_hIST,(png_structrp png_ptr,
/* Chunks that have keywords */
#ifdef PNG_WRITE_tEXt_SUPPORTED
PNG_INTERNAL_FUNCTION(void,png_write_tEXt,(png_structrp png_ptr,
png_const_charp key, png_const_charp text, png_size_t text_len),PNG_EMPTY);
png_const_charp key, png_const_charp text, size_t text_len),PNG_EMPTY);
#endif
#ifdef PNG_WRITE_zTXt_SUPPORTED
@ -1193,6 +1298,7 @@ PNG_INTERNAL_FUNCTION(void,png_do_write_interlace,(png_row_infop row_info, @@ -1193,6 +1298,7 @@ PNG_INTERNAL_FUNCTION(void,png_do_write_interlace,(png_row_infop row_info,
PNG_INTERNAL_FUNCTION(void,png_read_filter_row,(png_structrp pp, png_row_infop
row_info, png_bytep row, png_const_bytep prev_row, int filter),PNG_EMPTY);
#if PNG_ARM_NEON_OPT > 0
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_neon,(png_row_infop row_info,
png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_neon,(png_row_infop
@ -1207,6 +1313,56 @@ PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_neon,(png_row_infop @@ -1207,6 +1313,56 @@ PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_neon,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_neon,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
#endif
#if PNG_MIPS_MSA_OPT > 0
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_msa,(png_row_infop row_info,
png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_msa,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_msa,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_msa,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_msa,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_msa,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_msa,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
#endif
#if PNG_POWERPC_VSX_OPT > 0
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_vsx,(png_row_infop row_info,
png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_vsx,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_vsx,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_vsx,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_vsx,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_vsx,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_vsx,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
#endif
#if PNG_INTEL_SSE_IMPLEMENTATION > 0
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_sse2,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_sse2,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_sse2,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_sse2,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_sse2,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_sse2,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
#endif
/* Choose the best filter to use and filter the row data */
PNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr,
@ -1234,6 +1390,14 @@ PNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr), @@ -1234,6 +1390,14 @@ PNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr),
/* Initialize the row buffers, etc. */
PNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY);
#if ZLIB_VERNUM >= 0x1240
PNG_INTERNAL_FUNCTION(int,png_zlib_inflate,(png_structrp png_ptr, int flush),
PNG_EMPTY);
# define PNG_INFLATE(pp, flush) png_zlib_inflate(pp, flush)
#else /* Zlib < 1.2.4 */
# define PNG_INFLATE(pp, flush) inflate(&(pp)->zstream, flush)
#endif /* Zlib < 1.2.4 */
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
/* Optional call to update the users info structure */
PNG_INTERNAL_FUNCTION(void,png_read_transform_info,(png_structrp png_ptr,
@ -1292,6 +1456,11 @@ PNG_INTERNAL_FUNCTION(void,png_handle_cHRM,(png_structrp png_ptr, @@ -1292,6 +1456,11 @@ 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_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);
@ -1367,9 +1536,12 @@ PNG_INTERNAL_FUNCTION(void,png_handle_zTXt,(png_structrp png_ptr, @@ -1367,9 +1536,12 @@ 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_structrp png_ptr,
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);
/* This is the function that gets called for unknown chunks. The 'keep'
@ -1408,17 +1580,13 @@ PNG_INTERNAL_FUNCTION(void,png_push_read_chunk,(png_structrp png_ptr, @@ -1408,17 +1580,13 @@ PNG_INTERNAL_FUNCTION(void,png_push_read_chunk,(png_structrp png_ptr,
PNG_INTERNAL_FUNCTION(void,png_push_read_sig,(png_structrp png_ptr,
png_inforp info_ptr),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_push_check_crc,(png_structrp png_ptr),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_push_crc_skip,(png_structrp png_ptr,
png_uint_32 length),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_push_crc_finish,(png_structrp png_ptr),
PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_push_save_buffer,(png_structrp png_ptr),
PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_push_restore_buffer,(png_structrp png_ptr,
png_bytep buffer, png_size_t buffer_length),PNG_EMPTY);
png_bytep buffer, size_t buffer_length),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_push_read_IDAT,(png_structrp png_ptr),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_process_IDAT_data,(png_structrp png_ptr,
png_bytep buffer, png_size_t buffer_length),PNG_EMPTY);
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,
@ -1507,9 +1675,11 @@ PNG_INTERNAL_FUNCTION(int,png_colorspace_set_ICC,(png_const_structrp png_ptr, @@ -1507,9 +1675,11 @@ PNG_INTERNAL_FUNCTION(int,png_colorspace_set_ICC,(png_const_structrp png_ptr,
/* 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);
#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,
@ -1686,13 +1856,13 @@ PNG_INTERNAL_FUNCTION(void,png_chunk_report,(png_const_structrp png_ptr, @@ -1686,13 +1856,13 @@ PNG_INTERNAL_FUNCTION(void,png_chunk_report,(png_const_structrp png_ptr,
#ifdef PNG_FLOATING_POINT_SUPPORTED
PNG_INTERNAL_FUNCTION(void,png_ascii_from_fp,(png_const_structrp png_ptr,
png_charp ascii, png_size_t size, double fp, unsigned int precision),
png_charp ascii, size_t size, double fp, unsigned int precision),
PNG_EMPTY);
#endif /* FLOATING_POINT */
#ifdef PNG_FIXED_POINT_SUPPORTED
PNG_INTERNAL_FUNCTION(void,png_ascii_from_fixed,(png_const_structrp png_ptr,
png_charp ascii, png_size_t size, png_fixed_point fp),PNG_EMPTY);
png_charp ascii, size_t size, png_fixed_point fp),PNG_EMPTY);
#endif /* FIXED_POINT */
#endif /* sCAL */
@ -1785,7 +1955,7 @@ PNG_INTERNAL_FUNCTION(void,png_ascii_from_fixed,(png_const_structrp png_ptr, @@ -1785,7 +1955,7 @@ PNG_INTERNAL_FUNCTION(void,png_ascii_from_fixed,(png_const_structrp png_ptr,
* the problem character.) This has not been tested within libpng.
*/
PNG_INTERNAL_FUNCTION(int,png_check_fp_number,(png_const_charp string,
png_size_t size, int *statep, png_size_tp whereami),PNG_EMPTY);
size_t size, int *statep, png_size_tp whereami),PNG_EMPTY);
/* This is the same but it checks a complete string and returns true
* only if it just contains a floating point number. As of 1.5.4 this
@ -1794,7 +1964,7 @@ PNG_INTERNAL_FUNCTION(int,png_check_fp_number,(png_const_charp string, @@ -1794,7 +1964,7 @@ PNG_INTERNAL_FUNCTION(int,png_check_fp_number,(png_const_charp string,
* for negative or zero values using the sticky flag.
*/
PNG_INTERNAL_FUNCTION(int,png_check_fp_string,(png_const_charp string,
png_size_t size),PNG_EMPTY);
size_t size),PNG_EMPTY);
#endif /* pCAL || sCAL */
#if defined(PNG_GAMMA_SUPPORTED) ||\
@ -1869,7 +2039,7 @@ typedef struct png_control @@ -1869,7 +2039,7 @@ typedef struct png_control
png_voidp error_buf; /* Always a jmp_buf at present. */
png_const_bytep memory; /* Memory buffer. */
png_size_t size; /* Size of the memory buffer. */
size_t size; /* Size of the memory buffer. */
unsigned int for_write :1; /* Otherwise it is a read structure */
unsigned int owned_file :1; /* We own the file in io_ptr */
@ -1928,10 +2098,48 @@ PNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr, @@ -1928,10 +2098,48 @@ PNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr,
* the builder of libpng passes the definition of PNG_FILTER_OPTIMIZATIONS in
* CFLAGS in place of CPPFLAGS *and* uses symbol prefixing.
*/
# if PNG_ARM_NEON_OPT > 0
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon,
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
#endif
#if PNG_MIPS_MSA_OPT > 0
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_msa,
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
#endif
# if PNG_INTEL_SSE_IMPLEMENTATION > 0
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_sse2,
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
# endif
#endif
PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr,
png_const_charp key, png_bytep new_key), PNG_EMPTY);
#if PNG_ARM_NEON_IMPLEMENTATION == 1
PNG_INTERNAL_FUNCTION(void,
png_riffle_palette_neon,
(png_structrp),
PNG_EMPTY);
PNG_INTERNAL_FUNCTION(int,
png_do_expand_palette_rgba8_neon,
(png_structrp,
png_row_infop,
png_const_bytep,
const png_bytepp,
const png_bytepp),
PNG_EMPTY);
PNG_INTERNAL_FUNCTION(int,
png_do_expand_palette_rgb8_neon,
(png_structrp,
png_row_infop,
png_const_bytep,
const png_bytepp,
const png_bytepp),
PNG_EMPTY);
#endif
/* Maintainer: Put new private prototypes here ^ */
#include "pngdebug.h"

294
png/pngread.c

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
/* pngread.c - read a PNG file
*
* Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* Copyright (c) 2018-2019 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.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -63,7 +63,7 @@ png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr, @@ -63,7 +63,7 @@ png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
/* In stable builds only warn if an application error can be completely
* handled.
*/
# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
# if PNG_RELEASE_BUILD
png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;
# endif
# endif
@ -127,7 +127,10 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr) @@ -127,7 +127,10 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
}
else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
{
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
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.
@ -172,6 +175,11 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr) @@ -172,6 +175,11 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
png_handle_cHRM(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);
@ -356,9 +364,9 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row) @@ -356,9 +364,9 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row)
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
{
png_uint_32 s0 = (*(rp ) << 8) | *(rp + 1);
png_uint_32 s1 = (*(rp + 2) << 8) | *(rp + 3);
png_uint_32 s2 = (*(rp + 4) << 8) | *(rp + 5);
png_uint_32 s0 = (png_uint_32)(*(rp ) << 8) | *(rp + 1);
png_uint_32 s1 = (png_uint_32)(*(rp + 2) << 8) | *(rp + 3);
png_uint_32 s2 = (png_uint_32)(*(rp + 4) << 8) | *(rp + 5);
png_uint_32 red = (s0 + s1 + 65536) & 0xffff;
png_uint_32 blue = (s2 + s1 + 65536) & 0xffff;
*(rp ) = (png_byte)((red >> 8) & 0xff);
@ -531,6 +539,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row) @@ -531,6 +539,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
png_error(png_ptr, "Invalid attempt to read row data");
/* Fill the row with IDAT data: */
png_ptr->row_buf[0]=255; /* to force error if no data was found */
png_read_IDAT_data(png_ptr, png_ptr->row_buf, row_info.rowbytes + 1);
if (png_ptr->row_buf[0] > PNG_FILTER_VALUE_NONE)
@ -785,6 +794,9 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr) @@ -785,6 +794,9 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
png_uint_32 length = png_read_chunk_header(png_ptr);
png_uint_32 chunk_name = png_ptr->chunk_name;
if (chunk_name != png_IDAT)
png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
if (chunk_name == png_IEND)
png_handle_IEND(png_ptr, info_ptr, length);
@ -799,9 +811,9 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr) @@ -799,9 +811,9 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
{
if (chunk_name == png_IDAT)
{
if ((length > 0) ||
(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
png_benign_error(png_ptr, "Too many IDATs found");
if ((length > 0 && !(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
|| (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
png_benign_error(png_ptr, ".Too many IDATs found");
}
png_handle_unknown(png_ptr, info_ptr, length, keep);
if (chunk_name == png_PLTE)
@ -812,11 +824,14 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr) @@ -812,11 +824,14 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
else if (chunk_name == png_IDAT)
{
/* Zero length IDATs are legal after the last IDAT has been
* read, but not after other chunks have been read.
* read, but not after other chunks have been read. 1.6 does not
* always read all the deflate data; specifically it cannot be relied
* upon to read the Adler32 at the end. If it doesn't ignore IDAT
* chunks which are longer than zero as well:
*/
if ((length > 0) ||
(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
png_benign_error(png_ptr, "Too many IDATs found");
if ((length > 0 && !(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
|| (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
png_benign_error(png_ptr, "..Too many IDATs found");
png_crc_finish(png_ptr, length);
}
@ -833,6 +848,11 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr) @@ -833,6 +848,11 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
png_handle_cHRM(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);
@ -974,6 +994,12 @@ png_read_destroy(png_structrp png_ptr) @@ -974,6 +994,12 @@ png_read_destroy(png_structrp png_ptr)
png_ptr->chunk_list = NULL;
#endif
#if defined(PNG_READ_EXPAND_SUPPORTED) && \
defined(PNG_ARM_NEON_IMPLEMENTATION)
png_free(png_ptr, png_ptr->riffled_palette);
png_ptr->riffled_palette = NULL;
#endif
/* NOTE: the 'setjmp' buffer may still be allocated and the memory and error
* callbacks are still set at this point. They are required to complete the
* destruction of the png_struct itself.
@ -1021,8 +1047,7 @@ png_set_read_status_fn(png_structrp png_ptr, png_read_status_ptr read_row_fn) @@ -1021,8 +1047,7 @@ png_set_read_status_fn(png_structrp png_ptr, png_read_status_ptr read_row_fn)
#ifdef PNG_INFO_IMAGE_SUPPORTED
void PNGAPI
png_read_png(png_structrp png_ptr, png_inforp info_ptr,
int transforms,
voidp params)
int transforms, voidp params)
{
if (png_ptr == NULL || info_ptr == NULL)
return;
@ -1385,7 +1410,9 @@ png_image_read_header(png_voidp argument) @@ -1385,7 +1410,9 @@ png_image_read_header(png_voidp argument)
png_structrp png_ptr = image->opaque->png_ptr;
png_inforp info_ptr = image->opaque->info_ptr;
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
png_set_benign_errors(png_ptr, 1/*warn*/);
#endif
png_read_info(png_ptr, info_ptr);
/* Do this the fast way; just read directly out of png_struct. */
@ -1423,7 +1450,7 @@ png_image_read_header(png_voidp argument) @@ -1423,7 +1450,7 @@ png_image_read_header(png_voidp argument)
break;
case PNG_COLOR_TYPE_PALETTE:
cmap_entries = png_ptr->num_palette;
cmap_entries = (png_uint_32)png_ptr->num_palette;
break;
default:
@ -1511,7 +1538,7 @@ png_image_begin_read_from_file(png_imagep image, const char *file_name) @@ -1511,7 +1538,7 @@ png_image_begin_read_from_file(png_imagep image, const char *file_name)
#endif /* STDIO */
static void PNGCBAPI
png_image_memory_read(png_structp png_ptr, png_bytep out, png_size_t need)
png_image_memory_read(png_structp png_ptr, png_bytep out, size_t need)
{
if (png_ptr != NULL)
{
@ -1522,7 +1549,7 @@ png_image_memory_read(png_structp png_ptr, png_bytep out, png_size_t need) @@ -1522,7 +1549,7 @@ png_image_memory_read(png_structp png_ptr, png_bytep out, png_size_t need)
if (cp != NULL)
{
png_const_bytep memory = cp->memory;
png_size_t size = cp->size;
size_t size = cp->size;
if (memory != NULL && size >= need)
{
@ -1541,7 +1568,7 @@ png_image_memory_read(png_structp png_ptr, png_bytep out, png_size_t need) @@ -1541,7 +1568,7 @@ png_image_memory_read(png_structp png_ptr, png_bytep out, png_size_t need)
}
int PNGAPI png_image_begin_read_from_memory(png_imagep image,
png_const_voidp memory, png_size_t size)
png_const_voidp memory, size_t size)
{
if (image != NULL && image->version == PNG_IMAGE_VERSION)
{
@ -1600,7 +1627,7 @@ png_image_skip_unused_chunks(png_structrp png_ptr) @@ -1600,7 +1627,7 @@ png_image_skip_unused_chunks(png_structrp png_ptr)
* errors (which are unfortunately quite common.)
*/
{
static PNG_CONST png_byte chunks_to_process[] = {
static const png_byte chunks_to_process[] = {
98, 75, 71, 68, '\0', /* bKGD */
99, 72, 82, 77, '\0', /* cHRM */
103, 65, 77, 65, '\0', /* gAMA */
@ -1684,10 +1711,11 @@ decode_gamma(png_image_read_control *display, png_uint_32 value, int encoding) @@ -1684,10 +1711,11 @@ decode_gamma(png_image_read_control *display, png_uint_32 value, int encoding)
value *= 257;
break;
#ifdef __GNUC__
default:
png_error(display->image->opaque->png_ptr,
"unexpected encoding (internal error)");
break;
#endif
}
return value;
@ -1736,9 +1764,9 @@ png_create_colormap_entry(png_image_read_control *display, @@ -1736,9 +1764,9 @@ png_create_colormap_entry(png_image_read_control *display,
png_uint_32 alpha, int encoding)
{
png_imagep image = display->image;
const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
P_LINEAR : P_sRGB;
const int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 &&
int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 &&
(red != green || green != blue);
if (ip > 255)
@ -1824,6 +1852,7 @@ png_create_colormap_entry(png_image_read_control *display, @@ -1824,6 +1852,7 @@ png_create_colormap_entry(png_image_read_control *display,
y = (y + 128) >> 8;
y *= 255;
y = PNG_sRGB_FROM_LINEAR((y + 64) >> 7);
alpha = PNG_DIV257(alpha);
encoding = P_sRGB;
}
@ -1846,13 +1875,13 @@ png_create_colormap_entry(png_image_read_control *display, @@ -1846,13 +1875,13 @@ png_create_colormap_entry(png_image_read_control *display,
/* Store the value. */
{
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
const int afirst = (image->format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
int afirst = (image->format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
(image->format & PNG_FORMAT_FLAG_ALPHA) != 0;
# else
# define afirst 0
# endif
# ifdef PNG_FORMAT_BGR_SUPPORTED
const int bgr = (image->format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
int bgr = (image->format & PNG_FORMAT_FLAG_BGR) != 0 ? 2 : 0;
# else
# define bgr 0
# endif
@ -1871,7 +1900,7 @@ png_create_colormap_entry(png_image_read_control *display, @@ -1871,7 +1900,7 @@ png_create_colormap_entry(png_image_read_control *display,
{
case 4:
entry[afirst ? 0 : 3] = (png_uint_16)alpha;
/* FALL THROUGH */
/* FALLTHROUGH */
case 3:
if (alpha < 65535)
@ -1893,7 +1922,7 @@ png_create_colormap_entry(png_image_read_control *display, @@ -1893,7 +1922,7 @@ png_create_colormap_entry(png_image_read_control *display,
case 2:
entry[1 ^ afirst] = (png_uint_16)alpha;
/* FALL THROUGH */
/* FALLTHROUGH */
case 1:
if (alpha < 65535)
@ -1922,6 +1951,7 @@ png_create_colormap_entry(png_image_read_control *display, @@ -1922,6 +1951,7 @@ png_create_colormap_entry(png_image_read_control *display,
{
case 4:
entry[afirst ? 0 : 3] = (png_byte)alpha;
/* FALLTHROUGH */
case 3:
entry[afirst + (2 ^ bgr)] = (png_byte)blue;
entry[afirst + 1] = (png_byte)green;
@ -1930,6 +1960,7 @@ png_create_colormap_entry(png_image_read_control *display, @@ -1930,6 +1960,7 @@ png_create_colormap_entry(png_image_read_control *display,
case 2:
entry[1 ^ afirst] = (png_byte)alpha;
/* FALLTHROUGH */
case 1:
entry[afirst] = (png_byte)green;
break;
@ -1956,7 +1987,7 @@ make_gray_file_colormap(png_image_read_control *display) @@ -1956,7 +1987,7 @@ make_gray_file_colormap(png_image_read_control *display)
for (i=0; i<256; ++i)
png_create_colormap_entry(display, i, i, i, i, 255, P_FILE);
return i;
return (int)i;
}
static int
@ -1967,7 +1998,7 @@ make_gray_colormap(png_image_read_control *display) @@ -1967,7 +1998,7 @@ make_gray_colormap(png_image_read_control *display)
for (i=0; i<256; ++i)
png_create_colormap_entry(display, i, i, i, i, 255, P_sRGB);
return i;
return (int)i;
}
#define PNG_GRAY_COLORMAP_ENTRIES 256
@ -2021,7 +2052,7 @@ make_ga_colormap(png_image_read_control *display) @@ -2021,7 +2052,7 @@ make_ga_colormap(png_image_read_control *display)
P_sRGB);
}
return i;
return (int)i;
}
#define PNG_GA_COLORMAP_ENTRIES 256
@ -2046,7 +2077,7 @@ make_rgb_colormap(png_image_read_control *display) @@ -2046,7 +2077,7 @@ make_rgb_colormap(png_image_read_control *display)
}
}
return i;
return (int)i;
}
#define PNG_RGB_COLORMAP_ENTRIES 216
@ -2060,11 +2091,11 @@ png_image_read_colormap(png_voidp argument) @@ -2060,11 +2091,11 @@ png_image_read_colormap(png_voidp argument)
{
png_image_read_control *display =
png_voidcast(png_image_read_control*, argument);
const png_imagep image = display->image;
png_imagep image = display->image;
const png_structrp png_ptr = image->opaque->png_ptr;
const png_uint_32 output_format = image->format;
const int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
png_structrp png_ptr = image->opaque->png_ptr;
png_uint_32 output_format = image->format;
int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) != 0 ?
P_LINEAR : P_sRGB;
unsigned int cmap_entries;
@ -2094,7 +2125,7 @@ png_image_read_colormap(png_voidp argument) @@ -2094,7 +2125,7 @@ png_image_read_colormap(png_voidp argument)
else if (display->background == NULL /* no way to remove it */)
png_error(png_ptr,
"a background color must be supplied to remove alpha/transparency");
"background color must be supplied to remove alpha/transparency");
/* Get a copy of the background color (this avoids repeating the checks
* below.) The encoding is 8-bit sRGB or 16-bit linear, depending on the
@ -2239,7 +2270,7 @@ png_image_read_colormap(png_voidp argument) @@ -2239,7 +2270,7 @@ png_image_read_colormap(png_voidp argument)
if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries)
png_error(png_ptr, "gray[16] color-map: too few entries");
cmap_entries = make_gray_colormap(display);
cmap_entries = (unsigned int)make_gray_colormap(display);
if (png_ptr->num_trans > 0)
{
@ -2286,8 +2317,14 @@ png_image_read_colormap(png_voidp argument) @@ -2286,8 +2317,14 @@ png_image_read_colormap(png_voidp argument)
output_processing = PNG_CMAP_NONE;
break;
}
#ifdef __COVERITY__
/* Coverity claims that output_encoding cannot be 2 (P_LINEAR)
* here.
*/
back_alpha = 255;
#else
back_alpha = output_encoding == P_LINEAR ? 65535 : 255;
#endif
}
/* output_processing means that the libpng-processed row will be
@ -2331,7 +2368,7 @@ png_image_read_colormap(png_voidp argument) @@ -2331,7 +2368,7 @@ png_image_read_colormap(png_voidp argument)
if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries)
png_error(png_ptr, "gray+alpha color-map: too few entries");
cmap_entries = make_ga_colormap(display);
cmap_entries = (unsigned int)make_ga_colormap(display);
background_index = PNG_CMAP_GA_BACKGROUND;
output_processing = PNG_CMAP_GA;
@ -2365,7 +2402,7 @@ png_image_read_colormap(png_voidp argument) @@ -2365,7 +2402,7 @@ png_image_read_colormap(png_voidp argument)
if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries)
png_error(png_ptr, "gray-alpha color-map: too few entries");
cmap_entries = make_gray_colormap(display);
cmap_entries = (unsigned int)make_gray_colormap(display);
if (output_encoding == P_LINEAR)
{
@ -2412,7 +2449,14 @@ png_image_read_colormap(png_voidp argument) @@ -2412,7 +2449,14 @@ png_image_read_colormap(png_voidp argument)
*/
background_index = i;
png_create_colormap_entry(display, i++, back_r, back_g, back_b,
output_encoding == P_LINEAR ? 65535U : 255U, output_encoding);
#ifdef __COVERITY__
/* Coverity claims that output_encoding
* cannot be 2 (P_LINEAR) here.
*/ 255U,
#else
output_encoding == P_LINEAR ? 65535U : 255U,
#endif
output_encoding);
/* For non-opaque input composite on the sRGB background - this
* requires inverting the encoding for each component. The input
@ -2497,7 +2541,7 @@ png_image_read_colormap(png_voidp argument) @@ -2497,7 +2541,7 @@ png_image_read_colormap(png_voidp argument)
if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries)
png_error(png_ptr, "rgb[ga] color-map: too few entries");
cmap_entries = make_ga_colormap(display);
cmap_entries = (unsigned int)make_ga_colormap(display);
background_index = PNG_CMAP_GA_BACKGROUND;
output_processing = PNG_CMAP_GA;
}
@ -2523,12 +2567,12 @@ png_image_read_colormap(png_voidp argument) @@ -2523,12 +2567,12 @@ png_image_read_colormap(png_voidp argument)
png_ptr->num_trans > 0) &&
png_gamma_not_sRGB(png_ptr->colorspace.gamma) != 0)
{
cmap_entries = make_gray_file_colormap(display);
cmap_entries = (unsigned int)make_gray_file_colormap(display);
data_encoding = P_FILE;
}
else
cmap_entries = make_gray_colormap(display);
cmap_entries = (unsigned int)make_gray_colormap(display);
/* But if the input has alpha or transparency it must be removed
*/
@ -2616,7 +2660,7 @@ png_image_read_colormap(png_voidp argument) @@ -2616,7 +2660,7 @@ png_image_read_colormap(png_voidp argument)
if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries)
png_error(png_ptr, "rgb+alpha color-map: too few entries");
cmap_entries = make_rgb_colormap(display);
cmap_entries = (unsigned int)make_rgb_colormap(display);
/* Add a transparent entry. */
png_create_colormap_entry(display, cmap_entries, 255, 255,
@ -2665,7 +2709,7 @@ png_image_read_colormap(png_voidp argument) @@ -2665,7 +2709,7 @@ png_image_read_colormap(png_voidp argument)
if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries)
png_error(png_ptr, "rgb-alpha color-map: too few entries");
cmap_entries = make_rgb_colormap(display);
cmap_entries = (unsigned int)make_rgb_colormap(display);
png_create_colormap_entry(display, cmap_entries, back_r,
back_g, back_b, 0/*unused*/, output_encoding);
@ -2750,7 +2794,7 @@ png_image_read_colormap(png_voidp argument) @@ -2750,7 +2794,7 @@ png_image_read_colormap(png_voidp argument)
if (PNG_RGB_COLORMAP_ENTRIES > image->colormap_entries)
png_error(png_ptr, "rgb color-map: too few entries");
cmap_entries = make_rgb_colormap(display);
cmap_entries = (unsigned int)make_rgb_colormap(display);
output_processing = PNG_CMAP_RGB;
}
}
@ -2764,7 +2808,7 @@ png_image_read_colormap(png_voidp argument) @@ -2764,7 +2808,7 @@ png_image_read_colormap(png_voidp argument)
unsigned int num_trans = png_ptr->num_trans;
png_const_bytep trans = num_trans > 0 ? png_ptr->trans_alpha : NULL;
png_const_colorp colormap = png_ptr->palette;
const int do_background = trans != NULL &&
int do_background = trans != NULL &&
(output_format & PNG_FORMAT_FLAG_ALPHA) == 0;
unsigned int i;
@ -2774,11 +2818,11 @@ png_image_read_colormap(png_voidp argument) @@ -2774,11 +2818,11 @@ png_image_read_colormap(png_voidp argument)
output_processing = PNG_CMAP_NONE;
data_encoding = P_FILE; /* Don't change from color-map indices */
cmap_entries = png_ptr->num_palette;
cmap_entries = (unsigned int)png_ptr->num_palette;
if (cmap_entries > 256)
cmap_entries = 256;
if (cmap_entries > image->colormap_entries)
if (cmap_entries > (unsigned int)image->colormap_entries)
png_error(png_ptr, "palette color-map: too few entries");
for (i=0; i < cmap_entries; ++i)
@ -2795,12 +2839,12 @@ png_image_read_colormap(png_voidp argument) @@ -2795,12 +2839,12 @@ png_image_read_colormap(png_voidp argument)
* on the sRGB color in 'back'.
*/
png_create_colormap_entry(display, i,
png_colormap_compose(display, colormap[i].red, P_FILE,
trans[i], back_r, output_encoding),
png_colormap_compose(display, colormap[i].green, P_FILE,
trans[i], back_g, output_encoding),
png_colormap_compose(display, colormap[i].blue, P_FILE,
trans[i], back_b, output_encoding),
png_colormap_compose(display, colormap[i].red,
P_FILE, trans[i], back_r, output_encoding),
png_colormap_compose(display, colormap[i].green,
P_FILE, trans[i], back_g, output_encoding),
png_colormap_compose(display, colormap[i].blue,
P_FILE, trans[i], back_b, output_encoding),
output_encoding == P_LINEAR ? trans[i] * 257U :
trans[i],
output_encoding);
@ -2824,7 +2868,6 @@ png_image_read_colormap(png_voidp argument) @@ -2824,7 +2868,6 @@ png_image_read_colormap(png_voidp argument)
default:
png_error(png_ptr, "invalid PNG color type");
/*NOT REACHED*/
break;
}
/* Now deal with the output processing */
@ -2834,19 +2877,20 @@ png_image_read_colormap(png_voidp argument) @@ -2834,19 +2877,20 @@ png_image_read_colormap(png_voidp argument)
switch (data_encoding)
{
default:
png_error(png_ptr, "bad data option (internal error)");
break;
case P_sRGB:
/* Change to 8-bit sRGB */
png_set_alpha_mode_fixed(png_ptr, PNG_ALPHA_PNG, PNG_GAMMA_sRGB);
/* FALL THROUGH */
/* FALLTHROUGH */
case P_FILE:
if (png_ptr->bit_depth > 8)
png_set_scale_16(png_ptr);
break;
#ifdef __GNUC__
default:
png_error(png_ptr, "bad data option (internal error)");
#endif
}
if (cmap_entries > 256 || cmap_entries > image->colormap_entries)
@ -2890,7 +2934,7 @@ png_image_read_colormap(png_voidp argument) @@ -2890,7 +2934,7 @@ png_image_read_colormap(png_voidp argument)
png_error(png_ptr, "bad background index (internal error)");
}
display->colormap_processing = output_processing;
display->colormap_processing = (int)output_processing;
return 1/*ok*/;
}
@ -3154,8 +3198,7 @@ png_image_read_colormapped(png_voidp argument) @@ -3154,8 +3198,7 @@ png_image_read_colormapped(png_voidp argument)
image->colormap_entries == 244 /* 216 + 1 + 27 */)
break;
/* goto bad_output; */
/* FALL THROUGH */
goto bad_output;
default:
bad_output:
@ -3199,14 +3242,14 @@ png_image_read_colormapped(png_voidp argument) @@ -3199,14 +3242,14 @@ png_image_read_colormapped(png_voidp argument)
else
{
png_alloc_size_t row_bytes = display->row_bytes;
png_alloc_size_t row_bytes = (png_alloc_size_t)display->row_bytes;
while (--passes >= 0)
{
png_uint_32 y = image->height;
png_bytep row = png_voidcast(png_bytep, display->first_row);
while (y-- > 0)
for (; y > 0; --y)
{
png_read_row(png_ptr, row, NULL);
row += row_bytes;
@ -3397,10 +3440,6 @@ png_image_read_background(png_voidp argument) @@ -3397,10 +3440,6 @@ png_image_read_background(png_voidp argument)
*/
switch (info_ptr->bit_depth)
{
default:
png_error(png_ptr, "unexpected bit depth");
break;
case 8:
/* 8-bit sRGB gray values with an alpha channel; the alpha channel is
* to be removed by composing on a background: either the row if
@ -3413,8 +3452,7 @@ png_image_read_background(png_voidp argument) @@ -3413,8 +3452,7 @@ png_image_read_background(png_voidp argument)
for (pass = 0; pass < passes; ++pass)
{
png_bytep row = png_voidcast(png_bytep,
display->first_row);
png_bytep row = png_voidcast(png_bytep, display->first_row);
unsigned int startx, stepx, stepy;
png_uint_32 y;
@ -3539,8 +3577,9 @@ png_image_read_background(png_voidp argument) @@ -3539,8 +3577,9 @@ png_image_read_background(png_voidp argument)
* stride which was multiplied by 2 (below) to get row_bytes.
*/
ptrdiff_t step_row = display->row_bytes / 2;
int preserve_alpha = (image->format & PNG_FORMAT_FLAG_ALPHA) != 0;
unsigned int outchannels = 1+preserve_alpha;
unsigned int preserve_alpha = (image->format &
PNG_FORMAT_FLAG_ALPHA) != 0;
unsigned int outchannels = 1U+preserve_alpha;
int swap_alpha = 0;
# ifdef PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED
@ -3618,6 +3657,11 @@ png_image_read_background(png_voidp argument) @@ -3618,6 +3657,11 @@ png_image_read_background(png_voidp argument)
}
}
break;
#ifdef __GNUC__
default:
png_error(png_ptr, "unexpected bit depth");
#endif
}
return 1;
@ -3722,6 +3766,12 @@ png_image_read_direct(png_voidp argument) @@ -3722,6 +3766,12 @@ png_image_read_direct(png_voidp argument)
output_gamma = PNG_DEFAULT_sRGB;
}
if ((change & PNG_FORMAT_FLAG_ASSOCIATED_ALPHA) != 0)
{
mode = PNG_ALPHA_OPTIMIZED;
change &= ~PNG_FORMAT_FLAG_ASSOCIATED_ALPHA;
}
/* If 'do_local_background' is set check for the presence of gamma
* correction; this is part of the work-round for the libpng bug
* described above.
@ -3833,7 +3883,7 @@ png_image_read_direct(png_voidp argument) @@ -3833,7 +3883,7 @@ png_image_read_direct(png_voidp argument)
else
filler = 255;
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
#ifdef PNG_FORMAT_AFIRST_SUPPORTED
if ((format & PNG_FORMAT_FLAG_AFIRST) != 0)
{
where = PNG_FILLER_BEFORE;
@ -3841,7 +3891,7 @@ png_image_read_direct(png_voidp argument) @@ -3841,7 +3891,7 @@ png_image_read_direct(png_voidp argument)
}
else
# endif
#endif
where = PNG_FILLER_AFTER;
png_set_add_alpha(png_ptr, filler, where);
@ -3902,7 +3952,7 @@ png_image_read_direct(png_voidp argument) @@ -3902,7 +3952,7 @@ png_image_read_direct(png_voidp argument)
*/
if (linear != 0)
{
PNG_CONST png_uint_16 le = 0x0001;
png_uint_16 le = 0x0001;
if ((*(png_const_bytep) & le) != 0)
png_set_swap(png_ptr);
@ -3947,15 +3997,19 @@ png_image_read_direct(png_voidp argument) @@ -3947,15 +3997,19 @@ png_image_read_direct(png_voidp argument)
else if (do_local_compose != 0) /* internal error */
png_error(png_ptr, "png_image_read: alpha channel lost");
if ((format & PNG_FORMAT_FLAG_ASSOCIATED_ALPHA) != 0) {
info_format |= PNG_FORMAT_FLAG_ASSOCIATED_ALPHA;
}
if (info_ptr->bit_depth == 16)
info_format |= PNG_FORMAT_FLAG_LINEAR;
# ifdef PNG_FORMAT_BGR_SUPPORTED
#ifdef PNG_FORMAT_BGR_SUPPORTED
if ((png_ptr->transformations & PNG_BGR) != 0)
info_format |= PNG_FORMAT_FLAG_BGR;
# endif
#endif
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
#ifdef PNG_FORMAT_AFIRST_SUPPORTED
if (do_local_background == 2)
{
if ((format & PNG_FORMAT_FLAG_AFIRST) != 0)
@ -4032,14 +4086,14 @@ png_image_read_direct(png_voidp argument) @@ -4032,14 +4086,14 @@ png_image_read_direct(png_voidp argument)
else
{
png_alloc_size_t row_bytes = display->row_bytes;
png_alloc_size_t row_bytes = (png_alloc_size_t)display->row_bytes;
while (--passes >= 0)
{
png_uint_32 y = image->height;
png_bytep row = png_voidcast(png_bytep, display->first_row);
while (y-- > 0)
for (; y > 0; --y)
{
png_read_row(png_ptr, row, NULL);
row += row_bytes;
@ -4055,20 +4109,57 @@ png_image_finish_read(png_imagep image, png_const_colorp background, @@ -4055,20 +4109,57 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
void *buffer, png_int_32 row_stride, void *colormap)
{
if (image != NULL && image->version == PNG_IMAGE_VERSION)
{
/* Check for row_stride overflow. This check is not performed on the
* original PNG format because it may not occur in the output PNG format
* and libpng deals with the issues of reading the original.
*/
unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
/* The following checks just the 'row_stride' calculation to ensure it
* fits in a signed 32-bit value. Because channels/components can be
* either 1 or 2 bytes in size the length of a row can still overflow 32
* bits; this is just to verify that the 'row_stride' argument can be
* represented.
*/
if (image->width <= 0x7fffffffU/channels) /* no overflow */
{
png_uint_32 check;
png_uint_32 png_row_stride = image->width * channels;
if (row_stride == 0)
row_stride = PNG_IMAGE_ROW_STRIDE(*image);
row_stride = (png_int_32)/*SAFE*/png_row_stride;
if (row_stride < 0)
check = -row_stride;
check = (png_uint_32)(-row_stride);
else
check = row_stride;
check = (png_uint_32)row_stride;
if (image->opaque != NULL && buffer != NULL &&
check >= PNG_IMAGE_ROW_STRIDE(*image))
/* This verifies 'check', the absolute value of the actual stride
* passed in and detects overflow in the application calculation (i.e.
* if the app did actually pass in a non-zero 'row_stride'.
*/
if (image->opaque != NULL && buffer != NULL && check >= png_row_stride)
{
/* Now check for overflow of the image buffer calculation; this
* limits the whole image size to 32 bits for API compatibility with
* the current, 32-bit, PNG_IMAGE_BUFFER_SIZE macro.
*
* The PNG_IMAGE_BUFFER_SIZE macro is:
*
* (PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)*height*(row_stride))
*
* And the component size is always 1 or 2, so make sure that the
* number of *bytes* that the application is saying are available
* does actually fit into a 32-bit number.
*
* NOTE: this will be changed in 1.7 because PNG_IMAGE_BUFFER_SIZE
* will be changed to use png_alloc_size_t; bigger images can be
* accommodated on 64-bit systems.
*/
if (image->height <=
0xffffffffU/PNG_IMAGE_PIXEL_COMPONENT_SIZE(image->format)/check)
{
if ((image->format & PNG_FORMAT_FLAG_COLORMAP) == 0 ||
(image->colormap_entries > 0 && colormap != NULL))
@ -4084,17 +4175,20 @@ png_image_finish_read(png_imagep image, png_const_colorp background, @@ -4084,17 +4175,20 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
display.background = background;
display.local_row = NULL;
/* Choose the correct 'end' routine; for the color-map case all the
* setup has already been done.
/* Choose the correct 'end' routine; for the color-map case
* all the setup has already been done.
*/
if ((image->format & PNG_FORMAT_FLAG_COLORMAP) != 0)
result =
png_safe_execute(image, png_image_read_colormap, &display) &&
png_safe_execute(image, png_image_read_colormapped, &display);
png_safe_execute(image,
png_image_read_colormap, &display) &&
png_safe_execute(image,
png_image_read_colormapped, &display);
else
result =
png_safe_execute(image, png_image_read_direct, &display);
png_safe_execute(image,
png_image_read_direct, &display);
png_image_free(image);
return result;
@ -4105,11 +4199,21 @@ png_image_finish_read(png_imagep image, png_const_colorp background, @@ -4105,11 +4199,21 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
"png_image_finish_read[color-map]: no color-map");
}
else
return png_image_error(image,
"png_image_finish_read: image too large");
}
else
return png_image_error(image,
"png_image_finish_read: invalid argument");
}
else
return png_image_error(image,
"png_image_finish_read: row_stride too large");
}
else if (image != NULL)
return png_image_error(image,
"png_image_finish_read: damaged PNG_IMAGE_VERSION");

18
png/pngrio.c

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
/* pngrio.c - functions for data input
*
* Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* Copyright (c) 2018 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.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -26,10 +26,10 @@ @@ -26,10 +26,10 @@
* reads from a file pointer. Note that this routine sometimes gets called
* with very small lengths, so you should implement some kind of simple
* buffering if you are using unbuffered reads. This should never be asked
* to read more then 64K on a 16 bit machine.
* to read more than 64K on a 16-bit machine.
*/
void /* PRIVATE */
png_read_data(png_structrp png_ptr, png_bytep data, png_size_t length)
png_read_data(png_structrp png_ptr, png_bytep data, size_t length)
{
png_debug1(4, "reading %d bytes", (int)length);
@ -47,14 +47,14 @@ png_read_data(png_structrp png_ptr, png_bytep data, png_size_t length) @@ -47,14 +47,14 @@ png_read_data(png_structrp png_ptr, png_bytep data, png_size_t length)
* than changing the library.
*/
void PNGCBAPI
png_default_read_data(png_structp png_ptr, png_bytep data, png_size_t length)
png_default_read_data(png_structp png_ptr, png_bytep data, size_t length)
{
png_size_t check;
size_t check;
if (png_ptr == NULL)
return;
/* fread() returns 0 on error, so it is OK to store this in a png_size_t
/* 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));

360
png/pngrtran.c

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
* Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* Copyright (c) 2018-2019 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.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -18,6 +18,17 @@ @@ -18,6 +18,17 @@
#include "pngpriv.h"
#ifdef PNG_ARM_NEON_IMPLEMENTATION
# if PNG_ARM_NEON_IMPLEMENTATION == 1
# define PNG_ARM_NEON_INTRINSICS_AVAILABLE
# if defined(_MSC_VER) && defined(_M_ARM64)
# include <arm64_neon.h>
# else
# include <arm_neon.h>
# endif
# endif
#endif
#ifdef PNG_READ_SUPPORTED
/* Set the action on getting a CRC error for an ancillary or critical chunk. */
@ -49,6 +60,7 @@ png_set_crc_action(png_structrp png_ptr, int crit_action, int ancil_action) @@ -49,6 +60,7 @@ png_set_crc_action(png_structrp png_ptr, int crit_action, int ancil_action)
case PNG_CRC_WARN_DISCARD: /* Not a valid action for critical data */
png_warning(png_ptr,
"Can't discard critical data on CRC error");
/* FALLTHROUGH */
case PNG_CRC_ERROR_QUIT: /* Error/quit */
case PNG_CRC_DEFAULT:
@ -289,9 +301,12 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode, @@ -289,9 +301,12 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
* is expected to be 1 or greater, but this range test allows for some
* viewing correction values. The intent is to weed out users of this API
* who use the inverse of the gamma value accidentally! Since some of these
* values are reasonable this may have to be changed.
* values are reasonable this may have to be changed:
*
* 1.6.x: changed from 0.07..3 to 0.01..100 (to accommodate the optimal 16-bit
* gamma of 36, and its reciprocal.)
*/
if (output_gamma < 70000 || output_gamma > 300000)
if (output_gamma < 1000 || output_gamma > 10000000)
png_error(png_ptr, "output gamma out of expected range");
/* The default file gamma is the inverse of the output gamma; the output
@ -394,7 +409,7 @@ png_set_alpha_mode(png_structrp png_ptr, int mode, double output_gamma) @@ -394,7 +409,7 @@ png_set_alpha_mode(png_structrp png_ptr, int mode, double output_gamma)
/* Dither file to 8-bit. Supply a palette, the current number
* of elements in the palette, the maximum number of elements
* allowed, and a histogram if possible. If the current number
* of colors is greater then the maximum number, the palette will be
* of colors is greater than the maximum number, the palette will be
* modified to fit in the maximum number. "full_quantize" indicates
* whether we need a quantizing cube set up for RGB images, or if we
* simply are reducing the number of colors in a paletted image.
@ -426,7 +441,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, @@ -426,7 +441,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
int i;
png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr,
(png_uint_32)(num_palette * (sizeof (png_byte))));
(png_alloc_size_t)((png_uint_32)num_palette * (sizeof (png_byte))));
for (i = 0; i < num_palette; i++)
png_ptr->quantize_index[i] = (png_byte)i;
}
@ -443,7 +458,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, @@ -443,7 +458,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
/* Initialize an array to sort colors */
png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr,
(png_uint_32)(num_palette * (sizeof (png_byte))));
(png_alloc_size_t)((png_uint_32)num_palette * (sizeof (png_byte))));
/* Initialize the quantize_sort array */
for (i = 0; i < num_palette; i++)
@ -577,9 +592,11 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, @@ -577,9 +592,11 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
/* Initialize palette index arrays */
png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
(png_uint_32)(num_palette * (sizeof (png_byte))));
(png_alloc_size_t)((png_uint_32)num_palette *
(sizeof (png_byte))));
png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
(png_uint_32)(num_palette * (sizeof (png_byte))));
(png_alloc_size_t)((png_uint_32)num_palette *
(sizeof (png_byte))));
/* Initialize the sort array */
for (i = 0; i < num_palette; i++)
@ -588,7 +605,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, @@ -588,7 +605,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
png_ptr->palette_to_index[i] = (png_byte)i;
}
hash = (png_dsortpp)png_calloc(png_ptr, (png_uint_32)(769 *
hash = (png_dsortpp)png_calloc(png_ptr, (png_alloc_size_t)(769 *
(sizeof (png_dsortp))));
num_new_palette = num_palette;
@ -619,7 +636,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, @@ -619,7 +636,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
{
t = (png_dsortp)png_malloc_warn(png_ptr,
(png_uint_32)(sizeof (png_dsort)));
(png_alloc_size_t)(sizeof (png_dsort)));
if (t == NULL)
break;
@ -741,12 +758,12 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette, @@ -741,12 +758,12 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
int num_red = (1 << PNG_QUANTIZE_RED_BITS);
int num_green = (1 << PNG_QUANTIZE_GREEN_BITS);
int num_blue = (1 << PNG_QUANTIZE_BLUE_BITS);
png_size_t num_entries = ((png_size_t)1 << total_bits);
size_t num_entries = ((size_t)1 << total_bits);
png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr,
(png_uint_32)(num_entries * (sizeof (png_byte))));
(png_alloc_size_t)(num_entries * (sizeof (png_byte))));
distance = (png_bytep)png_malloc(png_ptr, (png_uint_32)(num_entries *
distance = (png_bytep)png_malloc(png_ptr, (png_alloc_size_t)(num_entries *
(sizeof (png_byte))));
memset(distance, 0xff, num_entries * (sizeof (png_byte)));
@ -976,7 +993,6 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action, @@ -976,7 +993,6 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
default:
png_error(png_ptr, "invalid error action to rgb_to_gray");
break;
}
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
@ -1175,9 +1191,9 @@ png_init_palette_transformations(png_structrp png_ptr) @@ -1175,9 +1191,9 @@ png_init_palette_transformations(png_structrp png_ptr)
*/
int i, istop = png_ptr->num_trans;
for (i=0; i<istop; i++)
png_ptr->trans_alpha[i] = (png_byte)(255 -
png_ptr->trans_alpha[i]);
for (i = 0; i < istop; i++)
png_ptr->trans_alpha[i] =
(png_byte)(255 - png_ptr->trans_alpha[i]);
}
}
#endif /* READ_INVERT_ALPHA */
@ -1251,7 +1267,7 @@ png_init_rgb_transformations(png_structrp png_ptr) @@ -1251,7 +1267,7 @@ png_init_rgb_transformations(png_structrp png_ptr)
default:
case 8:
/* FALL THROUGH (Already 8 bits) */
/* FALLTHROUGH */ /* (Already 8 bits) */
case 16:
/* Already a full 16 bits */
@ -1312,7 +1328,7 @@ png_init_read_transformations(png_structrp png_ptr) @@ -1312,7 +1328,7 @@ png_init_read_transformations(png_structrp png_ptr)
else if (png_ptr->screen_gamma != 0)
/* The converse - assume the file matches the screen, note that this
* perhaps undesireable default can (from 1.5.4) be changed by calling
* 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.)
*/
@ -1880,7 +1896,7 @@ png_init_read_transformations(png_structrp png_ptr) @@ -1880,7 +1896,7 @@ png_init_read_transformations(png_structrp png_ptr)
png_ptr->transformations &= ~PNG_SHIFT;
/* significant bits can be in the range 1 to 7 for a meaninful result, if
/* significant bits can be in the range 1 to 7 for a meaningful result, if
* the number of significant bits is 0 then no shift is done (this is an
* error condition which is silently ignored.)
*/
@ -1997,7 +2013,7 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr) @@ -1997,7 +2013,7 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
# endif
# else
/* No 16 bit support: force chopping 16-bit input down to 8, in this case
/* No 16-bit support: force chopping 16-bit input down to 8, in this case
* the app program can chose if both APIs are available by setting the
* correct scaling to use.
*/
@ -2098,10 +2114,10 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr) @@ -2098,10 +2114,10 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
defined(PNG_READ_USER_TRANSFORM_SUPPORTED)
if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
{
if (info_ptr->bit_depth < png_ptr->user_transform_depth)
if (png_ptr->user_transform_depth != 0)
info_ptr->bit_depth = png_ptr->user_transform_depth;
if (info_ptr->channels < png_ptr->user_transform_channels)
if (png_ptr->user_transform_channels != 0)
info_ptr->channels = png_ptr->user_transform_channels;
}
#endif
@ -2146,9 +2162,9 @@ png_do_unpack(png_row_infop row_info, png_bytep row) @@ -2146,9 +2162,9 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
{
case 1:
{
png_bytep sp = row + (png_size_t)((row_width - 1) >> 3);
png_bytep dp = row + (png_size_t)row_width - 1;
png_uint_32 shift = 7 - (int)((row_width + 7) & 0x07);
png_bytep sp = row + (size_t)((row_width - 1) >> 3);
png_bytep dp = row + (size_t)row_width - 1;
png_uint_32 shift = 7U - ((row_width + 7U) & 0x07);
for (i = 0; i < row_width; i++)
{
*dp = (png_byte)((*sp >> shift) & 0x01);
@ -2170,9 +2186,9 @@ png_do_unpack(png_row_infop row_info, png_bytep row) @@ -2170,9 +2186,9 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
case 2:
{
png_bytep sp = row + (png_size_t)((row_width - 1) >> 2);
png_bytep dp = row + (png_size_t)row_width - 1;
png_uint_32 shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
png_bytep sp = row + (size_t)((row_width - 1) >> 2);
png_bytep dp = row + (size_t)row_width - 1;
png_uint_32 shift = ((3U - ((row_width + 3U) & 0x03)) << 1);
for (i = 0; i < row_width; i++)
{
*dp = (png_byte)((*sp >> shift) & 0x03);
@ -2193,9 +2209,9 @@ png_do_unpack(png_row_infop row_info, png_bytep row) @@ -2193,9 +2209,9 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
case 4:
{
png_bytep sp = row + (png_size_t)((row_width - 1) >> 1);
png_bytep dp = row + (png_size_t)row_width - 1;
png_uint_32 shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);
png_bytep sp = row + (size_t)((row_width - 1) >> 1);
png_bytep dp = row + (size_t)row_width - 1;
png_uint_32 shift = ((1U - ((row_width + 1U) & 0x01)) << 2);
for (i = 0; i < row_width; i++)
{
*dp = (png_byte)((*sp >> shift) & 0x0f);
@ -2357,7 +2373,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row, @@ -2357,7 +2373,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row,
if (++channel >= channels)
channel = 0;
*bp++ = (png_byte)(value >> 8);
*bp++ = (png_byte)(value & 0xff);
*bp++ = (png_byte)value;
}
break;
}
@ -2382,8 +2398,8 @@ png_do_scale_16_to_8(png_row_infop row_info, png_bytep row) @@ -2382,8 +2398,8 @@ png_do_scale_16_to_8(png_row_infop row_info, png_bytep row)
while (sp < ep)
{
/* The input is an array of 16 bit components, these must be scaled to
* 8 bits each. For a 16 bit value V the required value (from the PNG
/* The input is an array of 16-bit components, these must be scaled to
* 8 bits each. For a 16-bit value V the required value (from the PNG
* specification) is:
*
* (V * 255) / 65535
@ -2404,7 +2420,7 @@ png_do_scale_16_to_8(png_row_infop row_info, png_bytep row) @@ -2404,7 +2420,7 @@ png_do_scale_16_to_8(png_row_infop row_info, png_bytep row)
*
* The approximate differs from the exact answer only when (vlo-vhi) is
* 128; it then gives a correction of +1 when the exact correction is
* 0. This gives 128 errors. The exact answer (correct for all 16 bit
* 0. This gives 128 errors. The exact answer (correct for all 16-bit
* input values) is:
*
* error = (vlo-vhi+128)*65535 >> 24;
@ -2458,10 +2474,10 @@ png_do_chop(png_row_infop row_info, png_bytep row) @@ -2458,10 +2474,10 @@ png_do_chop(png_row_infop row_info, png_bytep row)
static void
png_do_read_swap_alpha(png_row_infop row_info, png_bytep row)
{
png_uint_32 row_width = row_info->width;
png_debug(1, "in png_do_read_swap_alpha");
{
png_uint_32 row_width = row_info->width;
if (row_info->color_type == PNG_COLOR_TYPE_RGB_ALPHA)
{
/* This converts from RGBA to ARGB */
@ -2547,7 +2563,6 @@ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row) @@ -2547,7 +2563,6 @@ png_do_read_swap_alpha(png_row_infop row_info, png_bytep row)
}
#endif
}
}
}
#endif
@ -2662,9 +2677,9 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, @@ -2662,9 +2677,9 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
png_uint_32 row_width = row_info->width;
#ifdef PNG_READ_16BIT_SUPPORTED
png_byte hi_filler = (png_byte)((filler>>8) & 0xff);
png_byte hi_filler = (png_byte)(filler>>8);
#endif
png_byte lo_filler = (png_byte)(filler & 0xff);
png_byte lo_filler = (png_byte)filler;
png_debug(1, "in png_do_read_filler");
@ -2676,8 +2691,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, @@ -2676,8 +2691,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
if ((flags & PNG_FLAG_FILLER_AFTER) != 0)
{
/* This changes the data from G to GX */
png_bytep sp = row + (png_size_t)row_width;
png_bytep dp = sp + (png_size_t)row_width;
png_bytep sp = row + (size_t)row_width;
png_bytep dp = sp + (size_t)row_width;
for (i = 1; i < row_width; i++)
{
*(--dp) = lo_filler;
@ -2692,8 +2707,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, @@ -2692,8 +2707,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
else
{
/* This changes the data from G to XG */
png_bytep sp = row + (png_size_t)row_width;
png_bytep dp = sp + (png_size_t)row_width;
png_bytep sp = row + (size_t)row_width;
png_bytep dp = sp + (size_t)row_width;
for (i = 0; i < row_width; i++)
{
*(--dp) = *(--sp);
@ -2711,17 +2726,17 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, @@ -2711,17 +2726,17 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
if ((flags & PNG_FLAG_FILLER_AFTER) != 0)
{
/* This changes the data from GG to GGXX */
png_bytep sp = row + (png_size_t)row_width * 2;
png_bytep dp = sp + (png_size_t)row_width * 2;
png_bytep sp = row + (size_t)row_width * 2;
png_bytep dp = sp + (size_t)row_width * 2;
for (i = 1; i < row_width; i++)
{
*(--dp) = hi_filler;
*(--dp) = lo_filler;
*(--dp) = hi_filler;
*(--dp) = *(--sp);
*(--dp) = *(--sp);
}
*(--dp) = hi_filler;
*(--dp) = lo_filler;
*(--dp) = hi_filler;
row_info->channels = 2;
row_info->pixel_depth = 32;
row_info->rowbytes = row_width * 4;
@ -2730,14 +2745,14 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, @@ -2730,14 +2745,14 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
else
{
/* This changes the data from GG to XXGG */
png_bytep sp = row + (png_size_t)row_width * 2;
png_bytep dp = sp + (png_size_t)row_width * 2;
png_bytep sp = row + (size_t)row_width * 2;
png_bytep dp = sp + (size_t)row_width * 2;
for (i = 0; i < row_width; i++)
{
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = hi_filler;
*(--dp) = lo_filler;
*(--dp) = hi_filler;
}
row_info->channels = 2;
row_info->pixel_depth = 32;
@ -2753,8 +2768,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, @@ -2753,8 +2768,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
if ((flags & PNG_FLAG_FILLER_AFTER) != 0)
{
/* This changes the data from RGB to RGBX */
png_bytep sp = row + (png_size_t)row_width * 3;
png_bytep dp = sp + (png_size_t)row_width;
png_bytep sp = row + (size_t)row_width * 3;
png_bytep dp = sp + (size_t)row_width;
for (i = 1; i < row_width; i++)
{
*(--dp) = lo_filler;
@ -2771,8 +2786,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, @@ -2771,8 +2786,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
else
{
/* This changes the data from RGB to XRGB */
png_bytep sp = row + (png_size_t)row_width * 3;
png_bytep dp = sp + (png_size_t)row_width;
png_bytep sp = row + (size_t)row_width * 3;
png_bytep dp = sp + (size_t)row_width;
for (i = 0; i < row_width; i++)
{
*(--dp) = *(--sp);
@ -2792,12 +2807,12 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, @@ -2792,12 +2807,12 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
if ((flags & PNG_FLAG_FILLER_AFTER) != 0)
{
/* This changes the data from RRGGBB to RRGGBBXX */
png_bytep sp = row + (png_size_t)row_width * 6;
png_bytep dp = sp + (png_size_t)row_width * 2;
png_bytep sp = row + (size_t)row_width * 6;
png_bytep dp = sp + (size_t)row_width * 2;
for (i = 1; i < row_width; i++)
{
*(--dp) = hi_filler;
*(--dp) = lo_filler;
*(--dp) = hi_filler;
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = *(--sp);
@ -2805,8 +2820,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, @@ -2805,8 +2820,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
*(--dp) = *(--sp);
*(--dp) = *(--sp);
}
*(--dp) = hi_filler;
*(--dp) = lo_filler;
*(--dp) = hi_filler;
row_info->channels = 4;
row_info->pixel_depth = 64;
row_info->rowbytes = row_width * 8;
@ -2815,8 +2830,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, @@ -2815,8 +2830,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
else
{
/* This changes the data from RRGGBB to XXRRGGBB */
png_bytep sp = row + (png_size_t)row_width * 6;
png_bytep dp = sp + (png_size_t)row_width * 2;
png_bytep sp = row + (size_t)row_width * 6;
png_bytep dp = sp + (size_t)row_width * 2;
for (i = 0; i < row_width; i++)
{
*(--dp) = *(--sp);
@ -2825,8 +2840,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row, @@ -2825,8 +2840,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = *(--sp);
*(--dp) = hi_filler;
*(--dp) = lo_filler;
*(--dp) = hi_filler;
}
row_info->channels = 4;
@ -2857,8 +2872,8 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) @@ -2857,8 +2872,8 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
if (row_info->bit_depth == 8)
{
/* This changes G to RGB */
png_bytep sp = row + (png_size_t)row_width - 1;
png_bytep dp = sp + (png_size_t)row_width * 2;
png_bytep sp = row + (size_t)row_width - 1;
png_bytep dp = sp + (size_t)row_width * 2;
for (i = 0; i < row_width; i++)
{
*(dp--) = *sp;
@ -2870,8 +2885,8 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) @@ -2870,8 +2885,8 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
else
{
/* This changes GG to RRGGBB */
png_bytep sp = row + (png_size_t)row_width * 2 - 1;
png_bytep dp = sp + (png_size_t)row_width * 4;
png_bytep sp = row + (size_t)row_width * 2 - 1;
png_bytep dp = sp + (size_t)row_width * 4;
for (i = 0; i < row_width; i++)
{
*(dp--) = *sp;
@ -2889,8 +2904,8 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) @@ -2889,8 +2904,8 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
if (row_info->bit_depth == 8)
{
/* This changes GA to RGBA */
png_bytep sp = row + (png_size_t)row_width * 2 - 1;
png_bytep dp = sp + (png_size_t)row_width * 2;
png_bytep sp = row + (size_t)row_width * 2 - 1;
png_bytep dp = sp + (size_t)row_width * 2;
for (i = 0; i < row_width; i++)
{
*(dp--) = *(sp--);
@ -2903,8 +2918,8 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) @@ -2903,8 +2918,8 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
else
{
/* This changes GGAA to RRGGBBAA */
png_bytep sp = row + (png_size_t)row_width * 4 - 1;
png_bytep dp = sp + (png_size_t)row_width * 4;
png_bytep sp = row + (size_t)row_width * 4 - 1;
png_bytep dp = sp + (size_t)row_width * 4;
for (i = 0; i < row_width; i++)
{
*(dp--) = *(sp--);
@ -2932,7 +2947,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) @@ -2932,7 +2947,7 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
* using the equation given in Poynton's ColorFAQ of 1998-01-04 at
* <http://www.inforamp.net/~poynton/> (THIS LINK IS DEAD June 2008 but
* versions dated 1998 through November 2002 have been archived at
* http://web.archive.org/web/20000816232553/http://www.inforamp.net/
* https://web.archive.org/web/20000816232553/www.inforamp.net/
* ~poynton/notes/colour_and_gamma/ColorFAQ.txt )
* Charles Poynton poynton at poynton.com
*
@ -2975,14 +2990,13 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row) @@ -2975,14 +2990,13 @@ png_do_gray_to_rgb(png_row_infop row_info, png_bytep row)
* values this results in an implicit assumption that the original PNG RGB
* values were linear.
*
* Other integer coefficents can be used via png_set_rgb_to_gray(). Because
* Other integer coefficients can be used via png_set_rgb_to_gray(). Because
* the API takes just red and green coefficients the blue coefficient is
* calculated to make the sum 32768. This will result in different rounding
* to that used above.
*/
static int
png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
{
int rgb_error = 0;
@ -2991,12 +3005,11 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row) @@ -2991,12 +3005,11 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
if ((row_info->color_type & PNG_COLOR_MASK_PALETTE) == 0 &&
(row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
{
PNG_CONST png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
PNG_CONST png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;
PNG_CONST png_uint_32 bc = 32768 - rc - gc;
PNG_CONST png_uint_32 row_width = row_info->width;
PNG_CONST int have_alpha =
(row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0;
png_uint_32 rc = png_ptr->rgb_to_gray_red_coeff;
png_uint_32 gc = png_ptr->rgb_to_gray_green_coeff;
png_uint_32 bc = 32768 - rc - gc;
png_uint_32 row_width = row_info->width;
int have_alpha = (row_info->color_type & PNG_COLOR_MASK_ALPHA) != 0;
if (row_info->bit_depth == 8)
{
@ -3087,10 +3100,11 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row) @@ -3087,10 +3100,11 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
for (i = 0; i < row_width; i++)
{
png_uint_16 red, green, blue, w;
png_byte hi,lo;
red = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
green = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
blue = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
hi=*(sp)++; lo=*(sp)++; red = (png_uint_16)((hi << 8) | (lo));
hi=*(sp)++; lo=*(sp)++; green = (png_uint_16)((hi << 8) | (lo));
hi=*(sp)++; lo=*(sp)++; blue = (png_uint_16)((hi << 8) | (lo));
if (red == green && red == blue)
{
@ -3104,16 +3118,16 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row) @@ -3104,16 +3118,16 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
else
{
png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff)
png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red & 0xff)
>> png_ptr->gamma_shift][red>>8];
png_uint_16 green_1 =
png_ptr->gamma_16_to_1[(green&0xff) >>
png_ptr->gamma_16_to_1[(green & 0xff) >>
png_ptr->gamma_shift][green>>8];
png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff)
png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue & 0xff)
>> png_ptr->gamma_shift][blue>>8];
png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1
+ bc*blue_1 + 16384)>>15);
w = png_ptr->gamma_16_from_1[(gray16&0xff) >>
w = png_ptr->gamma_16_from_1[(gray16 & 0xff) >>
png_ptr->gamma_shift][gray16 >> 8];
rgb_error |= 1;
}
@ -3138,17 +3152,18 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row) @@ -3138,17 +3152,18 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
for (i = 0; i < row_width; i++)
{
png_uint_16 red, green, blue, gray16;
png_byte hi,lo;
red = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
green = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
blue = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
hi=*(sp)++; lo=*(sp)++; red = (png_uint_16)((hi << 8) | (lo));
hi=*(sp)++; lo=*(sp)++; green = (png_uint_16)((hi << 8) | (lo));
hi=*(sp)++; lo=*(sp)++; blue = (png_uint_16)((hi << 8) | (lo));
if (red != green || red != blue)
rgb_error |= 1;
/* From 1.5.5 in the 16 bit case do the accurate conversion even
/* From 1.5.5 in the 16-bit case do the accurate conversion even
* in the 'fast' case - this is because this is where the code
* ends up when handling linear 16 bit data.
* ends up when handling linear 16-bit data.
*/
gray16 = (png_uint_16)((rc*red + gc*green + bc*blue + 16384) >>
15);
@ -3202,7 +3217,6 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) @@ -3202,7 +3217,6 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
png_debug(1, "in png_do_compose");
{
switch (row_info->color_type)
{
case PNG_COLOR_TYPE_GRAY:
@ -3219,7 +3233,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) @@ -3219,7 +3233,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
== png_ptr->trans_color.gray)
{
unsigned int tmp = *sp & (0x7f7f >> (7 - shift));
tmp |= png_ptr->background.gray << shift;
tmp |=
(unsigned int)(png_ptr->background.gray << shift);
*sp = (png_byte)(tmp & 0xff);
}
@ -3248,7 +3263,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) @@ -3248,7 +3263,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
== png_ptr->trans_color.gray)
{
unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
tmp |= png_ptr->background.gray << shift;
tmp |=
(unsigned int)png_ptr->background.gray << shift;
*sp = (png_byte)(tmp & 0xff);
}
@ -3258,7 +3274,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) @@ -3258,7 +3274,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
unsigned int g = (gamma_table [p | (p << 2) |
(p << 4) | (p << 6)] >> 6) & 0x03;
unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
tmp |= g << shift;
tmp |= (unsigned int)(g << shift);
*sp = (png_byte)(tmp & 0xff);
}
@ -3284,7 +3300,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) @@ -3284,7 +3300,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
== png_ptr->trans_color.gray)
{
unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
tmp |= png_ptr->background.gray << shift;
tmp |=
(unsigned int)png_ptr->background.gray << shift;
*sp = (png_byte)(tmp & 0xff);
}
@ -3313,8 +3330,9 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) @@ -3313,8 +3330,9 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
if ((png_uint_16)((*sp >> shift) & 0x0f)
== png_ptr->trans_color.gray)
{
unsigned int tmp = *sp & (0xf0f >> (4 - shift));
tmp |= png_ptr->background.gray << shift;
unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
tmp |=
(unsigned int)(png_ptr->background.gray << shift);
*sp = (png_byte)(tmp & 0xff);
}
@ -3323,8 +3341,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) @@ -3323,8 +3341,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
unsigned int p = (*sp >> shift) & 0x0f;
unsigned int g = (gamma_table[p | (p << 4)] >> 4) &
0x0f;
unsigned int tmp = *sp & (0xf0f >> (4 - shift));
tmp |= g << shift;
unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
tmp |= (unsigned int)(g << shift);
*sp = (png_byte)(tmp & 0xff);
}
@ -3349,8 +3367,9 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) @@ -3349,8 +3367,9 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
if ((png_uint_16)((*sp >> shift) & 0x0f)
== png_ptr->trans_color.gray)
{
unsigned int tmp = *sp & (0xf0f >> (4 - shift));
tmp |= png_ptr->background.gray << shift;
unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
tmp |=
(unsigned int)(png_ptr->background.gray << shift);
*sp = (png_byte)(tmp & 0xff);
}
@ -3667,7 +3686,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) @@ -3667,7 +3686,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
if (optimize != 0)
w = v;
else
w = gamma_16_from_1[(v&0xff) >> gamma_shift][v >> 8];
w = gamma_16_from_1[(v & 0xff) >>
gamma_shift][v >> 8];
*sp = (png_byte)((w >> 8) & 0xff);
*(sp + 1) = (png_byte)(w & 0xff);
}
@ -3831,7 +3851,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) @@ -3831,7 +3851,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];
png_composite_16(w, v, a, png_ptr->background_1.red);
if (optimize == 0)
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
w = gamma_16_from_1[((w & 0xff) >> gamma_shift)][w >>
8];
*sp = (png_byte)((w >> 8) & 0xff);
*(sp + 1) = (png_byte)(w & 0xff);
@ -3839,7 +3859,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) @@ -3839,7 +3859,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)];
png_composite_16(w, v, a, png_ptr->background_1.green);
if (optimize == 0)
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
w = gamma_16_from_1[((w & 0xff) >> gamma_shift)][w >>
8];
*(sp + 2) = (png_byte)((w >> 8) & 0xff);
@ -3848,7 +3868,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) @@ -3848,7 +3868,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)];
png_composite_16(w, v, a, png_ptr->background_1.blue);
if (optimize == 0)
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
w = gamma_16_from_1[((w & 0xff) >> gamma_shift)][w >>
8];
*(sp + 4) = (png_byte)((w >> 8) & 0xff);
@ -3910,7 +3930,6 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr) @@ -3910,7 +3930,6 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
default:
break;
}
}
}
#endif /* READ_BACKGROUND || READ_ALPHA_MODE */
@ -4133,12 +4152,11 @@ png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr) @@ -4133,12 +4152,11 @@ png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
{
if (row_info->bit_depth == 8)
{
PNG_CONST png_bytep table = png_ptr->gamma_from_1;
png_bytep table = png_ptr->gamma_from_1;
if (table != NULL)
{
PNG_CONST int step =
(row_info->color_type & PNG_COLOR_MASK_COLOR) ? 4 : 2;
int step = (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 4 : 2;
/* The alpha channel is the last component: */
row += step - 1;
@ -4152,13 +4170,12 @@ png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr) @@ -4152,13 +4170,12 @@ png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
else if (row_info->bit_depth == 16)
{
PNG_CONST png_uint_16pp table = png_ptr->gamma_16_from_1;
PNG_CONST int gamma_shift = png_ptr->gamma_shift;
png_uint_16pp table = png_ptr->gamma_16_from_1;
int gamma_shift = png_ptr->gamma_shift;
if (table != NULL)
{
PNG_CONST int step =
(row_info->color_type & PNG_COLOR_MASK_COLOR) ? 8 : 4;
int step = (row_info->color_type & PNG_COLOR_MASK_COLOR) ? 8 : 4;
/* The alpha channel is the last component: */
row += step - 2;
@ -4189,8 +4206,9 @@ png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr) @@ -4189,8 +4206,9 @@ png_do_encode_alpha(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
* upon whether you supply trans and num_trans.
*/
static void
png_do_expand_palette(png_row_infop row_info, png_bytep row,
png_const_colorp palette, png_const_bytep trans_alpha, int num_trans)
png_do_expand_palette(png_structrp png_ptr, png_row_infop row_info,
png_bytep row, png_const_colorp palette, png_const_bytep trans_alpha,
int num_trans)
{
int shift, value;
png_bytep sp, dp;
@ -4207,8 +4225,8 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, @@ -4207,8 +4225,8 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
{
case 1:
{
sp = row + (png_size_t)((row_width - 1) >> 3);
dp = row + (png_size_t)row_width - 1;
sp = row + (size_t)((row_width - 1) >> 3);
dp = row + (size_t)row_width - 1;
shift = 7 - (int)((row_width + 7) & 0x07);
for (i = 0; i < row_width; i++)
{
@ -4234,8 +4252,8 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, @@ -4234,8 +4252,8 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
case 2:
{
sp = row + (png_size_t)((row_width - 1) >> 2);
dp = row + (png_size_t)row_width - 1;
sp = row + (size_t)((row_width - 1) >> 2);
dp = row + (size_t)row_width - 1;
shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
for (i = 0; i < row_width; i++)
{
@ -4257,8 +4275,8 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, @@ -4257,8 +4275,8 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
case 4:
{
sp = row + (png_size_t)((row_width - 1) >> 1);
dp = row + (png_size_t)row_width - 1;
sp = row + (size_t)((row_width - 1) >> 1);
dp = row + (size_t)row_width - 1;
shift = (int)((row_width & 0x01) << 2);
for (i = 0; i < row_width; i++)
{
@ -4291,17 +4309,30 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, @@ -4291,17 +4309,30 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
{
if (num_trans > 0)
{
sp = row + (png_size_t)row_width - 1;
dp = row + (png_size_t)(row_width << 2) - 1;
sp = row + (size_t)row_width - 1;
dp = row + ((size_t)row_width << 2) - 1;
for (i = 0; i < row_width; i++)
i = 0;
#ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE
if (png_ptr->riffled_palette != NULL)
{
/* The RGBA optimization works with png_ptr->bit_depth == 8
* but sometimes row_info->bit_depth has been changed to 8.
* In these cases, the palette hasn't been riffled.
*/
i = png_do_expand_palette_rgba8_neon(png_ptr, row_info, row,
&sp, &dp);
}
#else
PNG_UNUSED(png_ptr)
#endif
for (; i < row_width; i++)
{
if ((int)(*sp) >= num_trans)
*dp-- = 0xff;
else
*dp-- = trans_alpha[*sp];
*dp-- = palette[*sp].blue;
*dp-- = palette[*sp].green;
*dp-- = palette[*sp].red;
@ -4316,10 +4347,17 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row, @@ -4316,10 +4347,17 @@ png_do_expand_palette(png_row_infop row_info, png_bytep row,
else
{
sp = row + (png_size_t)row_width - 1;
dp = row + (png_size_t)(row_width * 3) - 1;
sp = row + (size_t)row_width - 1;
dp = row + (size_t)(row_width * 3) - 1;
i = 0;
#ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE
i = png_do_expand_palette_rgb8_neon(png_ptr, row_info, row,
&sp, &dp);
#else
PNG_UNUSED(png_ptr)
#endif
for (i = 0; i < row_width; i++)
for (; i < row_width; i++)
{
*dp-- = palette[*sp].blue;
*dp-- = palette[*sp].green;
@ -4352,7 +4390,6 @@ png_do_expand(png_row_infop row_info, png_bytep row, @@ -4352,7 +4390,6 @@ png_do_expand(png_row_infop row_info, png_bytep row,
png_debug(1, "in png_do_expand");
{
if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
{
unsigned int gray = trans_color != NULL ? trans_color->gray : 0;
@ -4364,8 +4401,8 @@ png_do_expand(png_row_infop row_info, png_bytep row, @@ -4364,8 +4401,8 @@ png_do_expand(png_row_infop row_info, png_bytep row,
case 1:
{
gray = (gray & 0x01) * 0xff;
sp = row + (png_size_t)((row_width - 1) >> 3);
dp = row + (png_size_t)row_width - 1;
sp = row + (size_t)((row_width - 1) >> 3);
dp = row + (size_t)row_width - 1;
shift = 7 - (int)((row_width + 7) & 0x07);
for (i = 0; i < row_width; i++)
{
@ -4392,8 +4429,8 @@ png_do_expand(png_row_infop row_info, png_bytep row, @@ -4392,8 +4429,8 @@ png_do_expand(png_row_infop row_info, png_bytep row,
case 2:
{
gray = (gray & 0x03) * 0x55;
sp = row + (png_size_t)((row_width - 1) >> 2);
dp = row + (png_size_t)row_width - 1;
sp = row + (size_t)((row_width - 1) >> 2);
dp = row + (size_t)row_width - 1;
shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
for (i = 0; i < row_width; i++)
{
@ -4417,8 +4454,8 @@ png_do_expand(png_row_infop row_info, png_bytep row, @@ -4417,8 +4454,8 @@ png_do_expand(png_row_infop row_info, png_bytep row,
case 4:
{
gray = (gray & 0x0f) * 0x11;
sp = row + (png_size_t)((row_width - 1) >> 1);
dp = row + (png_size_t)row_width - 1;
sp = row + (size_t)((row_width - 1) >> 1);
dp = row + (size_t)row_width - 1;
shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);
for (i = 0; i < row_width; i++)
{
@ -4452,12 +4489,12 @@ png_do_expand(png_row_infop row_info, png_bytep row, @@ -4452,12 +4489,12 @@ png_do_expand(png_row_infop row_info, png_bytep row,
if (row_info->bit_depth == 8)
{
gray = gray & 0xff;
sp = row + (png_size_t)row_width - 1;
dp = row + (png_size_t)(row_width << 1) - 1;
sp = row + (size_t)row_width - 1;
dp = row + ((size_t)row_width << 1) - 1;
for (i = 0; i < row_width; i++)
{
if (*sp == gray)
if ((*sp & 0xffU) == gray)
*dp-- = 0;
else
@ -4475,7 +4512,8 @@ png_do_expand(png_row_infop row_info, png_bytep row, @@ -4475,7 +4512,8 @@ png_do_expand(png_row_infop row_info, png_bytep row,
dp = row + (row_info->rowbytes << 1) - 1;
for (i = 0; i < row_width; i++)
{
if (*(sp - 1) == gray_high && *(sp) == gray_low)
if ((*(sp - 1) & 0xffU) == gray_high &&
(*(sp) & 0xffU) == gray_low)
{
*dp-- = 0;
*dp-- = 0;
@ -4507,8 +4545,8 @@ png_do_expand(png_row_infop row_info, png_bytep row, @@ -4507,8 +4545,8 @@ png_do_expand(png_row_infop row_info, png_bytep row,
png_byte red = (png_byte)(trans_color->red & 0xff);
png_byte green = (png_byte)(trans_color->green & 0xff);
png_byte blue = (png_byte)(trans_color->blue & 0xff);
sp = row + (png_size_t)row_info->rowbytes - 1;
dp = row + (png_size_t)(row_width << 2) - 1;
sp = row + (size_t)row_info->rowbytes - 1;
dp = row + ((size_t)row_width << 2) - 1;
for (i = 0; i < row_width; i++)
{
if (*(sp - 2) == red && *(sp - 1) == green && *(sp) == blue)
@ -4531,7 +4569,7 @@ png_do_expand(png_row_infop row_info, png_bytep row, @@ -4531,7 +4569,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
png_byte green_low = (png_byte)(trans_color->green & 0xff);
png_byte blue_low = (png_byte)(trans_color->blue & 0xff);
sp = row + row_info->rowbytes - 1;
dp = row + (png_size_t)(row_width << 3) - 1;
dp = row + ((size_t)row_width << 3) - 1;
for (i = 0; i < row_width; i++)
{
if (*(sp - 5) == red_high &&
@ -4564,7 +4602,6 @@ png_do_expand(png_row_infop row_info, png_bytep row, @@ -4564,7 +4602,6 @@ png_do_expand(png_row_infop row_info, png_bytep row,
row_info->pixel_depth = (png_byte)(row_info->bit_depth << 2);
row_info->rowbytes = PNG_ROWBYTES(row_info->pixel_depth, row_width);
}
}
}
#endif
@ -4590,7 +4627,9 @@ png_do_expand_16(png_row_infop row_info, png_bytep row) @@ -4590,7 +4627,9 @@ png_do_expand_16(png_row_infop row_info, png_bytep row)
png_byte *sp = row + row_info->rowbytes; /* source, last byte + 1 */
png_byte *dp = sp + row_info->rowbytes; /* destination, end + 1 */
while (dp > sp)
dp[-2] = dp[-1] = *--sp, dp -= 2;
{
dp[-2] = dp[-1] = *--sp; dp -= 2;
}
row_info->rowbytes *= 2;
row_info->bit_depth = 16;
@ -4732,7 +4771,19 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) @@ -4732,7 +4771,19 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
{
if (row_info->color_type == PNG_COLOR_TYPE_PALETTE)
{
png_do_expand_palette(row_info, png_ptr->row_buf + 1,
#ifdef PNG_ARM_NEON_INTRINSICS_AVAILABLE
if ((png_ptr->num_trans > 0) && (png_ptr->bit_depth == 8))
{
if (png_ptr->riffled_palette == NULL)
{
/* Initialize the accelerated palette expansion. */
png_ptr->riffled_palette =
(png_bytep)png_malloc(png_ptr, 256 * 4);
png_riffle_palette_neon(png_ptr);
}
}
#endif
png_do_expand_palette(png_ptr, row_info, png_ptr->row_buf + 1,
png_ptr->palette, png_ptr->trans_alpha, png_ptr->num_trans);
}
@ -4744,8 +4795,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) @@ -4744,8 +4795,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
&(png_ptr->trans_color));
else
png_do_expand(row_info, png_ptr->row_buf + 1,
NULL);
png_do_expand(row_info, png_ptr->row_buf + 1, NULL);
}
}
#endif
@ -4837,7 +4887,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) @@ -4837,7 +4887,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
/* Because PNG_COMPOSE does the gamma transform if there is something to
* do (if there is an alpha channel or transparency.)
*/
!((png_ptr->transformations & PNG_COMPOSE) &&
!((png_ptr->transformations & PNG_COMPOSE) != 0 &&
((png_ptr->num_trans != 0) ||
(png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)) &&
#endif
@ -4969,7 +5019,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info) @@ -4969,7 +5019,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
(png_ptr, /* png_ptr */
row_info, /* row_info: */
/* png_uint_32 width; width of row */
/* png_size_t rowbytes; number of bytes in row */
/* size_t rowbytes; number of bytes in row */
/* png_byte color_type; color type of pixels */
/* png_byte bit_depth; bit depth of samples */
/* png_byte channels; number of channels (1-4) */

507
png/pngrutil.c

File diff suppressed because it is too large Load Diff

279
png/pngset.c

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
/* pngset.c - storage of image information into info struct
*
* Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* Copyright (c) 2018 Cosmin Truta
* Copyright (c) 1998-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -123,17 +123,64 @@ png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X, @@ -123,17 +123,64 @@ png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X,
png_fixed(png_ptr, red_X, "cHRM Red X"),
png_fixed(png_ptr, red_Y, "cHRM Red Y"),
png_fixed(png_ptr, red_Z, "cHRM Red Z"),
png_fixed(png_ptr, green_X, "cHRM Red X"),
png_fixed(png_ptr, green_Y, "cHRM Red Y"),
png_fixed(png_ptr, green_Z, "cHRM Red Z"),
png_fixed(png_ptr, blue_X, "cHRM Red X"),
png_fixed(png_ptr, blue_Y, "cHRM Red Y"),
png_fixed(png_ptr, blue_Z, "cHRM Red Z"));
png_fixed(png_ptr, green_X, "cHRM Green X"),
png_fixed(png_ptr, green_Y, "cHRM Green Y"),
png_fixed(png_ptr, green_Z, "cHRM Green Z"),
png_fixed(png_ptr, blue_X, "cHRM Blue X"),
png_fixed(png_ptr, blue_Y, "cHRM Blue Y"),
png_fixed(png_ptr, blue_Z, "cHRM Blue Z"));
}
# endif /* FLOATING_POINT */
#endif /* cHRM */
#ifdef PNG_eXIf_SUPPORTED
void PNGAPI
png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr,
png_bytep eXIf_buf)
{
png_warning(png_ptr, "png_set_eXIf does not work; use png_set_eXIf_1");
PNG_UNUSED(info_ptr)
PNG_UNUSED(eXIf_buf)
}
void PNGAPI
png_set_eXIf_1(png_const_structrp png_ptr, png_inforp info_ptr,
png_uint_32 num_exif, png_bytep eXIf_buf)
{
int i;
png_debug1(1, "in %s storage function", "eXIf");
if (png_ptr == NULL || info_ptr == NULL)
return;
if (info_ptr->exif)
{
png_free(png_ptr, info_ptr->exif);
info_ptr->exif = NULL;
}
info_ptr->num_exif = num_exif;
info_ptr->exif = png_voidcast(png_bytep, png_malloc_warn(png_ptr,
info_ptr->num_exif));
if (info_ptr->exif == NULL)
{
png_warning(png_ptr, "Insufficient memory for eXIf chunk data");
return;
}
info_ptr->free_me |= PNG_FREE_EXIF;
for (i = 0; i < (int) info_ptr->num_exif; i++)
info_ptr->exif[i] = eXIf_buf[i];
info_ptr->valid |= PNG_INFO_eXIf;
}
#endif /* eXIf */
#ifdef PNG_gAMA_SUPPORTED
void PNGFAPI
png_set_gAMA_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
@ -190,6 +237,7 @@ png_set_hIST(png_const_structrp png_ptr, png_inforp info_ptr, @@ -190,6 +237,7 @@ png_set_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
if (info_ptr->hist == NULL)
{
png_warning(png_ptr, "Insufficient memory for hIST chunk data");
return;
}
@ -265,7 +313,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, @@ -265,7 +313,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type,
int nparams, png_const_charp units, png_charpp params)
{
png_size_t length;
size_t length;
int i;
png_debug1(1, "in %s storage function", "pCAL");
@ -282,17 +330,29 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, @@ -282,17 +330,29 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
/* Check that the type matches the specification. */
if (type < 0 || type > 3)
png_error(png_ptr, "Invalid pCAL equation type");
{
png_chunk_report(png_ptr, "Invalid pCAL equation type",
PNG_CHUNK_WRITE_ERROR);
return;
}
if (nparams < 0 || nparams > 255)
png_error(png_ptr, "Invalid pCAL parameter count");
{
png_chunk_report(png_ptr, "Invalid pCAL parameter count",
PNG_CHUNK_WRITE_ERROR);
return;
}
/* Validate params[nparams] */
for (i=0; i<nparams; ++i)
{
if (params[i] == NULL ||
!png_check_fp_string(params[i], strlen(params[i])))
png_error(png_ptr, "Invalid format for pCAL parameter");
{
png_chunk_report(png_ptr, "Invalid format for pCAL parameter",
PNG_CHUNK_WRITE_ERROR);
return;
}
}
info_ptr->pcal_purpose = png_voidcast(png_charp,
@ -300,7 +360,8 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, @@ -300,7 +360,8 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
if (info_ptr->pcal_purpose == NULL)
{
png_warning(png_ptr, "Insufficient memory for pCAL purpose");
png_chunk_report(png_ptr, "Insufficient memory for pCAL purpose",
PNG_CHUNK_WRITE_ERROR);
return;
}
@ -322,21 +383,24 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, @@ -322,21 +383,24 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
if (info_ptr->pcal_units == NULL)
{
png_warning(png_ptr, "Insufficient memory for pCAL units");
return;
}
memcpy(info_ptr->pcal_units, units, length);
info_ptr->pcal_params = png_voidcast(png_charpp, png_malloc_warn(png_ptr,
(png_size_t)((nparams + 1) * (sizeof (png_charp)))));
(size_t)(((unsigned int)nparams + 1) * (sizeof (png_charp)))));
if (info_ptr->pcal_params == NULL)
{
png_warning(png_ptr, "Insufficient memory for pCAL params");
return;
}
memset(info_ptr->pcal_params, 0, (nparams + 1) * (sizeof (png_charp)));
memset(info_ptr->pcal_params, 0, ((unsigned int)nparams + 1) *
(sizeof (png_charp)));
for (i = 0; i < nparams; i++)
{
@ -349,6 +413,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr, @@ -349,6 +413,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
if (info_ptr->pcal_params[i] == NULL)
{
png_warning(png_ptr, "Insufficient memory for pCAL parameter");
return;
}
@ -365,7 +430,7 @@ void PNGAPI @@ -365,7 +430,7 @@ void PNGAPI
png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
int unit, png_const_charp swidth, png_const_charp sheight)
{
png_size_t lengthw = 0, lengthh = 0;
size_t lengthw = 0, lengthh = 0;
png_debug1(1, "in %s storage function", "sCAL");
@ -398,6 +463,7 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr, @@ -398,6 +463,7 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
if (info_ptr->scal_s_width == NULL)
{
png_warning(png_ptr, "Memory allocation failed while processing sCAL");
return;
}
@ -416,6 +482,7 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr, @@ -416,6 +482,7 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
info_ptr->scal_s_width = NULL;
png_warning(png_ptr, "Memory allocation failed while processing sCAL");
return;
}
@ -506,12 +573,17 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr, @@ -506,12 +573,17 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
png_const_colorp palette, int num_palette)
{
png_uint_32 max_palette_length;
png_debug1(1, "in %s storage function", "PLTE");
if (png_ptr == NULL || info_ptr == NULL)
return;
if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH)
max_palette_length = (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ?
(1 << info_ptr->bit_depth) : PNG_MAX_PALETTE_LENGTH;
if (num_palette < 0 || num_palette > (int) max_palette_length)
{
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
png_error(png_ptr, "Invalid palette length");
@ -519,6 +591,7 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr, @@ -519,6 +591,7 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
else
{
png_warning(png_ptr, "Invalid palette length");
return;
}
}
@ -531,7 +604,6 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr, @@ -531,7 +604,6 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
))
{
png_error(png_ptr, "Invalid palette");
return;
}
/* It may not actually be necessary to set png_ptr->palette here;
@ -544,14 +616,15 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr, @@ -544,14 +616,15 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
png_free_data(png_ptr, info_ptr, PNG_FREE_PLTE, 0);
/* Changed in libpng-1.2.1 to allocate PNG_MAX_PALETTE_LENGTH instead
* of num_palette entries, in case of an invalid PNG file that has
* too-large sample values.
* of num_palette entries, in case of an invalid PNG file or incorrect
* call to png_set_PLTE() with too-large sample values.
*/
png_ptr->palette = png_voidcast(png_colorp, png_calloc(png_ptr,
PNG_MAX_PALETTE_LENGTH * (sizeof (png_color))));
if (num_palette > 0)
memcpy(png_ptr->palette, palette, num_palette * (sizeof (png_color)));
memcpy(png_ptr->palette, palette, (unsigned int)num_palette *
(sizeof (png_color)));
info_ptr->palette = png_ptr->palette;
info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
@ -618,7 +691,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, @@ -618,7 +691,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
{
png_charp new_iccp_name;
png_bytep new_iccp_profile;
png_size_t length;
size_t length;
png_debug1(1, "in %s storage function", "iCCP");
@ -655,6 +728,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, @@ -655,6 +728,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
if (new_iccp_name == NULL)
{
png_benign_error(png_ptr, "Insufficient memory to process iCCP chunk");
return;
}
@ -665,9 +739,9 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr, @@ -665,9 +739,9 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
if (new_iccp_profile == NULL)
{
png_free(png_ptr, new_iccp_name);
new_iccp_name = NULL;
png_benign_error(png_ptr,
"Insufficient memory to process iCCP profile");
return;
}
@ -701,7 +775,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr, @@ -701,7 +775,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
{
int i;
png_debug1(1, "in %lx storage function", png_ptr == NULL ? "unexpected" :
png_debug1(1, "in %lx storage function", png_ptr == NULL ? 0xabadca11U :
(unsigned long)png_ptr->chunk_name);
if (png_ptr == NULL || info_ptr == NULL || num_text <= 0 || text_ptr == NULL)
@ -743,6 +817,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr, @@ -743,6 +817,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
{
png_chunk_report(png_ptr, "too many text chunks",
PNG_CHUNK_WRITE_ERROR);
return 1;
}
@ -798,7 +873,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr, @@ -798,7 +873,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
else
lang_key_len = 0;
}
# else /* PNG_iTXt_SUPPORTED */
# else /* iTXt */
{
png_chunk_report(png_ptr, "iTXt chunk not supported",
PNG_CHUNK_WRITE_ERROR);
@ -831,6 +906,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr, @@ -831,6 +906,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
{
png_chunk_report(png_ptr, "text chunk: out of memory",
PNG_CHUNK_WRITE_ERROR);
return 1;
}
@ -904,6 +980,7 @@ png_set_tIME(png_const_structrp png_ptr, png_inforp info_ptr, @@ -904,6 +980,7 @@ png_set_tIME(png_const_structrp png_ptr, png_inforp info_ptr,
mod_time->second > 60)
{
png_warning(png_ptr, "Ignoring invalid time value");
return;
}
@ -920,6 +997,7 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr, @@ -920,6 +997,7 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
png_debug1(1, "in %s storage function", "tRNS");
if (png_ptr == NULL || info_ptr == NULL)
return;
if (trans_alpha != NULL)
@ -935,17 +1013,22 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr, @@ -935,17 +1013,22 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH)
{
/* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */
png_ptr->trans_alpha = info_ptr->trans_alpha = png_voidcast(png_bytep,
info_ptr->trans_alpha = png_voidcast(png_bytep,
png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH));
if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH)
memcpy(info_ptr->trans_alpha, trans_alpha, (png_size_t)num_trans);
memcpy(info_ptr->trans_alpha, trans_alpha, (size_t)num_trans);
}
png_ptr->trans_alpha = info_ptr->trans_alpha;
}
if (trans_color != NULL)
{
int sample_max = (1 << info_ptr->bit_depth);
#ifdef PNG_WARNINGS_SUPPORTED
if (info_ptr->bit_depth < 16)
{
int sample_max = (1 << info_ptr->bit_depth) - 1;
if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
trans_color->gray > sample_max) ||
@ -955,6 +1038,8 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr, @@ -955,6 +1038,8 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
trans_color->blue > sample_max)))
png_warning(png_ptr,
"tRNS chunk has out-of-range samples for bit_depth");
}
#endif
info_ptr->trans_color = *trans_color;
@ -1001,6 +1086,7 @@ png_set_sPLT(png_const_structrp png_ptr, @@ -1001,6 +1086,7 @@ png_set_sPLT(png_const_structrp png_ptr,
{
/* Out of memory or too many chunks */
png_chunk_report(png_ptr, "too many sPLT chunks", PNG_CHUNK_WRITE_ERROR);
return;
}
@ -1012,7 +1098,7 @@ png_set_sPLT(png_const_structrp png_ptr, @@ -1012,7 +1098,7 @@ png_set_sPLT(png_const_structrp png_ptr,
do
{
png_size_t length;
size_t length;
/* Skip invalid input entries */
if (entries->name == NULL || entries->entries == NULL)
@ -1055,7 +1141,7 @@ png_set_sPLT(png_const_structrp png_ptr, @@ -1055,7 +1141,7 @@ png_set_sPLT(png_const_structrp png_ptr,
* checked it when doing the allocation.
*/
memcpy(np->entries, entries->entries,
entries->nentries * sizeof (png_sPLT_entry));
(unsigned int)entries->nentries * sizeof (png_sPLT_entry));
/* Note that 'continue' skips the advance of the out pointer and out
* count, so an invalid entry is not added.
@ -1063,8 +1149,9 @@ png_set_sPLT(png_const_structrp png_ptr, @@ -1063,8 +1149,9 @@ png_set_sPLT(png_const_structrp png_ptr,
info_ptr->valid |= PNG_INFO_sPLT;
++(info_ptr->splt_palettes_num);
++np;
++entries;
}
while (++entries, --nentries);
while (--nentries);
if (nentries > 0)
png_chunk_report(png_ptr, "sPLT out of memory", PNG_CHUNK_WRITE_ERROR);
@ -1130,6 +1217,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr, @@ -1130,6 +1217,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
{
png_app_error(png_ptr, "no unknown chunk support on read");
return;
}
# endif
@ -1138,6 +1226,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr, @@ -1138,6 +1226,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
{
png_app_error(png_ptr, "no unknown chunk support on write");
return;
}
# endif
@ -1155,6 +1244,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr, @@ -1155,6 +1244,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
{
png_chunk_report(png_ptr, "too many unknown chunks",
PNG_CHUNK_WRITE_ERROR);
return;
}
@ -1221,7 +1311,7 @@ png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr, @@ -1221,7 +1311,7 @@ png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr,
{
png_app_error(png_ptr, "invalid unknown chunk location");
/* Fake out the pre 1.6.0 behavior: */
if ((location & PNG_HAVE_IDAT) != 0) /* undocumented! */
if (((unsigned int)location & PNG_HAVE_IDAT) != 0) /* undocumented! */
location = PNG_AFTER_IDAT;
else
@ -1232,8 +1322,7 @@ png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr, @@ -1232,8 +1322,7 @@ png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr,
check_location(png_ptr, location);
}
}
#endif
#endif /* STORE_UNKNOWN_CHUNKS */
#ifdef PNG_MNG_FEATURES_SUPPORTED
png_uint_32 PNGAPI
@ -1264,6 +1353,7 @@ add_one_chunk(png_bytep list, unsigned int count, png_const_bytep add, int keep) @@ -1264,6 +1353,7 @@ add_one_chunk(png_bytep list, unsigned int count, png_const_bytep add, int keep)
if (memcmp(list, add, 4) == 0)
{
list[4] = (png_byte)keep;
return count;
}
}
@ -1291,6 +1381,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep, @@ -1291,6 +1381,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
if (keep < 0 || keep >= PNG_HANDLE_CHUNK_LAST)
{
png_app_error(png_ptr, "png_set_keep_unknown_chunks: invalid keep");
return;
}
@ -1308,9 +1399,10 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep, @@ -1308,9 +1399,10 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
/* Ignore all unknown chunks and all chunks recognized by
* libpng except for IHDR, PLTE, tRNS, IDAT, and IEND
*/
static PNG_CONST png_byte chunks_to_ignore[] = {
static const png_byte chunks_to_ignore[] = {
98, 75, 71, 68, '\0', /* bKGD */
99, 72, 82, 77, '\0', /* cHRM */
101, 88, 73, 102, '\0', /* eXIf */
103, 65, 77, 65, '\0', /* gAMA */
104, 73, 83, 84, '\0', /* hIST */
105, 67, 67, 80, '\0', /* iCCP */
@ -1340,10 +1432,11 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep, @@ -1340,10 +1432,11 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
* which can be switched off.
*/
png_app_error(png_ptr, "png_set_keep_unknown_chunks: no chunk list");
return;
}
num_chunks = num_chunks_in;
num_chunks = (unsigned int)num_chunks_in;
}
old_num_chunks = png_ptr->num_chunk_list;
@ -1355,6 +1448,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep, @@ -1355,6 +1448,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
if (num_chunks + old_num_chunks > UINT_MAX/5)
{
png_app_error(png_ptr, "png_set_keep_unknown_chunks: too many chunks");
return;
}
@ -1469,7 +1563,7 @@ png_set_rows(png_const_structrp png_ptr, png_inforp info_ptr, @@ -1469,7 +1563,7 @@ png_set_rows(png_const_structrp png_ptr, png_inforp info_ptr,
#endif
void PNGAPI
png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size)
png_set_compression_buffer_size(png_structrp png_ptr, size_t size)
{
if (png_ptr == NULL)
return;
@ -1492,23 +1586,30 @@ png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size) @@ -1492,23 +1586,30 @@ png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size)
{
png_warning(png_ptr,
"Compression buffer size cannot be changed because it is in use");
return;
}
#ifndef __COVERITY__
/* Some compilers complain that this is always false. However, it
* can be true when integer overflow happens.
*/
if (size > ZLIB_IO_MAX)
{
png_warning(png_ptr,
"Compression buffer size limited to system maximum");
size = ZLIB_IO_MAX; /* must fit */
}
#endif
else if (size < 6)
if (size < 6)
{
/* Deflate will potentially go into an infinite loop on a SYNC_FLUSH
* if this is permitted.
*/
png_warning(png_ptr,
"Compression buffer size cannot be reduced below 6");
return;
}
@ -1525,7 +1626,7 @@ void PNGAPI @@ -1525,7 +1626,7 @@ void PNGAPI
png_set_invalid(png_const_structrp png_ptr, png_inforp info_ptr, int mask)
{
if (png_ptr != NULL && info_ptr != NULL)
info_ptr->valid &= ~mask;
info_ptr->valid &= (unsigned int)(~mask);
}
@ -1537,7 +1638,7 @@ png_set_user_limits (png_structrp png_ptr, png_uint_32 user_width_max, @@ -1537,7 +1638,7 @@ png_set_user_limits (png_structrp png_ptr, png_uint_32 user_width_max,
{
/* Images with dimensions larger than these limits will be
* rejected by png_set_IHDR(). To accept any PNG datastream
* regardless of dimensions, set both limits to 0x7ffffffL.
* regardless of dimensions, set both limits to 0x7fffffff.
*/
if (png_ptr == NULL)
return;
@ -1608,4 +1709,94 @@ png_set_check_for_invalid_index(png_structrp png_ptr, int allowed) @@ -1608,4 +1709,94 @@ png_set_check_for_invalid_index(png_structrp png_ptr, int allowed)
png_ptr->num_palette_max = -1;
}
#endif
#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_pCAL_SUPPORTED) || \
defined(PNG_iCCP_SUPPORTED) || defined(PNG_sPLT_SUPPORTED)
/* Check that the tEXt or zTXt keyword is valid per PNG 1.0 specification,
* and if invalid, correct the keyword rather than discarding the entire
* chunk. The PNG 1.0 specification requires keywords 1-79 characters in
* length, forbids leading or trailing whitespace, multiple internal spaces,
* and the non-break space (0x80) from ISO 8859-1. Returns keyword length.
*
* The 'new_key' buffer must be 80 characters in size (for the keyword plus a
* trailing '\0'). If this routine returns 0 then there was no keyword, or a
* valid one could not be generated, and the caller must png_error.
*/
png_uint_32 /* PRIVATE */
png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
{
#ifdef PNG_WARNINGS_SUPPORTED
png_const_charp orig_key = key;
#endif
png_uint_32 key_len = 0;
int bad_character = 0;
int space = 1;
png_debug(1, "in png_check_keyword");
if (key == NULL)
{
*new_key = 0;
return 0;
}
while (*key && key_len < 79)
{
png_byte ch = (png_byte)*key++;
if ((ch > 32 && ch <= 126) || (ch >= 161 /*&& ch <= 255*/))
{
*new_key++ = ch; ++key_len; space = 0;
}
else if (space == 0)
{
/* A space or an invalid character when one wasn't seen immediately
* before; output just a space.
*/
*new_key++ = 32; ++key_len; space = 1;
/* If the character was not a space then it is invalid. */
if (ch != 32)
bad_character = ch;
}
else if (bad_character == 0)
bad_character = ch; /* just skip it, record the first error */
}
if (key_len > 0 && space != 0) /* trailing space */
{
--key_len; --new_key;
if (bad_character == 0)
bad_character = 32;
}
/* Terminate the keyword */
*new_key = 0;
if (key_len == 0)
return 0;
#ifdef PNG_WARNINGS_SUPPORTED
/* Try to only output one warning per keyword: */
if (*key != 0) /* keyword too long */
png_warning(png_ptr, "keyword truncated");
else if (bad_character != 0)
{
PNG_WARNING_PARAMETERS(p)
png_warning_parameter(p, 1, orig_key);
png_warning_parameter_signed(p, 2, PNG_NUMBER_FORMAT_02x, bad_character);
png_formatted_warning(png_ptr, p, "keyword \"@1\": bad character '0x@2'");
}
#else /* !WARNINGS */
PNG_UNUSED(png_ptr)
#endif /* !WARNINGS */
return key_len;
}
#endif /* TEXT || pCAL || iCCP || sPLT */
#endif /* READ || WRITE */

70
png/pngstruct.h

@ -1,11 +1,10 @@ @@ -1,11 +1,10 @@
/* pngstruct.h - header file for PNG reference library
*
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
*
* Last changed in libpng 1.6.1 [March 28, 2013]
* Copyright (c) 2018-2019 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.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -48,7 +47,7 @@ @@ -48,7 +47,7 @@
/* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib
* can handle at once. This type need be no larger than 16 bits (so maximum of
* 65535), this define allows us to discover how big it is, but limited by the
* maximuum for png_size_t. The value can be overriden in a library build
* maximum for size_t. The value can be overridden in a library build
* (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably
* lower value (e.g. 255 works). A lower value may help memory usage (slightly)
* and may even improve performance on some systems (and degrade it on others.)
@ -101,7 +100,7 @@ typedef struct png_XYZ @@ -101,7 +100,7 @@ typedef struct png_XYZ
#endif /* COLORSPACE */
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
/* A colorspace is all the above plus, potentially, profile information,
/* 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.
@ -215,23 +214,25 @@ struct png_struct_def @@ -215,23 +214,25 @@ struct png_struct_def
png_uint_32 height; /* height of image in pixels */
png_uint_32 num_rows; /* number of rows in current pass */
png_uint_32 usr_width; /* width of row at start of write */
png_size_t rowbytes; /* size of row in bytes */
size_t rowbytes; /* size of row in bytes */
png_uint_32 iwidth; /* width of current interlaced row in pixels */
png_uint_32 row_number; /* current row in interlace pass */
png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */
png_bytep prev_row; /* buffer to save previous (unfiltered) row.
* This is a pointer into big_prev_row
* While reading this is a pointer into
* big_prev_row; while writing it is separately
* allocated if needed.
*/
png_bytep row_buf; /* buffer to save current (unfiltered) row.
* This is a pointer into big_row_buf
* While reading, this is a pointer into
* big_row_buf; while writing it is separately
* allocated.
*/
#ifdef PNG_WRITE_SUPPORTED
png_bytep sub_row; /* buffer to save "sub" row when filtering */
png_bytep up_row; /* buffer to save "up" row when filtering */
png_bytep avg_row; /* buffer to save "avg" row when filtering */
png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
#ifdef PNG_WRITE_FILTER_SUPPORTED
png_bytep try_row; /* buffer to save trial row when filtering */
png_bytep tst_row; /* buffer to save best trial row when filtering */
#endif
png_size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */
size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */
png_uint_32 idat_size; /* current IDAT size for read */
png_uint_32 crc; /* current chunk CRC value */
@ -248,7 +249,7 @@ struct png_struct_def @@ -248,7 +249,7 @@ struct png_struct_def
png_byte filter; /* file filter type (always 0) */
png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
png_byte pass; /* current interlace pass (0 - 6) */
png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */
png_byte do_filter; /* row filter flags (see PNG_FILTER_ in png.h ) */
png_byte color_type; /* color type of file */
png_byte bit_depth; /* bit depth of file */
png_byte usr_bit_depth; /* bit depth of users row: write only */
@ -262,6 +263,9 @@ struct png_struct_def @@ -262,6 +263,9 @@ struct png_struct_def
/* pixel depth used for the row buffers */
png_byte transformed_pixel_depth;
/* pixel depth after read/write transforms */
#if ZLIB_VERNUM >= 0x1240
png_byte zstream_start; /* at start of an input zlib stream */
#endif /* Zlib >= 1.2.4 */
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
png_uint_16 filler; /* filler bytes for pixel expansion */
#endif
@ -303,7 +307,7 @@ struct png_struct_def @@ -303,7 +307,7 @@ struct png_struct_def
#endif
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
png_color_8 shift; /* shift for significant bit tranformation */
png_color_8 shift; /* shift for significant bit transformation */
#endif
#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \
@ -324,10 +328,10 @@ struct png_struct_def @@ -324,10 +328,10 @@ struct png_struct_def
png_bytep current_buffer; /* buffer for recently used data */
png_uint_32 push_length; /* size of current input chunk */
png_uint_32 skip_length; /* bytes to skip in input data */
png_size_t save_buffer_size; /* amount of data now in save_buffer */
png_size_t save_buffer_max; /* total size of save_buffer */
png_size_t buffer_size; /* total amount of available input data */
png_size_t current_buffer_size; /* amount of data now in current_buffer */
size_t save_buffer_size; /* amount of data now in save_buffer */
size_t save_buffer_max; /* total size of save_buffer */
size_t buffer_size; /* total amount of available input data */
size_t current_buffer_size; /* amount of data now in current_buffer */
int process_mode; /* what push library is currently doing */
int cur_palette; /* current push library palette index */
@ -347,19 +351,9 @@ struct png_struct_def @@ -347,19 +351,9 @@ struct png_struct_def
png_bytep quantize_index; /* index translation for palette files */
#endif
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
png_byte heuristic_method; /* heuristic for row filter selection */
png_byte num_prev_filters; /* number of weights for previous rows */
png_bytep prev_filters; /* filter type(s) of previous row(s) */
png_uint_16p filter_weights; /* weight(s) for previous line(s) */
png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */
png_uint_16p filter_costs; /* relative filter calculation cost */
png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
#endif
/* Options */
/* Options */
#ifdef PNG_SET_OPTION_SUPPORTED
png_byte options; /* On/off state (up to 4 options) */
png_uint_32 options; /* On/off state (up to 16 options) */
#endif
#if PNG_LIBPNG_VER < 10700
@ -398,6 +392,12 @@ struct png_struct_def @@ -398,6 +392,12 @@ struct png_struct_def
/* deleted in 1.5.5: rgb_to_gray_blue_coeff; */
#endif
/* New member added in libpng-1.6.36 */
#if defined(PNG_READ_EXPAND_SUPPORTED) && \
defined(PNG_ARM_NEON_IMPLEMENTATION)
png_bytep riffled_palette; /* buffer for accelerated palette expansion */
#endif
/* New member added in libpng-1.0.4 (renamed in 1.0.9) */
#if defined(PNG_MNG_FEATURES_SUPPORTED)
/* Changed from png_byte to png_uint_32 at version 1.2.0 */
@ -457,7 +457,7 @@ struct png_struct_def @@ -457,7 +457,7 @@ struct png_struct_def
#endif
/* New member added in libpng-1.2.26 */
png_size_t old_big_row_buf_size;
size_t old_big_row_buf_size;
#ifdef PNG_READ_SUPPORTED
/* New member added in libpng-1.2.30 */

75
png/pngtrans.c

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
*
* Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* Copyright (c) 2018 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.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -30,7 +30,7 @@ png_set_bgr(png_structrp png_ptr) @@ -30,7 +30,7 @@ png_set_bgr(png_structrp png_ptr)
#endif
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
/* Turn on 16 bit byte swapping */
/* Turn on 16-bit byte swapping */
void PNGAPI
png_set_swap(png_structrp png_ptr)
{
@ -172,7 +172,8 @@ png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc) @@ -172,7 +172,8 @@ png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
* size!
*/
png_app_error(png_ptr,
"png_set_filler is invalid for low bit depth gray output");
"png_set_filler is invalid for"
" low bit depth gray output");
return;
}
@ -268,8 +269,8 @@ png_do_invert(png_row_infop row_info, png_bytep row) @@ -268,8 +269,8 @@ png_do_invert(png_row_infop row_info, png_bytep row)
if (row_info->color_type == PNG_COLOR_TYPE_GRAY)
{
png_bytep rp = row;
png_size_t i;
png_size_t istop = row_info->rowbytes;
size_t i;
size_t istop = row_info->rowbytes;
for (i = 0; i < istop; i++)
{
@ -282,8 +283,8 @@ png_do_invert(png_row_infop row_info, png_bytep row) @@ -282,8 +283,8 @@ png_do_invert(png_row_infop row_info, png_bytep row)
row_info->bit_depth == 8)
{
png_bytep rp = row;
png_size_t i;
png_size_t istop = row_info->rowbytes;
size_t i;
size_t istop = row_info->rowbytes;
for (i = 0; i < istop; i += 2)
{
@ -297,8 +298,8 @@ png_do_invert(png_row_infop row_info, png_bytep row) @@ -297,8 +298,8 @@ png_do_invert(png_row_infop row_info, png_bytep row)
row_info->bit_depth == 16)
{
png_bytep rp = row;
png_size_t i;
png_size_t istop = row_info->rowbytes;
size_t i;
size_t istop = row_info->rowbytes;
for (i = 0; i < istop; i += 4)
{
@ -313,7 +314,7 @@ png_do_invert(png_row_infop row_info, png_bytep row) @@ -313,7 +314,7 @@ png_do_invert(png_row_infop row_info, png_bytep row)
#ifdef PNG_16BIT_SUPPORTED
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
/* Swaps byte order on 16 bit depth images */
/* Swaps byte order on 16-bit depth images */
void /* PRIVATE */
png_do_swap(png_row_infop row_info, png_bytep row)
{
@ -344,7 +345,7 @@ png_do_swap(png_row_infop row_info, png_bytep row) @@ -344,7 +345,7 @@ png_do_swap(png_row_infop row_info, png_bytep row)
#endif
#if defined(PNG_READ_PACKSWAP_SUPPORTED)||defined(PNG_WRITE_PACKSWAP_SUPPORTED)
static PNG_CONST png_byte onebppswaptable[256] = {
static const png_byte onebppswaptable[256] = {
0x00, 0x80, 0x40, 0xC0, 0x20, 0xA0, 0x60, 0xE0,
0x10, 0x90, 0x50, 0xD0, 0x30, 0xB0, 0x70, 0xF0,
0x08, 0x88, 0x48, 0xC8, 0x28, 0xA8, 0x68, 0xE8,
@ -379,7 +380,7 @@ static PNG_CONST png_byte onebppswaptable[256] = { @@ -379,7 +380,7 @@ static PNG_CONST png_byte onebppswaptable[256] = {
0x1F, 0x9F, 0x5F, 0xDF, 0x3F, 0xBF, 0x7F, 0xFF
};
static PNG_CONST png_byte twobppswaptable[256] = {
static const png_byte twobppswaptable[256] = {
0x00, 0x40, 0x80, 0xC0, 0x10, 0x50, 0x90, 0xD0,
0x20, 0x60, 0xA0, 0xE0, 0x30, 0x70, 0xB0, 0xF0,
0x04, 0x44, 0x84, 0xC4, 0x14, 0x54, 0x94, 0xD4,
@ -414,7 +415,7 @@ static PNG_CONST png_byte twobppswaptable[256] = { @@ -414,7 +415,7 @@ static PNG_CONST png_byte twobppswaptable[256] = {
0x2F, 0x6F, 0xAF, 0xEF, 0x3F, 0x7F, 0xBF, 0xFF
};
static PNG_CONST png_byte fourbppswaptable[256] = {
static const png_byte fourbppswaptable[256] = {
0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,
0x80, 0x90, 0xA0, 0xB0, 0xC0, 0xD0, 0xE0, 0xF0,
0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71,
@ -513,11 +514,15 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start) @@ -513,11 +514,15 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
if (at_start != 0) /* Skip initial filler */
++sp;
else /* Skip initial channel and, for sp, the filler */
sp += 2, ++dp;
{
sp += 2; ++dp;
}
/* For a 1 pixel wide image there is nothing to do */
while (sp < ep)
*dp++ = *sp, sp += 2;
{
*dp++ = *sp; sp += 2;
}
row_info->pixel_depth = 8;
}
@ -527,10 +532,14 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start) @@ -527,10 +532,14 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
if (at_start != 0) /* Skip initial filler */
sp += 2;
else /* Skip initial channel and, for sp, the filler */
sp += 4, dp += 2;
{
sp += 4; dp += 2;
}
while (sp < ep)
*dp++ = *sp++, *dp++ = *sp, sp += 3;
{
*dp++ = *sp++; *dp++ = *sp; sp += 3;
}
row_info->pixel_depth = 16;
}
@ -553,11 +562,15 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start) @@ -553,11 +562,15 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
if (at_start != 0) /* Skip initial filler */
++sp;
else /* Skip initial channels and, for sp, the filler */
sp += 4, dp += 3;
{
sp += 4; dp += 3;
}
/* Note that the loop adds 3 to dp and 4 to sp each time. */
while (sp < ep)
*dp++ = *sp++, *dp++ = *sp++, *dp++ = *sp, sp += 2;
{
*dp++ = *sp++; *dp++ = *sp++; *dp++ = *sp; sp += 2;
}
row_info->pixel_depth = 24;
}
@ -567,14 +580,16 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start) @@ -567,14 +580,16 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
if (at_start != 0) /* Skip initial filler */
sp += 2;
else /* Skip initial channels and, for sp, the filler */
sp += 8, dp += 6;
{
sp += 8; dp += 6;
}
while (sp < ep)
{
/* Copy 6 bytes, skip 2 */
*dp++ = *sp++, *dp++ = *sp++;
*dp++ = *sp++, *dp++ = *sp++;
*dp++ = *sp++, *dp++ = *sp, sp += 3;
*dp++ = *sp++; *dp++ = *sp++;
*dp++ = *sp++; *dp++ = *sp++;
*dp++ = *sp++; *dp++ = *sp; sp += 3;
}
row_info->pixel_depth = 48;
@ -594,7 +609,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start) @@ -594,7 +609,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
return; /* The filler channel has gone already */
/* Fix the rowbytes value. */
row_info->rowbytes = dp-row;
row_info->rowbytes = (size_t)(dp-row);
}
#endif
@ -692,8 +707,8 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info) @@ -692,8 +707,8 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
* and this calculation is used because it avoids warnings that other
* forms produced on either GCC or MSVC.
*/
int padding = (-row_info->pixel_depth * row_info->width) & 7;
png_bytep rp = png_ptr->row_buf + row_info->rowbytes;
int padding = PNG_PADBITS(row_info->pixel_depth, row_info->width);
png_bytep rp = png_ptr->row_buf + row_info->rowbytes - 1;
switch (row_info->bit_depth)
{
@ -704,7 +719,7 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info) @@ -704,7 +719,7 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
*/
for (; rp > png_ptr->row_buf; rp--)
{
if (*rp >> padding != 0)
if ((*rp >> padding) != 0)
png_ptr->num_palette_max = 1;
padding = 0;
}

16
png/pngwio.c

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
/* pngwio.c - functions for data output
*
* Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* Copyright (c) 2018 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.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -26,11 +26,11 @@ @@ -26,11 +26,11 @@
* writes to a file pointer. Note that this routine sometimes gets called
* with very small lengths, so you should implement some kind of simple
* buffering if you are using unbuffered writes. This should never be asked
* to write more than 64K on a 16 bit machine.
* to write more than 64K on a 16-bit machine.
*/
void /* PRIVATE */
png_write_data(png_structrp png_ptr, png_const_bytep data, png_size_t length)
png_write_data(png_structrp png_ptr, png_const_bytep data, size_t length)
{
/* NOTE: write_data_fn must not change the buffer! */
if (png_ptr->write_data_fn != NULL )
@ -48,9 +48,9 @@ png_write_data(png_structrp png_ptr, png_const_bytep data, png_size_t length) @@ -48,9 +48,9 @@ png_write_data(png_structrp png_ptr, png_const_bytep data, png_size_t length)
* than changing the library.
*/
void PNGCBAPI
png_default_write_data(png_structp png_ptr, png_bytep data, png_size_t length)
png_default_write_data(png_structp png_ptr, png_bytep data, size_t length)
{
png_size_t check;
size_t check;
if (png_ptr == NULL)
return;

674
png/pngwrite.c

File diff suppressed because it is too large Load Diff

33
png/pngwtran.c

@ -1,10 +1,10 @@ @@ -1,10 +1,10 @@
/* pngwtran.c - transforms the data in a row for PNG writers
*
* Last changed in libpng 1.6.15 [November 20, 2014]
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
* Copyright (c) 2018 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.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -71,7 +71,8 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) @@ -71,7 +71,8 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
case 2:
{
png_bytep sp, dp;
int shift, v;
unsigned int shift;
int v;
png_uint_32 i;
png_uint_32 row_width = row_info->width;
@ -110,7 +111,8 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth) @@ -110,7 +111,8 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
case 4:
{
png_bytep sp, dp;
int shift, v;
unsigned int shift;
int v;
png_uint_32 i;
png_uint_32 row_width = row_info->width;
@ -175,7 +177,7 @@ png_do_shift(png_row_infop row_info, png_bytep row, @@ -175,7 +177,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
if (row_info->color_type != PNG_COLOR_TYPE_PALETTE)
{
int shift_start[4], shift_dec[4];
int channels = 0;
unsigned int channels = 0;
if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
{
@ -210,9 +212,9 @@ png_do_shift(png_row_infop row_info, png_bytep row, @@ -210,9 +212,9 @@ png_do_shift(png_row_infop row_info, png_bytep row,
if (row_info->bit_depth < 8)
{
png_bytep bp = row;
png_size_t i;
size_t i;
unsigned int mask;
png_size_t row_bytes = row_info->rowbytes;
size_t row_bytes = row_info->rowbytes;
if (bit_depth->gray == 1 && row_info->bit_depth == 2)
mask = 0x55;
@ -252,8 +254,7 @@ png_do_shift(png_row_infop row_info, png_bytep row, @@ -252,8 +254,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
for (i = 0; i < istop; i++, bp++)
{
const unsigned int c = i%channels;
unsigned int c = i%channels;
int j;
unsigned int v, out;
@ -281,7 +282,7 @@ png_do_shift(png_row_infop row_info, png_bytep row, @@ -281,7 +282,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
for (bp = row, i = 0; i < istop; i++)
{
const unsigned int c = i%channels;
unsigned int c = i%channels;
int j;
unsigned int value, v;
@ -422,7 +423,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) @@ -422,7 +423,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
*(dp++) = *(sp++);
*/
sp+=3; dp = sp;
*(dp++) = (png_byte)(255 - *(sp++));
*dp = (png_byte)(255 - *(sp++));
}
}
@ -446,7 +447,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) @@ -446,7 +447,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
*/
sp+=6; dp = sp;
*(dp++) = (png_byte)(255 - *(sp++));
*(dp++) = (png_byte)(255 - *(sp++));
*dp = (png_byte)(255 - *(sp++));
}
}
#endif /* WRITE_16BIT */
@ -484,7 +485,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row) @@ -484,7 +485,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
*/
sp+=2; dp = sp;
*(dp++) = (png_byte)(255 - *(sp++));
*(dp++) = (png_byte)(255 - *(sp++));
*dp = (png_byte)(255 - *(sp++));
}
}
#endif /* WRITE_16BIT */
@ -512,7 +513,7 @@ png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info) @@ -512,7 +513,7 @@ png_do_write_transformations(png_structrp png_ptr, png_row_infop row_info)
(png_ptr, /* png_ptr */
row_info, /* row_info: */
/* png_uint_32 width; width of row */
/* png_size_t rowbytes; number of bytes in row */
/* size_t rowbytes; number of bytes in row */
/* png_byte color_type; color type of pixels */
/* png_byte bit_depth; bit depth of samples */
/* png_byte channels; number of channels (1-4) */

1172
png/pngwutil.c

File diff suppressed because it is too large Load Diff

44
test/makedepend

@ -2,12 +2,27 @@ @@ -2,12 +2,27 @@
CubeMain.o: ../FL/Enumerations.H
CubeMain.o: ../FL/Fl.H
CubeMain.o: ../FL/Fl_Bitmap.H
CubeMain.o: ../FL/Fl_Box.H
CubeMain.o: ../FL/Fl_Double_Window.H
CubeMain.o: ../FL/Fl_Export.H
CubeMain.o: ../FL/Fl_Gl_Window.H
CubeMain.o: ../FL/Fl_Group.H
CubeMain.o: ../FL/Fl_Image.H
CubeMain.o: ../FL/Fl_Roller.H
CubeMain.o: ../FL/Fl_Slider.H
CubeMain.o: ../FL/Fl_Valuator.H
CubeMain.o: ../FL/Fl_Value_Slider.H
CubeMain.o: ../FL/Fl_Widget.H
CubeMain.o: ../FL/Fl_Window.H
CubeMain.o: ../FL/abi-version.h
CubeMain.o: ../FL/fl_types.h
CubeMain.o: ../FL/fl_utf8.h
CubeMain.o: ../FL/gl.h
CubeMain.o: ../FL/platform_types.h
CubeMain.o: ../config.h
CubeMain.o: CubeView.h
CubeMain.o: CubeViewUI.h
CubeView.o: ../FL/Enumerations.H
CubeView.o: ../FL/Fl.H
CubeView.o: ../FL/Fl_Bitmap.H
@ -1067,6 +1082,26 @@ input_choice.o: ../FL/fl_draw.H @@ -1067,6 +1082,26 @@ input_choice.o: ../FL/fl_draw.H
input_choice.o: ../FL/fl_types.h
input_choice.o: ../FL/fl_utf8.h
input_choice.o: ../FL/platform_types.h
keyboard.o: ../FL/Enumerations.H
keyboard.o: ../FL/Fl.H
keyboard.o: ../FL/Fl_Bitmap.H
keyboard.o: ../FL/Fl_Box.H
keyboard.o: ../FL/Fl_Button.H
keyboard.o: ../FL/Fl_Dial.H
keyboard.o: ../FL/Fl_Export.H
keyboard.o: ../FL/Fl_Group.H
keyboard.o: ../FL/Fl_Image.H
keyboard.o: ../FL/Fl_Input.H
keyboard.o: ../FL/Fl_Input_.H
keyboard.o: ../FL/Fl_Output.H
keyboard.o: ../FL/Fl_Widget.H
keyboard.o: ../FL/Fl_Window.H
keyboard.o: ../FL/abi-version.h
keyboard.o: ../FL/fl_types.h
keyboard.o: ../FL/fl_utf8.h
keyboard.o: ../FL/platform_types.h
keyboard.o: keyboard.h
keyboard.o: keyboard_ui.h
label.o: ../FL/Enumerations.H
label.o: ../FL/Fl.H
label.o: ../FL/Fl_Bitmap.H
@ -1134,18 +1169,25 @@ list_visuals.o: ../config.h @@ -1134,18 +1169,25 @@ list_visuals.o: ../config.h
mandelbrot.o: ../FL/Enumerations.H
mandelbrot.o: ../FL/Fl.H
mandelbrot.o: ../FL/Fl_Bitmap.H
mandelbrot.o: ../FL/Fl_Box.H
mandelbrot.o: ../FL/Fl_Button.H
mandelbrot.o: ../FL/Fl_Device.H
mandelbrot.o: ../FL/Fl_Double_Window.H
mandelbrot.o: ../FL/Fl_Export.H
mandelbrot.o: ../FL/Fl_Float_Input.H
mandelbrot.o: ../FL/Fl_Graphics_Driver.H
mandelbrot.o: ../FL/Fl_Group.H
mandelbrot.o: ../FL/Fl_Image.H
mandelbrot.o: ../FL/Fl_Input.H
mandelbrot.o: ../FL/Fl_Input_.H
mandelbrot.o: ../FL/Fl_Paged_Device.H
mandelbrot.o: ../FL/Fl_Pixmap.H
mandelbrot.o: ../FL/Fl_Plugin.H
mandelbrot.o: ../FL/Fl_Preferences.H
mandelbrot.o: ../FL/Fl_Printer.H
mandelbrot.o: ../FL/Fl_RGB_Image.H
mandelbrot.o: ../FL/Fl_Slider.H
mandelbrot.o: ../FL/Fl_Valuator.H
mandelbrot.o: ../FL/Fl_Widget.H
mandelbrot.o: ../FL/Fl_Widget_Surface.H
mandelbrot.o: ../FL/Fl_Window.H
@ -1154,6 +1196,8 @@ mandelbrot.o: ../FL/fl_draw.H @@ -1154,6 +1196,8 @@ mandelbrot.o: ../FL/fl_draw.H
mandelbrot.o: ../FL/fl_types.h
mandelbrot.o: ../FL/fl_utf8.h
mandelbrot.o: ../FL/platform_types.h
mandelbrot.o: mandelbrot.h
mandelbrot.o: mandelbrot_ui.h
menubar.o: ../FL/Enumerations.H
menubar.o: ../FL/Fl.H
menubar.o: ../FL/Fl_Bitmap.H

2
zlib/makedepend

@ -6,7 +6,7 @@ crc32.o: zutil.h zlib.h zconf.h crc32.h @@ -6,7 +6,7 @@ crc32.o: zutil.h zlib.h zconf.h crc32.h
uncompr.o: zlib.h zconf.h
deflate.o: deflate.h zutil.h zlib.h zconf.h
trees.o: deflate.h zutil.h zlib.h zconf.h trees.h
zutil.o: zutil.h zlib.h zconf.h
zutil.o: zutil.h zlib.h zconf.h gzguts.h
inflate.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h inffixed.h
inftrees.o: zutil.h zlib.h zconf.h inftrees.h
inffast.o: zutil.h zlib.h zconf.h inftrees.h inflate.h inffast.h

Loading…
Cancel
Save