mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-02-16 09:02:06 +00:00
Update libpng and zlib
This commit is contained in:
parent
37dd048f12
commit
165ade339b
651 changed files with 150519 additions and 47247 deletions
|
@ -1,65 +1,47 @@
|
||||||
|
libpng 1.6.37 - April 14, 2019
|
||||||
|
==============================
|
||||||
|
|
||||||
Libpng 1.2.46 - July 9, 2011
|
This is a public release of libpng, intended for use in production code.
|
||||||
|
|
||||||
This is a public release of libpng, intended for use in production codes.
|
|
||||||
|
|
||||||
Files available for download:
|
Files available for download
|
||||||
|
----------------------------
|
||||||
|
|
||||||
Source files with LF line endings (for Unix/Linux) and with a
|
Source files with LF line endings (for Unix/Linux):
|
||||||
"configure" script
|
|
||||||
|
|
||||||
libpng-1.2.46.tar.xz (LZMA-compressed, recommended)
|
* libpng-1.6.37.tar.xz (LZMA-compressed, recommended)
|
||||||
libpng-1.2.46.tar.gz
|
* libpng-1.6.37.tar.gz
|
||||||
libpng-1.2.46.tar.bz2
|
|
||||||
|
|
||||||
Source files with LF line endings (for Unix/Linux) without the
|
Source files with CRLF line endings (for Windows):
|
||||||
"configure" script
|
|
||||||
|
|
||||||
libpng-1.2.46-no-config.tar.xz (LZMA-compressed, recommended)
|
* lp1637.7z (LZMA-compressed, recommended)
|
||||||
libpng-1.2.46-no-config.tar.gz
|
* lp1637.zip
|
||||||
libpng-1.2.46-no-config.tar.bz2
|
|
||||||
|
|
||||||
Source files with CRLF line endings (for Windows), without the
|
|
||||||
"configure" script
|
|
||||||
|
|
||||||
lpng1246.zip
|
|
||||||
lpng1246.7z
|
|
||||||
lpng1246.tar.bz2
|
|
||||||
|
|
||||||
Project files
|
|
||||||
|
|
||||||
libpng-1.2.46-project-netware.zip
|
|
||||||
libpng-1.2.46-project-wince.zip
|
|
||||||
|
|
||||||
Other information:
|
Other information:
|
||||||
|
|
||||||
libpng-1.2.46-README.txt
|
* README.md
|
||||||
libpng-1.2.46-KNOWNBUGS.txt
|
* LICENSE.md
|
||||||
libpng-1.2.46-LICENSE.txt
|
* AUTHORS.md
|
||||||
libpng-1.2.46-Y2K-compliance.txt
|
* TRADEMARK.md
|
||||||
libpng-1.2.46-[previous version]-diff.txt
|
|
||||||
|
|
||||||
Changes since the last public release (1.2.43):
|
|
||||||
|
|
||||||
version 1.2.45 [July 9, 2011]
|
Changes since the previous public release (version 1.6.36)
|
||||||
|
----------------------------------------------------------
|
||||||
|
|
||||||
Fixed uninitialized memory read in png_format_buffer() (Bug
|
* Fixed a use-after-free vulnerability (CVE-2019-7317) in png_image_free.
|
||||||
report by Frank Busse, related to CVE-2004-0421).
|
* Fixed a memory leak in the ARM NEON implementation of png_do_expand_palette.
|
||||||
Pass "" instead of '\0' to png_default_error() in png_err(). This mistake
|
* Fixed a memory leak in pngtest.c.
|
||||||
was introduced in libpng-1.2.20beta01.
|
* Fixed two vulnerabilities (CVE-2018-14048, CVE-2018-14550) in
|
||||||
Check for up->location !PNG_AFTER_IDAT when writing unknown chunks
|
contrib/pngminus; refactor.
|
||||||
before IDAT.
|
* Changed the license of contrib/pngminus to MIT; refresh makefile and docs.
|
||||||
Ported bugfix in pngrtran.c from 1.5.3: when expanding a paletted image,
|
(Contributed by Willem van Schaik)
|
||||||
always expand to RGBA if transparency is present.
|
* Fixed a typo in the libpng license v2.
|
||||||
Check for integer overflow in png_set_rgb_to_gray().
|
(Contributed by Miguel Ojeda)
|
||||||
Check for sCAL chunk too short.
|
* Added makefiles for AddressSanitizer-enabled builds.
|
||||||
Added CMakeLists.txt, projects/xcode, and pnggccrd.c to EXTRA_DIST in
|
* Cleaned up various makefiles.
|
||||||
Makefile.am and Makefile.in
|
|
||||||
Udated copyright year to 2011.
|
|
||||||
|
|
||||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
|
||||||
(subscription required; visit
|
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
|
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||||
to subscribe) or to glennrp at users.sourceforge.net
|
to subscribe.
|
||||||
|
|
||||||
Glenn R-P
|
|
||||||
|
|
45
libs/libpng-src/AUTHORS
Normal file
45
libs/libpng-src/AUTHORS
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
PNG REFERENCE LIBRARY AUTHORS
|
||||||
|
=============================
|
||||||
|
|
||||||
|
This is the list of PNG Reference Library ("libpng") Contributing
|
||||||
|
Authors, for copyright and licensing purposes.
|
||||||
|
|
||||||
|
* Andreas Dilger
|
||||||
|
* Cosmin Truta
|
||||||
|
* Dave Martindale
|
||||||
|
* Eric S. Raymond
|
||||||
|
* Gilles Vollant
|
||||||
|
* Glenn Randers-Pehrson
|
||||||
|
* Greg Roelofs
|
||||||
|
* Guy Eric Schalnat
|
||||||
|
* James Yu
|
||||||
|
* John Bowler
|
||||||
|
* Kevin Bracey
|
||||||
|
* Magnus Holmgren
|
||||||
|
* Mandar Sahastrabuddhe
|
||||||
|
* Mans Rullgard
|
||||||
|
* Matt Sarett
|
||||||
|
* Mike Klein
|
||||||
|
* Paul Schmidt
|
||||||
|
* Sam Bushell
|
||||||
|
* Samuel Williams
|
||||||
|
* Simon-Pierre Cadieux
|
||||||
|
* Tim Wegner
|
||||||
|
* Tom Lane
|
||||||
|
* Tom Tanner
|
||||||
|
* Vadim Barkov
|
||||||
|
* Willem van Schaik
|
||||||
|
* Zhijie Liang
|
||||||
|
* Arm Holdings
|
||||||
|
- Richard Townsend
|
||||||
|
* Google Inc.
|
||||||
|
- Matt Sarett
|
||||||
|
- Mike Klein
|
||||||
|
|
||||||
|
The build projects, the build scripts, the test scripts, and other
|
||||||
|
files in the "projects", "scripts" and "tests" directories, have other
|
||||||
|
copyright owners, but are released under the libpng license.
|
||||||
|
|
||||||
|
Some files in the "contrib" directory, and some tools-generated files
|
||||||
|
that are distributed with libpng, have other copyright owners, and are
|
||||||
|
released under other open source licenses.
|
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,28 @@
|
||||||
|
|
||||||
Installing libpng version 1.2.46 - July 9, 2011
|
Installing libpng
|
||||||
|
|
||||||
|
Contents
|
||||||
|
|
||||||
|
I. Simple installation
|
||||||
|
II. Rebuilding the configure scripts
|
||||||
|
III. Using scripts/makefile*
|
||||||
|
IV. Using cmake
|
||||||
|
V. Directory structure
|
||||||
|
VI. Building with project files
|
||||||
|
VII. Building with makefiles
|
||||||
|
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. 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
|
||||||
|
|
||||||
On Unix/Linux and similar systems, you can simply type
|
On Unix/Linux and similar systems, you can simply type
|
||||||
|
|
||||||
|
@ -7,20 +30,44 @@ On Unix/Linux and similar systems, you can simply type
|
||||||
make check
|
make check
|
||||||
make install
|
make install
|
||||||
|
|
||||||
and ignore the rest of this document.
|
and ignore the rest of this document. "/path" is the path to the directory
|
||||||
|
where you want to install the libpng "lib", "include", and "bin"
|
||||||
|
subdirectories.
|
||||||
|
|
||||||
If configure does not work on your system and you have a reasonably
|
If you downloaded a GIT clone, you will need to run ./autogen.sh before
|
||||||
up-to-date set of tools, running ./autogen.sh before running ./configure
|
running ./configure, to create "configure" and "Makefile.in" which are
|
||||||
may fix the problem. You can also run the individual commands in
|
not included in the GIT repository.
|
||||||
autogen.sh with the --force option, if supported by your version of
|
|
||||||
the tools. If you run 'libtoolize --force', though, this will replace
|
Note that "configure" is only included in the "*.tar" distributions and not
|
||||||
the distributed, patched, version of ltmain.sh with an unpatched version
|
in the "*.zip" or "*.7z" distributions. If you downloaded one of those
|
||||||
and your shared library builds may fail to produce libraries with the
|
distributions, see "Building with project files" or "Building with makefiles",
|
||||||
correct version numbers.
|
below.
|
||||||
|
|
||||||
|
II. Rebuilding the configure scripts
|
||||||
|
|
||||||
|
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, especially if you
|
||||||
|
are building from a tar distribution instead of a git distribution,
|
||||||
|
do this:
|
||||||
|
|
||||||
|
./configure --enable-maintainer-mode
|
||||||
|
make maintainer-clean
|
||||||
|
./autogen.sh --maintainer --clean
|
||||||
|
./autogen.sh --maintainer
|
||||||
|
./configure [--prefix=/path] [other options]
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
make check
|
||||||
|
|
||||||
|
III. Using scripts/makefile*
|
||||||
|
|
||||||
Instead, you can use one of the custom-built makefiles in the
|
Instead, you can use one of the custom-built makefiles in the
|
||||||
"scripts" directory
|
"scripts" directory
|
||||||
|
|
||||||
|
cp scripts/pnglibconf.h.prebuilt pnglibconf.h
|
||||||
cp scripts/makefile.system makefile
|
cp scripts/makefile.system makefile
|
||||||
make test
|
make test
|
||||||
make install
|
make install
|
||||||
|
@ -32,82 +79,107 @@ Or you can use one of the "projects" in the "projects" directory.
|
||||||
|
|
||||||
Before installing libpng, you must first install zlib, if it
|
Before installing libpng, you must first install zlib, if it
|
||||||
is not already on your system. zlib can usually be found
|
is not already on your system. zlib can usually be found
|
||||||
wherever you got libpng. zlib can be placed in another directory,
|
wherever you got libpng; otherwise go to https://zlib.net/. You can
|
||||||
at the same level as libpng.
|
place zlib in the same directory as libpng or in another directory.
|
||||||
|
|
||||||
If you want to use "cmake" (see www.cmake.org), type
|
|
||||||
|
|
||||||
cmake . -DCMAKE_INSTALL_PREFIX=/path
|
|
||||||
make
|
|
||||||
make install
|
|
||||||
|
|
||||||
If your system already has a preinstalled zlib you will still need
|
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
|
to have access to the zlib.h and zconf.h include files that
|
||||||
correspond to the version of zlib that's installed.
|
correspond to the version of zlib that's installed.
|
||||||
|
|
||||||
|
If you wish to test with a particular zlib that is not first in the
|
||||||
|
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
|
||||||
|
|
||||||
|
If you are using one of the makefile scripts, put ZLIBLIB and ZLIBINC
|
||||||
|
in your environment and type
|
||||||
|
|
||||||
|
make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test
|
||||||
|
|
||||||
|
IV. Using cmake
|
||||||
|
|
||||||
|
If you want to use "cmake" (see www.cmake.org), type
|
||||||
|
|
||||||
|
cmake . -DCMAKE_INSTALL_PREFIX=/path
|
||||||
|
make
|
||||||
|
make install
|
||||||
|
|
||||||
|
As when using the simple configure method described above, "/path" points to
|
||||||
|
the installation directory where you want to put the libpng "lib", "include",
|
||||||
|
and "bin" subdirectories.
|
||||||
|
|
||||||
|
V. Directory structure
|
||||||
|
|
||||||
You can rename the directories that you downloaded (they
|
You can rename the directories that you downloaded (they
|
||||||
might be called "libpng-1.2.46" or "libpng12" and "zlib-1.2.3"
|
might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.8"
|
||||||
or "zlib123") so that you have directories called "zlib" and "libpng".
|
or "zlib128") so that you have directories called "zlib" and "libpng".
|
||||||
|
|
||||||
Your directory structure should look like this:
|
Your directory structure should look like this:
|
||||||
|
|
||||||
.. (the parent directory)
|
.. (the parent directory)
|
||||||
libpng (this directory)
|
libpng (this directory)
|
||||||
INSTALL (this file)
|
INSTALL (this file)
|
||||||
README
|
README
|
||||||
*.h
|
*.h, *.c => libpng source files
|
||||||
*.c
|
|
||||||
CMakeLists.txt => "cmake" script
|
CMakeLists.txt => "cmake" script
|
||||||
configuration files:
|
configuration files:
|
||||||
configure.ac, configure, Makefile.am, Makefile.in,
|
configure.ac, configure, Makefile.am, Makefile.in,
|
||||||
autogen.sh, config.guess, ltmain.sh, missing,
|
autogen.sh, config.guess, ltmain.sh, missing, libpng.pc.in,
|
||||||
aclocal.m4, config.h.in, config.sub,
|
libpng-config.in, aclocal.m4, config.h.in, config.sub,
|
||||||
depcomp, install-sh, mkinstalldirs, test-pngtest.sh
|
depcomp, install-sh, mkinstalldirs, test-pngtest.sh
|
||||||
contrib
|
contrib
|
||||||
gregbook
|
arm-neon, conftest, examples, gregbook, libtests, pngminim,
|
||||||
pngminim
|
pngminus, pngsuite, tools, visupng
|
||||||
pngminus
|
|
||||||
pngsuite
|
|
||||||
visupng
|
|
||||||
projects
|
projects
|
||||||
cbuilder5 (Borland)
|
cbuilder5, owatcom, visualc71, vstudio, xcode
|
||||||
visualc6 (msvc)
|
|
||||||
visualc71
|
|
||||||
xcode
|
|
||||||
scripts
|
scripts
|
||||||
makefile.*
|
makefile.*
|
||||||
*.def (module definition files)
|
*.def (module definition files)
|
||||||
|
etc.
|
||||||
pngtest.png
|
pngtest.png
|
||||||
etc.
|
etc.
|
||||||
zlib
|
zlib
|
||||||
README
|
README, *.h, *.c contrib, etc.
|
||||||
*.h
|
|
||||||
*.c
|
|
||||||
contrib
|
|
||||||
etc.
|
|
||||||
|
|
||||||
If the line endings in the files look funny, you may wish to get the other
|
If the line endings in the files look funny, you may wish to get the other
|
||||||
distribution of libpng. It is available in both tar.gz (UNIX style line
|
distribution of libpng. It is available in both tar.gz (UNIX style line
|
||||||
endings) and zip (DOS style line endings) formats.
|
endings) and zip (DOS style line endings) formats.
|
||||||
|
|
||||||
|
VI. Building with project files
|
||||||
|
|
||||||
If you are building libpng with MSVC, you can enter the
|
If you are building libpng with MSVC, you can enter the
|
||||||
libpng projects\visualc6 or visualc71 directory and follow the instructions
|
libpng projects\visualc71 or vstudio directory and follow the instructions
|
||||||
in README.txt.
|
in README.txt.
|
||||||
|
|
||||||
Otherwise enter the zlib directory and follow the instructions in zlib/README,
|
Otherwise enter the zlib directory and follow the instructions in zlib/README,
|
||||||
then come back here and run "configure" or choose the appropriate
|
then come back here and run "configure" or choose the appropriate
|
||||||
makefile.sys in the scripts directory.
|
makefile.sys in the scripts directory.
|
||||||
|
|
||||||
|
VII. Building with makefiles
|
||||||
|
|
||||||
Copy the file (or files) that you need from the
|
Copy the file (or files) that you need from the
|
||||||
scripts directory into this directory, for example
|
scripts directory into this directory, for example
|
||||||
|
|
||||||
MSDOS example: copy scripts\makefile.msc makefile
|
MSDOS example:
|
||||||
UNIX example: cp scripts/makefile.std makefile
|
|
||||||
|
copy scripts\makefile.msc makefile
|
||||||
|
copy scripts\pnglibconf.h.prebuilt pnglibconf.h
|
||||||
|
|
||||||
|
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
|
Read the makefile to see if you need to change any source or
|
||||||
target directories to match your preferences.
|
target directories to match your preferences.
|
||||||
|
|
||||||
Then read pngconf.h to see if you want to make any configuration
|
Then read pnglibconf.dfa to see if you want to make any configuration
|
||||||
changes.
|
changes.
|
||||||
|
|
||||||
Then just run "make" which will create the libpng library in
|
Then just run "make" which will create the libpng library in
|
||||||
|
@ -125,39 +197,269 @@ do that, run "make install" in the zlib directory first if necessary).
|
||||||
Some also allow you to run "make test-installed" after you have
|
Some also allow you to run "make test-installed" after you have
|
||||||
run "make install".
|
run "make install".
|
||||||
|
|
||||||
If you encounter a compiler error message complaining about the
|
VIII. Configuring libpng for 16-bit platforms
|
||||||
lines
|
|
||||||
|
|
||||||
__png.h__ already includes setjmp.h;
|
You will want to look into zconf.h to tell zlib (and thus libpng) that
|
||||||
__dont__ include it again.;
|
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.
|
||||||
|
|
||||||
this means you have compiled another module that includes setjmp.h,
|
IX. Configuring for DOS
|
||||||
which is hazardous because the two modules might not include exactly
|
|
||||||
the same setjmp.h. If you are sure that you know what you are doing
|
|
||||||
and that they are exactly the same, then you can comment out or
|
|
||||||
delete the two lines. Better yet, use the cexcept interface
|
|
||||||
instead, as demonstrated in contrib/visupng of the libpng distribution.
|
|
||||||
|
|
||||||
Further information can be found in the README and libpng.txt
|
For DOS users who only have access to the lower 640K, you will
|
||||||
|
have to limit zlib's memory usage via a png_set_compression_mem_level()
|
||||||
|
call. See zlib.h or zconf.h in the zlib library for more information.
|
||||||
|
|
||||||
|
X. Configuring for Medium Model
|
||||||
|
|
||||||
|
Libpng's support for medium model has been tested on most of the popular
|
||||||
|
compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets
|
||||||
|
defined, and FAR gets defined to far in pngconf.h, and you should be
|
||||||
|
all set. Everything in the library (except for zlib's structure) is
|
||||||
|
expecting far data. You must use the typedefs with the p or pp on
|
||||||
|
the end for pointers (or at least look at them and be careful). Make
|
||||||
|
note that the rows of data are defined as png_bytepp, which is
|
||||||
|
an "unsigned char far * far *".
|
||||||
|
|
||||||
|
XI. Prepending a prefix to exported symbols
|
||||||
|
|
||||||
|
Starting with libpng-1.6.0, you can configure libpng (when using the
|
||||||
|
"configure" script) to prefix all exported symbols by means of the
|
||||||
|
configuration option "--with-libpng-prefix=FOO_", where FOO_ can be any
|
||||||
|
string beginning with a letter and containing only uppercase
|
||||||
|
and lowercase letters, digits, and the underscore (i.e., a C language
|
||||||
|
identifier). This creates a set of macros in pnglibconf.h, so this is
|
||||||
|
transparent to applications; their function calls get transformed by
|
||||||
|
the macros to use the modified names.
|
||||||
|
|
||||||
|
XII. Configuring for compiler xxx:
|
||||||
|
|
||||||
|
All includes for libpng are in pngconf.h. If you need to add, change
|
||||||
|
or delete an include, this is the place to do it.
|
||||||
|
The includes that are not needed outside libpng are placed in pngpriv.h,
|
||||||
|
which is only used by the routines inside libpng itself.
|
||||||
|
The files in libpng proper only include pngpriv.h and png.h, which
|
||||||
|
in turn includes pngconf.h and, as of libpng-1.5.0, pnglibconf.h.
|
||||||
|
As of libpng-1.5.0, pngpriv.h also includes three other private header
|
||||||
|
files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material
|
||||||
|
that previously appeared in the public headers.
|
||||||
|
|
||||||
|
XIII. Removing unwanted object code
|
||||||
|
|
||||||
|
There are a bunch of #define's in pngconf.h that control what parts of
|
||||||
|
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_".
|
||||||
|
|
||||||
|
In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead.
|
||||||
|
|
||||||
|
You can also turn all of the transforms and ancillary chunk capabilities
|
||||||
|
off en masse with compiler directives that define
|
||||||
|
PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
|
||||||
|
or all four, along with directives to turn on any of the capabilities that
|
||||||
|
you do want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable the
|
||||||
|
extra transformations but still leave the library fully capable of reading
|
||||||
|
and writing PNG files with all known public chunks. Use of the
|
||||||
|
PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a library
|
||||||
|
that is incapable of reading or writing ancillary chunks. If you are
|
||||||
|
not using the progressive reading capability, you can turn that off
|
||||||
|
with PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACING
|
||||||
|
capability, which you'll still have).
|
||||||
|
|
||||||
|
All the reading and writing specific code are in separate files, so the
|
||||||
|
linker should only grab the files it needs. However, if you want to
|
||||||
|
make sure, or if you are building a stand alone library, all the
|
||||||
|
reading files start with "pngr" and all the writing files start with "pngw".
|
||||||
|
The files that don't match either (like png.c, pngtrans.c, etc.)
|
||||||
|
are used for both reading and writing, and always need to be included.
|
||||||
|
The progressive reader is in pngpread.c
|
||||||
|
|
||||||
|
If you are creating or distributing a dynamically linked library (a .so
|
||||||
|
or DLL file), you should not remove or disable any parts of the library,
|
||||||
|
as this will cause applications linked with different versions of the
|
||||||
|
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. 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
|
||||||
|
majority of library users or builders; however, the few who configure libpng
|
||||||
|
to a non-default feature set may need to change how this is done.
|
||||||
|
|
||||||
|
There should be no need for library builders to alter build scripts if
|
||||||
|
these use the distributed build support - configure or the makefiles -
|
||||||
|
however, users of the makefiles may care to update their build scripts
|
||||||
|
to build pnglibconf.h where the corresponding makefile does not do so.
|
||||||
|
|
||||||
|
Building libpng with a non-default configuration has changed completely.
|
||||||
|
The old method using pngusr.h should still work correctly even though the
|
||||||
|
way pngusr.h is used in the build has been changed; however, library
|
||||||
|
builders will probably want to examine the changes to take advantage of
|
||||||
|
new capabilities and to simplify their build system.
|
||||||
|
|
||||||
|
A. Specific changes to library configuration capabilities
|
||||||
|
|
||||||
|
The exact mechanism used to control attributes of API functions has
|
||||||
|
changed. A single set of operating system independent macro definitions
|
||||||
|
is used and operating system specific directives are defined in
|
||||||
|
pnglibconf.h
|
||||||
|
|
||||||
|
As part of this the mechanism used to choose procedure call standards on
|
||||||
|
those systems that allow a choice has been changed. At present this only
|
||||||
|
affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems
|
||||||
|
running on Intel processors. As before, PNGAPI is defined where required
|
||||||
|
to control the exported API functions; however, two new macros, PNGCBAPI
|
||||||
|
and PNGCAPI, are used instead for callback functions (PNGCBAPI) and
|
||||||
|
(PNGCAPI) for functions that must match a C library prototype (currently
|
||||||
|
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
|
||||||
|
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
|
||||||
|
(png-mng-implement) of this and library builders who use Openwatcom and
|
||||||
|
therefore set PNG_API_RULE to 2 should also contact the mailing list.
|
||||||
|
|
||||||
|
B. Changes to the configuration mechanism
|
||||||
|
|
||||||
|
Prior to libpng-1.5.0 library builders who needed to configure libpng
|
||||||
|
had either to modify the exported pngconf.h header file to add system
|
||||||
|
specific configuration or had to write feature selection macros into
|
||||||
|
pngusr.h and cause this to be included into pngconf.h by defining
|
||||||
|
PNG_USER_CONFIG. The latter mechanism had the disadvantage that an
|
||||||
|
application built without PNG_USER_CONFIG defined would see the
|
||||||
|
unmodified, default, libpng API and thus would probably fail to link.
|
||||||
|
|
||||||
|
These mechanisms still work in the configure build and in any makefile
|
||||||
|
build that builds pnglibconf.h, although the feature selection macros
|
||||||
|
have changed somewhat as described above. In 1.5.0, however, pngusr.h is
|
||||||
|
processed only once, at the time the exported header file pnglibconf.h is
|
||||||
|
built. pngconf.h no longer includes pngusr.h; therefore, pngusr.h is ignored
|
||||||
|
after the build of pnglibconf.h and it is never included in an application
|
||||||
|
build.
|
||||||
|
|
||||||
|
The formerly used alternative of adding a list of feature macros to the
|
||||||
|
CPPFLAGS setting in the build also still works; however, the macros will be
|
||||||
|
copied to pnglibconf.h and this may produce macro redefinition warnings
|
||||||
|
when the individual C files are compiled.
|
||||||
|
|
||||||
|
All configuration now only works if pnglibconf.h is built from
|
||||||
|
scripts/pnglibconf.dfa. This requires the program awk. Brian Kernighan
|
||||||
|
(the original author of awk) maintains C source code of that awk and this
|
||||||
|
and all known later implementations (often called by subtly different
|
||||||
|
names - nawk and gawk for example) are adequate to build pnglibconf.h.
|
||||||
|
The Sun Microsystems (now Oracle) program 'awk' is an earlier version
|
||||||
|
and does not work; this may also apply to other systems that have a
|
||||||
|
functioning awk called 'nawk'.
|
||||||
|
|
||||||
|
Configuration options are now documented in scripts/pnglibconf.dfa. This
|
||||||
|
file also includes dependency information that ensures a configuration is
|
||||||
|
consistent; that is, if a feature is switched off, dependent features are
|
||||||
|
also switched off. As a recommended alternative to using feature macros in
|
||||||
|
pngusr.h a system builder may also define equivalent options in pngusr.dfa
|
||||||
|
(or, indeed, any file) and add that to the configuration by setting
|
||||||
|
DFA_XTRA to the file name. The makefiles in contrib/pngminim illustrate
|
||||||
|
how to do this, and also illustrate a case where pngusr.h is still required.
|
||||||
|
|
||||||
|
After you have built libpng, the definitions that were recorded in
|
||||||
|
pnglibconf.h are available to your application (pnglibconf.h is included
|
||||||
|
in png.h and gets installed alongside png.h and pngconf.h in your
|
||||||
|
$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.
|
||||||
|
|
||||||
|
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
|
||||||
|
any platform where it is guaranteed to be thread-safe. Therefore, if
|
||||||
|
your application is going to be using multiple threads, you should
|
||||||
|
configure libpng with PNG_NO_SETJMP in your pngusr.dfa file, with
|
||||||
|
-DPNG_NO_SETJMP on your compile line, or with
|
||||||
|
|
||||||
|
#undef PNG_SETJMP_SUPPORTED
|
||||||
|
|
||||||
|
in your pnglibconf.h or pngusr.h.
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
||||||
|
XVII. Common linking failures
|
||||||
|
|
||||||
|
If your application fails to find libpng or zlib entries while linking:
|
||||||
|
|
||||||
|
Be sure "-lz" appears after "-lpng" on your linking command.
|
||||||
|
|
||||||
|
Be sure you have built libpng, zlib, and your application for the
|
||||||
|
same platform (e.g., 32-bit or 64-bit).
|
||||||
|
|
||||||
|
If you are using the vstudio project, observe the WARNING in
|
||||||
|
project/vstudio/README.txt.
|
||||||
|
|
||||||
|
XVIII. Other sources of information about libpng:
|
||||||
|
|
||||||
|
Further information can be found in the README and libpng-manual.txt
|
||||||
files, in the individual makefiles, in png.h, and the manual pages
|
files, in the individual makefiles, in png.h, and the manual pages
|
||||||
libpng.3 and png.5.
|
libpng.3 and png.5.
|
||||||
|
|
||||||
|
Copyright (c) 1998-2002,2006-2016 Glenn Randers-Pehrson
|
||||||
Using the ./configure script -- 16 December 2002.
|
This document is released under the libpng license.
|
||||||
=================================================
|
For conditions of distribution and use, see the disclaimer
|
||||||
|
and license in png.h.
|
||||||
|
|
||||||
The ./configure script should work compatibly with what scripts/makefile.*
|
|
||||||
did, however there are some options you need to add to configure explicitly,
|
|
||||||
which previously was done semi-automatically (if you didn't edit
|
|
||||||
scripts/makefile.* yourself, that is)
|
|
||||||
|
|
||||||
|
|
||||||
CFLAGS="-Wall -O -funroll-loops \
|
|
||||||
-malign-loops=2 -malign-functions=2" ./configure --prefix=/usr/include \
|
|
||||||
--with-pkgconfigdir=/usr/lib/pkgconfig --includedir=/usr/include
|
|
||||||
|
|
||||||
You can alternatively specify --includedir=/usr/include, /usr/local/include,
|
|
||||||
/usr/include/png12, or whatever.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,111 +1,134 @@
|
||||||
|
COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
|
||||||
|
=========================================
|
||||||
|
|
||||||
This copy of the libpng notices is provided for your convenience. In case of
|
PNG Reference Library License version 2
|
||||||
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:
|
* 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.
|
||||||
|
|
||||||
If you modify libpng you may insert additional notices immediately following
|
The software is supplied "as is", without warranty of any kind,
|
||||||
this sentence.
|
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.
|
||||||
|
|
||||||
This code is released under the libpng license.
|
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:
|
||||||
|
|
||||||
libpng versions 1.2.6, August 15, 2004, through 1.2.46, July 9, 2011, are
|
1. The origin of this software must not be misrepresented; you
|
||||||
Copyright (c) 2004, 2006-2009 Glenn Randers-Pehrson, and are
|
must not claim that you wrote the original software. If you
|
||||||
distributed according to the same disclaimer and license as libpng-1.2.5
|
use this software in a product, an acknowledgment in the product
|
||||||
with the following individual added to the list of Contributing Authors
|
documentation would be appreciated, but is not required.
|
||||||
|
|
||||||
Cosmin Truta
|
2. Altered source versions must be plainly marked as such, and must
|
||||||
|
not be misrepresented as being the original software.
|
||||||
|
|
||||||
libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
|
3. This Copyright notice may not be removed or altered from any
|
||||||
Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
|
source or altered source distribution.
|
||||||
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
|
PNG Reference Library License version 1 (for libpng 0.5 through 1.6.35)
|
||||||
Gilles Vollant
|
-----------------------------------------------------------------------
|
||||||
|
|
||||||
|
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:
|
and with the following additions to the disclaimer:
|
||||||
|
|
||||||
There is no warranty against interference with your enjoyment of the
|
There is no warranty against interference with your enjoyment of
|
||||||
library or against infringement. There is no warranty that our
|
the library or against infringement. There is no warranty that our
|
||||||
efforts or the library will fulfill any of your particular purposes
|
efforts or the library will fulfill any of your particular purposes
|
||||||
or needs. This library is provided with all faults, and the entire
|
or needs. This library is provided with all faults, and the entire
|
||||||
risk of satisfactory quality, performance, accuracy, and effort is with
|
risk of satisfactory quality, performance, accuracy, and effort is
|
||||||
the user.
|
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
|
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
||||||
Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are
|
Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
|
||||||
distributed according to the same disclaimer and license as libpng-0.96,
|
libpng-0.96, and are distributed according to the same disclaimer and
|
||||||
with the following individuals added to the list of Contributing Authors:
|
license as libpng-0.96, with the following individuals added to the
|
||||||
|
list of Contributing Authors:
|
||||||
|
|
||||||
Tom Lane
|
Tom Lane
|
||||||
Glenn Randers-Pehrson
|
Glenn Randers-Pehrson
|
||||||
Willem van Schaik
|
Willem van Schaik
|
||||||
|
|
||||||
libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
||||||
Copyright (c) 1996, 1997 Andreas Dilger
|
Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
|
||||||
Distributed according to the same disclaimer and license as libpng-0.88,
|
and are distributed according to the same disclaimer and license as
|
||||||
with the following individuals added to the list of Contributing Authors:
|
libpng-0.88, with the following individuals added to the list of
|
||||||
|
Contributing Authors:
|
||||||
|
|
||||||
John Bowler
|
John Bowler
|
||||||
Kevin Bracey
|
Kevin Bracey
|
||||||
Sam Bushell
|
Sam Bushell
|
||||||
Magnus Holmgren
|
Magnus Holmgren
|
||||||
Greg Roelofs
|
Greg Roelofs
|
||||||
Tom Tanner
|
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
|
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"
|
For the purposes of this copyright and license, "Contributing Authors"
|
||||||
is defined as the following set of individuals:
|
is defined as the following set of individuals:
|
||||||
|
|
||||||
Andreas Dilger
|
Andreas Dilger
|
||||||
Dave Martindale
|
Dave Martindale
|
||||||
Guy Eric Schalnat
|
Guy Eric Schalnat
|
||||||
Paul Schmidt
|
Paul Schmidt
|
||||||
Tim Wegner
|
Tim Wegner
|
||||||
|
|
||||||
The PNG Reference Library is supplied "AS IS". The Contributing Authors
|
The PNG Reference Library is supplied "AS IS". The Contributing
|
||||||
and Group 42, Inc. disclaim all warranties, expressed or implied,
|
Authors and Group 42, Inc. disclaim all warranties, expressed or
|
||||||
including, without limitation, the warranties of merchantability and of
|
implied, including, without limitation, the warranties of
|
||||||
fitness for any purpose. The Contributing Authors and Group 42, Inc.
|
merchantability and of fitness for any purpose. The Contributing
|
||||||
assume no liability for direct, indirect, incidental, special, exemplary,
|
Authors and Group 42, Inc. assume no liability for direct, indirect,
|
||||||
or consequential damages, which may result from the use of the PNG
|
incidental, special, exemplary, or consequential damages, which may
|
||||||
Reference Library, even if advised of the possibility of such damage.
|
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
|
Permission is hereby granted to use, copy, modify, and distribute this
|
||||||
source code, or portions hereof, for any purpose, without fee, subject
|
source code, or portions hereof, for any purpose, without fee, subject
|
||||||
to the following restrictions:
|
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.
|
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.
|
source or altered source distribution.
|
||||||
|
|
||||||
The Contributing Authors and Group 42, Inc. specifically permit, without
|
The Contributing Authors and Group 42, Inc. specifically permit,
|
||||||
fee, and encourage the use of this source code as a component to
|
without fee, and encourage the use of this source code as a component
|
||||||
supporting the PNG file format in commercial products. If you use this
|
to supporting the PNG file format in commercial products. If you use
|
||||||
source code in a product, acknowledgment is not required but would be
|
this source code in a product, acknowledgment is not required but would
|
||||||
appreciated.
|
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
|
|
||||||
July 9, 2011
|
|
||||||
|
|
2428
libs/libpng-src/Makefile
Normal file
2428
libs/libpng-src/Makefile
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,155 +1,393 @@
|
||||||
# Makefile.am:
|
# Makefile.am, the source file for Makefile.in (and hence Makefile), is
|
||||||
# Source file for Makefile.in (and hence Makefile)
|
|
||||||
#
|
#
|
||||||
# Makefile.am need only be changed on a major version number
|
# Copyright (c) 2018 Cosmin Truta
|
||||||
# change (e.g. libpng12 --> libpng14). In that case seach
|
# Copyright (c) 2004-2016 Glenn Randers-Pehrson
|
||||||
# this file for every instance of the old base name (libpng12)
|
#
|
||||||
# and change to the new one (libpng14), then change the
|
# This code is released under the libpng license.
|
||||||
# -version-number settings below so that the new values have
|
# For conditions of distribution and use, see the disclaimer
|
||||||
# the correct major part (first field).
|
# and license in png.h
|
||||||
|
|
||||||
PNGLIB_BASENAME= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
|
PNGLIB_BASENAME= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
|
||||||
|
|
||||||
# libpng does not follow GNU file name conventions
|
ACLOCAL_AMFLAGS = -I scripts
|
||||||
AUTOMAKE_OPTIONS = foreign
|
|
||||||
|
|
||||||
# test programs - run on make check, make distcheck
|
# test programs - run on make check, make distcheck
|
||||||
check_PROGRAMS= pngtest
|
check_PROGRAMS= pngtest pngunknown pngstest pngvalid pngimage pngcp
|
||||||
|
if HAVE_CLOCK_GETTIME
|
||||||
|
check_PROGRAMS += timepng
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Utilities - installed
|
||||||
|
bin_PROGRAMS= pngfix png-fix-itxt
|
||||||
|
|
||||||
|
# This ensures that pnglibconf.h gets built at the start of 'make all' or
|
||||||
|
# 'make check', but it does not add dependencies to the individual programs,
|
||||||
|
# this is done below.
|
||||||
|
#
|
||||||
|
# IMPORTANT: always add the object modules of new programs to the list below
|
||||||
|
# because otherwise the sequence 'configure; make new-program' will *sometimes*
|
||||||
|
# result in the installed (system) pnglibconf.h being used and the result is
|
||||||
|
# always wrong and always very confusing.
|
||||||
|
BUILT_SOURCES = pnglibconf.h
|
||||||
|
|
||||||
pngtest_SOURCES = pngtest.c
|
pngtest_SOURCES = pngtest.c
|
||||||
pngtest_LDADD = libpng12.la
|
pngtest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||||
TESTS = test-pngtest.sh
|
|
||||||
TESTS_ENVIRONMENT= srcdir=$(srcdir)
|
pngvalid_SOURCES = contrib/libtests/pngvalid.c
|
||||||
|
pngvalid_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||||
|
|
||||||
|
pngstest_SOURCES = contrib/libtests/pngstest.c
|
||||||
|
pngstest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||||
|
|
||||||
|
pngunknown_SOURCES = contrib/libtests/pngunknown.c
|
||||||
|
pngunknown_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||||
|
|
||||||
|
pngimage_SOURCES = contrib/libtests/pngimage.c
|
||||||
|
pngimage_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||||
|
|
||||||
|
timepng_SOURCES = contrib/libtests/timepng.c
|
||||||
|
timepng_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||||
|
|
||||||
|
pngfix_SOURCES = contrib/tools/pngfix.c
|
||||||
|
pngfix_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||||
|
|
||||||
|
png_fix_itxt_SOURCES = contrib/tools/png-fix-itxt.c
|
||||||
|
|
||||||
|
pngcp_SOURCES = contrib/tools/pngcp.c
|
||||||
|
pngcp_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||||
|
|
||||||
|
# Generally these are single line shell scripts to run a test with a particular
|
||||||
|
# set of parameters:
|
||||||
|
TESTS =\
|
||||||
|
tests/pngtest\
|
||||||
|
tests/pngtest-badpngs\
|
||||||
|
tests/pngvalid-gamma-16-to-8 tests/pngvalid-gamma-alpha-mode\
|
||||||
|
tests/pngvalid-gamma-background tests/pngvalid-gamma-expand16-alpha-mode\
|
||||||
|
tests/pngvalid-gamma-expand16-background\
|
||||||
|
tests/pngvalid-gamma-expand16-transform tests/pngvalid-gamma-sbit\
|
||||||
|
tests/pngvalid-gamma-threshold tests/pngvalid-gamma-transform\
|
||||||
|
tests/pngvalid-progressive-size\
|
||||||
|
tests/pngvalid-progressive-interlace-standard\
|
||||||
|
tests/pngvalid-transform\
|
||||||
|
tests/pngvalid-progressive-standard tests/pngvalid-standard\
|
||||||
|
tests/pngstest-1.8 tests/pngstest-1.8-alpha tests/pngstest-linear\
|
||||||
|
tests/pngstest-linear-alpha tests/pngstest-none tests/pngstest-none-alpha\
|
||||||
|
tests/pngstest-sRGB tests/pngstest-sRGB-alpha tests/pngunknown-IDAT\
|
||||||
|
tests/pngunknown-discard tests/pngunknown-if-safe tests/pngunknown-sAPI\
|
||||||
|
tests/pngunknown-sTER tests/pngunknown-save tests/pngunknown-vpAg\
|
||||||
|
tests/pngimage-quick tests/pngimage-full
|
||||||
|
|
||||||
# man pages
|
# man pages
|
||||||
dist_man_MANS= libpng.3 libpngpf.3 png.5
|
dist_man_MANS= libpng.3 libpngpf.3 png.5
|
||||||
|
|
||||||
# generate the -config scripts if required
|
# generate the -config scripts if required
|
||||||
binconfigs= libpng12-config
|
binconfigs= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config
|
||||||
EXTRA_SCRIPTS= libpng-config libpng12-config
|
EXTRA_SCRIPTS= libpng-config libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config
|
||||||
bin_SCRIPTS= @binconfigs@
|
bin_SCRIPTS= @binconfigs@
|
||||||
|
|
||||||
# rules to build libpng, only build the old library on request
|
# rules to build libpng, only build the old library on request
|
||||||
lib_LTLIBRARIES=libpng12.la @compatlib@
|
lib_LTLIBRARIES=libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||||
EXTRA_LTLIBRARIES= libpng.la
|
# EXTRA_LTLIBRARIES= libpng.la
|
||||||
libpng12_la_SOURCES = png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c\
|
||||||
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
|
pngget.c pngmem.c pngpread.c pngread.c pngrio.c pngrtran.c pngrutil.c\
|
||||||
pngwtran.c pngmem.c pngerror.c pngpread.c \
|
pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c pngwutil.c\
|
||||||
png.h pngconf.h
|
png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngusr.dfa
|
||||||
libpng_la_SOURCES = $(libpng12_la_SOURCES)
|
|
||||||
|
|
||||||
libpng_la_CPPFLAGS = @LIBPNG_DEFINES@
|
if PNG_ARM_NEON
|
||||||
libpng12_la_CPPFLAGS = @LIBPNG_DEFINES@
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/arm_init.c\
|
||||||
|
arm/filter_neon.S arm/filter_neon_intrinsics.c \
|
||||||
|
arm/palette_neon_intrinsics.c
|
||||||
|
endif
|
||||||
|
|
||||||
# MAJOR UPGRADE: the version-number settings below must be changed.
|
if PNG_MIPS_MSA
|
||||||
libpng12_la_LDFLAGS = -no-undefined -export-dynamic \
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += mips/mips_init.c\
|
||||||
-version-number 0:@PNGLIB_RELEASE@:0
|
mips/filter_msa_intrinsics.c
|
||||||
# -rpath is needed as automake doesn't know the directory
|
endif
|
||||||
libpng_la_LDFLAGS = -rpath '$(libdir)' -no-undefined -export-dynamic \
|
|
||||||
-version-number 3:@PNGLIB_RELEASE@:0
|
if PNG_INTEL_SSE
|
||||||
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += intel/intel_init.c\
|
||||||
|
intel/filter_sse2_intrinsics.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
if PNG_POWERPC_VSX
|
||||||
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += powerpc/powerpc_init.c\
|
||||||
|
powerpc/filter_vsx_intrinsics.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
|
||||||
|
|
||||||
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS = -no-undefined -export-dynamic \
|
||||||
|
-version-number @PNGLIB_MAJOR@@PNGLIB_MINOR@:@PNGLIB_RELEASE@:0
|
||||||
|
|
||||||
if HAVE_LD_VERSION_SCRIPT
|
if HAVE_LD_VERSION_SCRIPT
|
||||||
# Versioned symbols and restricted exports
|
# Versioned symbols and restricted exports
|
||||||
libpng12_la_LDFLAGS += -Wl,--version-script=libpng.vers
|
if HAVE_SOLARIS_LD
|
||||||
libpng12_la_DEPENDENCIES = libpng.vers
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS += -Wl,-M -Wl,libpng.vers
|
||||||
else
|
else
|
||||||
# Only restricted exports when possible
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS += -Wl,--version-script=libpng.vers
|
||||||
libpng12_la_LDFLAGS += -export-symbols libpng.sym
|
|
||||||
libpng12_la_DEPENDENCIES = libpng.sym
|
|
||||||
endif
|
endif
|
||||||
libpng_la_DEPENDENCIES = $(libpng12_la_DEPENDENCIES)
|
|
||||||
|
|
||||||
# Avoid depending upon Character Ranges.
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.vers
|
||||||
AN = '_abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
|
else
|
||||||
|
# Only restricted exports when possible
|
||||||
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS += -export-symbols libpng.sym
|
||||||
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.sym
|
||||||
|
endif
|
||||||
|
|
||||||
#distribute headers in /usr/include/libpng/*
|
#distribute headers in /usr/include/libpng/*
|
||||||
pkgincludedir= $(includedir)/$(PNGLIB_BASENAME)
|
pkgincludedir= $(includedir)/$(PNGLIB_BASENAME)
|
||||||
pkginclude_HEADERS= png.h pngconf.h
|
pkginclude_HEADERS= png.h pngconf.h
|
||||||
|
nodist_pkginclude_HEADERS= pnglibconf.h
|
||||||
|
|
||||||
# pkg-config stuff, note that libpng.pc is always required in order
|
# pkg-config stuff, note that libpng.pc is always required in order
|
||||||
# to get the correct library
|
# to get the correct library
|
||||||
pkgconfigdir = @pkgconfigdir@
|
pkgconfigdir = @pkgconfigdir@
|
||||||
pkgconfig_DATA = libpng12.pc
|
pkgconfig_DATA = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc
|
||||||
|
|
||||||
#extra source distribution files.
|
# Extra source distribution files, '${srcdir}' is used below to stop build files
|
||||||
|
# from those directories being included. This only works if the configure is
|
||||||
|
# not done in the source directory!
|
||||||
EXTRA_DIST= \
|
EXTRA_DIST= \
|
||||||
ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO \
|
ANNOUNCE AUTHORS CHANGES INSTALL LICENSE README TODO TRADEMARK \
|
||||||
pngtest.png pngbar.png pngnow.png pngbar.jpg autogen.sh \
|
pngtest.png pngbar.png pngnow.png pngbar.jpg autogen.sh \
|
||||||
CMakeLists.txt \
|
${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \
|
||||||
${srcdir}/projects/cbuilder5/* \
|
$(TESTS) $(XFAIL_TESTS) tests/pngstest \
|
||||||
${srcdir}/projects/beos/* \
|
CMakeLists.txt example.c libpng-manual.txt
|
||||||
${srcdir}/projects/visualc6/* \
|
|
||||||
${srcdir}/projects/visualc71/* \
|
|
||||||
${srcdir}/projects/wince.txt \
|
|
||||||
${srcdir}/projects/netware.txt \
|
|
||||||
${srcdir}/projects/xcode/* \
|
|
||||||
${srcdir}/scripts/* \
|
|
||||||
${srcdir}/contrib/gregbook/* \
|
|
||||||
${srcdir}/contrib/pngminim/* \
|
|
||||||
${srcdir}/contrib/pngminus/* \
|
|
||||||
${srcdir}/contrib/pngsuite/* \
|
|
||||||
${srcdir}/contrib/visupng/* \
|
|
||||||
$(TESTS) \
|
|
||||||
example.c libpng-1.2.46.txt pnggccrd.c pngvcrd.c
|
|
||||||
|
|
||||||
CLEANFILES= pngout.png libpng12.pc libpng12-config libpng.vers \
|
SCRIPT_CLEANFILES=scripts/*.out scripts/*.chk
|
||||||
libpng.sym
|
|
||||||
|
CLEANFILES= *.tf? pngout.png libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc \
|
||||||
|
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config libpng.vers libpng.sym \
|
||||||
|
check.new pnglibconf.h pngprefix.h symbols.new pngtest-log.txt \
|
||||||
|
pnglibconf.out pnglibconf.c pnglibconf.pre pnglibconf.dfn \
|
||||||
|
$(SCRIPT_CLEANFILES)
|
||||||
|
|
||||||
MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.h.in \
|
MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.h.in \
|
||||||
config.sub configure depcomp install-sh ltmain.sh missing
|
config.sub configure depcomp install-sh ltmain.sh missing
|
||||||
|
|
||||||
|
# PNG_COPTS give extra options for the C compiler to be used on all compilation
|
||||||
|
# steps (unless targe_CFLAGS is specified; that will take precedence over
|
||||||
|
# AM_CFLAGS)
|
||||||
|
PNG_COPTS = @PNG_COPTS@
|
||||||
|
AM_CFLAGS = ${PNG_COPTS}
|
||||||
|
|
||||||
|
# DFNCPP is normally just CPP - the C preprocessor - but on Solaris and maybe
|
||||||
|
# other operating systems (NeXT?) the C preprocessor selected by configure
|
||||||
|
# checks input tokens for validity - effectively it performs part of the ANSI-C
|
||||||
|
# parsing - and therefore fails with the .df files. configure.ac has special
|
||||||
|
# checks for this and sets DFNCPP appropriately.
|
||||||
|
DFNCPP = @DFNCPP@
|
||||||
|
|
||||||
|
SUFFIXES = .chk .out
|
||||||
|
|
||||||
$(PNGLIB_BASENAME).pc: libpng.pc
|
$(PNGLIB_BASENAME).pc: libpng.pc
|
||||||
cp libpng.pc $@
|
cp libpng.pc $@
|
||||||
|
|
||||||
$(PNGLIB_BASENAME)-config: libpng-config
|
$(PNGLIB_BASENAME)-config: libpng-config
|
||||||
cp libpng-config $@
|
cp libpng-config $@
|
||||||
|
|
||||||
libpng.sym: png.h pngconf.h
|
scripts/sym.out scripts/vers.out: png.h pngconf.h pnglibconf.h
|
||||||
rm -f $@ $@.new
|
scripts/prefix.out: png.h pngconf.h pnglibconf.out
|
||||||
$(CPP) @LIBPNG_DEFINES@ $(CPPFLAGS) -DPNG_BUILDSYMS $(srcdir)/png.h | \
|
scripts/symbols.out: png.h pngconf.h $(srcdir)/scripts/pnglibconf.h.prebuilt
|
||||||
$(SED) -n -e \
|
scripts/intprefix.out: pnglibconf.h
|
||||||
's|^.*PNG_FUNCTION_EXPORT[ ]*\([$(AN)]*\).*$$|$(SYMBOL_PREFIX)\1|p' \
|
|
||||||
-e 's|^.*PNG_DATA_EXPORT[ ]*\([$(AN)]*\).*$$|$(SYMBOL_PREFIX)\1|p' \
|
|
||||||
>$@.new
|
|
||||||
mv $@.new $@
|
|
||||||
|
|
||||||
libpng.vers: libpng.sym
|
libpng.sym: scripts/sym.out
|
||||||
rm -f $@ $@.new
|
rm -f $@
|
||||||
echo PNG@PNGLIB_MAJOR@@PNGLIB_MINOR@_0 '{global:' > $@.new
|
cp $? $@
|
||||||
$(SED) s/$$/\;/ libpng.sym >> $@.new
|
libpng.vers: scripts/vers.out
|
||||||
echo 'local: *; };' >> $@.new
|
rm -f $@
|
||||||
mv $@.new $@
|
cp $? $@
|
||||||
|
|
||||||
test: check
|
if DO_PNG_PREFIX
|
||||||
|
# Rename functions in scripts/prefix.out with a PNG_PREFIX prefix.
|
||||||
|
# Rename macros in scripts/macro.lst from PNG_PREFIXpng_ to PNG_ (the actual
|
||||||
|
# implementation of the macro).
|
||||||
|
pnglibconf.h: pnglibconf.out scripts/prefix.out scripts/macro.lst
|
||||||
|
rm -f $@
|
||||||
|
$(AWK) 's==0 && NR>1{print prev}\
|
||||||
|
s==0{prev=$$0}\
|
||||||
|
s==1{print "#define", $$1, "@PNG_PREFIX@" $$1}\
|
||||||
|
s==2{print "#define @PNG_PREFIX@png_" $$1, "PNG_" $$1}\
|
||||||
|
END{print prev}' s=0 pnglibconf.out s=1 scripts/prefix.out\
|
||||||
|
s=2 ${srcdir}/scripts/macro.lst >pnglibconf.tf8
|
||||||
|
mv pnglibconf.tf8 $@
|
||||||
|
|
||||||
# install the .../include headers as links to the new ones
|
pngprefix.h: scripts/intprefix.out
|
||||||
install-data-hook:
|
rm -f pngprefix.tf1
|
||||||
cd $(DESTDIR)$(includedir); rm -f png.h pngconf.h
|
$(AWK) '{print "#define", $$1, "@PNG_PREFIX@" $$1}' $? >pngprefix.tf1
|
||||||
cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/png.h png.h
|
mv pngprefix.tf1 $@
|
||||||
cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/pngconf.h pngconf.h
|
else
|
||||||
cd $(DESTDIR)$(pkgconfigdir); rm -f libpng.pc
|
pnglibconf.h: pnglibconf.out
|
||||||
cd $(DESTDIR)$(pkgconfigdir); $(LN_S) $(PNGLIB_BASENAME).pc libpng.pc
|
rm -f $@
|
||||||
|
cp $? $@
|
||||||
|
|
||||||
# do evil things to libpng to cause libpng12 to be used
|
pngprefix.h: # is empty
|
||||||
install-exec-hook:
|
:>$@
|
||||||
cd $(DESTDIR)$(bindir); rm -f libpng-config
|
endif
|
||||||
cd $(DESTDIR)$(bindir); $(LN_S) $(PNGLIB_BASENAME)-config libpng-config
|
|
||||||
@set -x;\
|
$(srcdir)/scripts/pnglibconf.h.prebuilt:
|
||||||
cd $(DESTDIR)$(libdir);\
|
@echo "Attempting to build $@" >&2
|
||||||
for ext in a la so sl dylib; do\
|
@echo "This is a machine generated file, but if you want to make" >&2
|
||||||
rm -f libpng.$$ext;\
|
@echo "a new one simply make 'scripts/pnglibconf.out', copy that" >&2
|
||||||
if test -f $(PNGLIB_BASENAME).$$ext; then\
|
@echo "AND set PNG_ZLIB_VERNUM to 0 (you MUST do this)" >&2
|
||||||
$(LN_S) $(PNGLIB_BASENAME).$$ext libpng.$$ext;\
|
@exit 1
|
||||||
fi;\
|
|
||||||
|
# The following is necessary to ensure that the local pnglibconf.h is used, not
|
||||||
|
# an installed one (this can happen immediately after on a clean system if
|
||||||
|
# 'make test' is the first thing the user does.) Only files which include
|
||||||
|
# one of the png source files (typically png.h or pngpriv.h) need to be listed
|
||||||
|
# here:
|
||||||
|
pngtest.o: pnglibconf.h
|
||||||
|
|
||||||
|
contrib/libtests/makepng.o: pnglibconf.h
|
||||||
|
contrib/libtests/pngstest.o: pnglibconf.h
|
||||||
|
contrib/libtests/pngunknown.o: pnglibconf.h
|
||||||
|
contrib/libtests/pngimage.o: pnglibconf.h
|
||||||
|
contrib/libtests/pngvalid.o: pnglibconf.h
|
||||||
|
contrib/libtests/readpng.o: pnglibconf.h
|
||||||
|
contrib/libtests/tarith.o: pnglibconf.h
|
||||||
|
contrib/libtests/timepng.o: pnglibconf.h
|
||||||
|
|
||||||
|
contrib/tools/makesRGB.o: pnglibconf.h
|
||||||
|
contrib/tools/pngfix.o: pnglibconf.h
|
||||||
|
contrib/tools/pngcp.o: pnglibconf.h
|
||||||
|
|
||||||
|
# We must use -DPNG_NO_USE_READ_MACROS here even when the library may actually
|
||||||
|
# be built with PNG_USE_READ_MACROS; this prevents the read macros from
|
||||||
|
# interfering with the symbol file format.
|
||||||
|
SYMBOL_CFLAGS = -DPNGLIB_LIBNAME='PNG@PNGLIB_MAJOR@@PNGLIB_MINOR@_0'\
|
||||||
|
-DPNGLIB_VERSION='@PNGLIB_VERSION@'\
|
||||||
|
-DSYMBOL_PREFIX='$(SYMBOL_PREFIX)'\
|
||||||
|
-DPNG_NO_USE_READ_MACROS -DPNG_BUILDING_SYMBOL_TABLE
|
||||||
|
|
||||||
|
if DO_PNG_PREFIX
|
||||||
|
SYMBOL_CFLAGS += -DPNG_PREFIX='@PNG_PREFIX@'
|
||||||
|
endif
|
||||||
|
|
||||||
|
.c.out:
|
||||||
|
rm -f $@ $*.tf[12]
|
||||||
|
test -d scripts || mkdir scripts || test -d scripts
|
||||||
|
$(DFNCPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)\
|
||||||
|
$(CPPFLAGS) $(SYMBOL_CFLAGS) $< > $*.tf1
|
||||||
|
$(AWK) -f "${srcdir}/scripts/dfn.awk" out="$*.tf2" $*.tf1 1>&2
|
||||||
|
rm -f $*.tf1
|
||||||
|
mv $*.tf2 $@
|
||||||
|
|
||||||
|
# The .c file for pnglibconf.h is machine generated
|
||||||
|
pnglibconf.c: scripts/pnglibconf.dfa scripts/options.awk pngconf.h pngusr.dfa $(DFA_XTRA)
|
||||||
|
rm -f $@ $*.tf[45]
|
||||||
|
$(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf4 version=search\
|
||||||
|
${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\
|
||||||
|
${srcdir}/pngusr.dfa $(DFA_XTRA) 1>&2
|
||||||
|
$(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf5 $*.tf4 1>&2
|
||||||
|
rm $*.tf4
|
||||||
|
mv $*.tf5 $@
|
||||||
|
|
||||||
|
# Symbol checks (.def and .out files should match)
|
||||||
|
scripts/symbols.chk: scripts/checksym.awk scripts/symbols.def scripts/symbols.out
|
||||||
|
|
||||||
|
.out.chk:
|
||||||
|
rm -f $@ $*.new
|
||||||
|
$(AWK) -f ${srcdir}/scripts/checksym.awk ${srcdir}/scripts/${*F}.def\
|
||||||
|
of="$*.new" $< >&2
|
||||||
|
mv $*.new $@
|
||||||
|
|
||||||
|
# used on demand to regenerate the standard header, CPPFLAGS should
|
||||||
|
# be empty - no non-standard defines
|
||||||
|
scripts/pnglibconf.c: scripts/pnglibconf.dfa scripts/options.awk pngconf.h
|
||||||
|
rm -f $@ pnglibconf.tf[67]
|
||||||
|
test -z "$(CPPFLAGS)"
|
||||||
|
echo "com @PNGLIB_VERSION@ STANDARD API DEFINITION" |\
|
||||||
|
$(AWK) -f ${srcdir}/scripts/options.awk out=pnglibconf.tf6\
|
||||||
|
logunsupported=1 version=search ${srcdir}/pngconf.h -\
|
||||||
|
${srcdir}/scripts/pnglibconf.dfa 1>&2
|
||||||
|
$(AWK) -f ${srcdir}/scripts/options.awk out=pnglibconf.tf7\
|
||||||
|
pnglibconf.tf6 1>&2
|
||||||
|
rm pnglibconf.tf6
|
||||||
|
mv pnglibconf.tf7 $@
|
||||||
|
|
||||||
|
$(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS): png.h pngconf.h \
|
||||||
|
pnglibconf.h pngpriv.h pngdebug.h pnginfo.h pngstruct.h pngprefix.h
|
||||||
|
|
||||||
|
test: check-am
|
||||||
|
|
||||||
|
# Extra checks
|
||||||
|
check: scripts/symbols.chk
|
||||||
|
|
||||||
|
# Don't distribute the generated script files
|
||||||
|
dist-hook:
|
||||||
|
cd '$(top_distdir)'; rm -f $(SCRIPT_CLEANFILES)
|
||||||
|
|
||||||
|
# Make links between installed files with release-specific names and the generic
|
||||||
|
# file names. If this install rule is run the generic names will be deleted and
|
||||||
|
# recreated - this has obvious issues for systems with multiple installations.
|
||||||
|
|
||||||
|
install-header-links:
|
||||||
|
@set -ex; cd '$(DESTDIR)$(includedir)'; for f in $(HEADERS); do \
|
||||||
|
rm -f "$$f"; $(LN_S) "$(PNGLIB_BASENAME)/$$f" "$$f"; done
|
||||||
|
|
||||||
|
uninstall-header-links:
|
||||||
|
cd '$(DESTDIR)$(includedir)'; rm -f $(HEADERS)
|
||||||
|
|
||||||
|
install-libpng-pc:
|
||||||
|
@set -ex; cd '$(DESTDIR)$(pkgconfigdir)'; rm -f libpng.pc; \
|
||||||
|
$(LN_S) '$(PNGLIB_BASENAME).pc' libpng.pc
|
||||||
|
|
||||||
|
uninstall-libpng-pc:
|
||||||
|
rm -f '$(DESTDIR)$(pkgconfigdir)/libpng.pc'
|
||||||
|
|
||||||
|
# EXT_LIST is a list of the possibly library directory extensions, this exists
|
||||||
|
# because we can't find a good way of discovering the file extensions that are
|
||||||
|
# actually installed on a given system, so instead we check for every extension
|
||||||
|
# we have seen.
|
||||||
|
|
||||||
|
EXT_LIST = a dll.a so so.@PNGLIB_MAJOR@@PNGLIB_MINOR@.@PNGLIB_RELEASE@ la sl dylib
|
||||||
|
|
||||||
|
install-library-links:
|
||||||
|
@set -x; cd '$(DESTDIR)$(libdir)';\
|
||||||
|
for ext in $(EXT_LIST); do\
|
||||||
|
rm -f "libpng.$$ext";\
|
||||||
|
if test -f "$(PNGLIB_BASENAME).$$ext"; then\
|
||||||
|
$(LN_S) "$(PNGLIB_BASENAME).$$ext" "libpng.$$ext" || exit 1;\
|
||||||
|
fi;\
|
||||||
done
|
done
|
||||||
|
|
||||||
uninstall-hook:
|
uninstall-library-links:
|
||||||
cd $(DESTDIR)$(includedir); rm -f png.h pngconf.h
|
@set -x; cd '$(DESTDIR)$(libdir)'; for ext in $(EXT_LIST); do\
|
||||||
rm -f $(DESTDIR)$(pkgconfigdir)/libpng.pc
|
rm -f "libpng.$$ext"; done
|
||||||
rm -f $(DESTDIR)$(bindir)/libpng-config
|
|
||||||
@if test -n "@compatlib@"; then\
|
install-libpng-config:
|
||||||
set -x;\
|
@set -ex; cd '$(DESTDIR)$(bindir)'; rm -f libpng-config; \
|
||||||
cd $(DESTDIR)$(libdir);\
|
$(LN_S) '$(PNGLIB_BASENAME)-config' libpng-config
|
||||||
for ext in a la so sl dylib; do\
|
|
||||||
rm -f libpng.$$ext;\
|
uninstall-libpng-config:
|
||||||
done;\
|
rm -f '$(DESTDIR)$(bindir)/libpng-config'
|
||||||
fi
|
|
||||||
|
if DO_INSTALL_LINKS
|
||||||
|
# If --enable-unversioned-links is specified the header and lib file links
|
||||||
|
# will be automatically made on a 'make install':
|
||||||
|
|
||||||
|
install-data-hook: install-header-links
|
||||||
|
uninstall-hook: uninstall-header-links
|
||||||
|
install-exec-hook: install-library-links
|
||||||
|
uninstall-hook: uninstall-library-links
|
||||||
|
endif
|
||||||
|
|
||||||
|
if DO_INSTALL_LIBPNG_PC
|
||||||
|
# Likewise, --install-pc causes libpng.pc to be constructed:
|
||||||
|
|
||||||
|
install-data-hook: install-libpng-pc
|
||||||
|
uninstall-hook: uninstall-libpng-pc
|
||||||
|
endif
|
||||||
|
|
||||||
|
if DO_INSTALL_LIBPNG_CONFIG
|
||||||
|
# And --install-config:
|
||||||
|
|
||||||
|
install-exec-hook: install-libpng-config
|
||||||
|
uninstall-hook: uninstall-libpng-config
|
||||||
|
endif
|
||||||
|
|
||||||
|
# The following addition ensures that 'make all' always builds the test programs
|
||||||
|
# too. It used to, but some change either in libpng or configure stopped this
|
||||||
|
# working.
|
||||||
|
all-am: $(check_PROGRAMS)
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,19 +1,16 @@
|
||||||
README for libpng version 1.2.46 - July 9, 2011 (shared library 12.0)
|
README for libpng version 1.6.37 - April 14, 2019
|
||||||
See the note about version numbers near the top of png.h
|
=================================================
|
||||||
|
|
||||||
|
See the note about version numbers near the top of png.h.
|
||||||
See INSTALL for instructions on how to install libpng.
|
See INSTALL for instructions on how to install libpng.
|
||||||
|
|
||||||
Libpng comes in several distribution formats. Get libpng-*.tar.gz,
|
Libpng comes in several distribution formats. Get libpng-*.tar.gz or
|
||||||
libpng-*.tar.xz, or libpng-*.tar.bz2 if you want UNIX-style line
|
libpng-*.tar.xz or if you want UNIX-style line endings in the text
|
||||||
endings in the text files, or lpng*.7z or lpng*.zip if you want DOS-style
|
files, or lpng*.7z or lpng*.zip if you want DOS-style line endings.
|
||||||
line endings. You can get UNIX-style line endings from the *.zip file
|
|
||||||
by using "unzip -a" but there seems to be no simple way to recover
|
|
||||||
UNIX-style line endings from the *.7z file. The *.tar.xz file is
|
|
||||||
recommended for *NIX users instead.
|
|
||||||
|
|
||||||
Version 0.89 was the first official release of libpng. Don't let the
|
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
|
fact that it's the first release fool you. The libpng library has been
|
||||||
extensive use and testing since mid-1995. By late 1997 it had
|
in extensive use and testing since mid-1995. By late 1997 it had
|
||||||
finally gotten to the stage where there hadn't been significant
|
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
|
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
|
libraries with versions < 1.0. Version 1.0.0 was released in
|
||||||
|
@ -27,18 +24,25 @@ earlier versions if you are using a shared library. The type of the
|
||||||
png_uint_32, which will affect shared-library applications that use
|
png_uint_32, which will affect shared-library applications that use
|
||||||
this function.
|
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
|
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
|
access to info_ptr. These functions are the png_set_<chunk> and
|
||||||
png_get_<chunk> functions. These functions should be used when
|
png_get_<chunk> functions. These functions should be used when
|
||||||
accessing/storing the info_struct data, rather than manipulating it
|
accessing/storing the info_struct data, rather than manipulating it
|
||||||
directly, to avoid such problems in the future.
|
directly, to avoid such problems in the future.
|
||||||
|
|
||||||
It is important to note that the APIs do not make current programs
|
It is important to note that the APIs did not make current programs
|
||||||
that access the info struct directly incompatible with the new
|
that access the info struct directly incompatible with the new
|
||||||
library. However, it is strongly suggested that new programs use
|
library, through libpng-1.2.x. In libpng-1.4.x, which was meant to
|
||||||
the new APIs (as shown in example.c and pngtest.c), and older programs
|
be a transitional release, members of the png_struct and the
|
||||||
be converted to the new format, to facilitate upgrades in the future.
|
info_struct can still be accessed, but the compiler will issue a
|
||||||
|
warning about deprecated usage. Since libpng-1.5.0, direct access
|
||||||
|
to these structs is not allowed, and the definitions of the structs
|
||||||
|
reside in private pngstruct.h and pnginfo.h header files that are not
|
||||||
|
accessible to applications. It is strongly suggested that new
|
||||||
|
programs use the new APIs (as shown in example.c and pngtest.c), and
|
||||||
|
older programs be converted to the new format, to facilitate upgrades
|
||||||
|
in the future.
|
||||||
****
|
****
|
||||||
|
|
||||||
Additions since 0.90 include the ability to compile libpng as a
|
Additions since 0.90 include the ability to compile libpng as a
|
||||||
|
@ -57,101 +61,71 @@ 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
|
to set different actions based on whether the CRC error occurred in a
|
||||||
critical or an ancillary chunk.
|
critical or an ancillary chunk.
|
||||||
|
|
||||||
The changes made to the library, and bugs fixed are based on discussions
|
For a detailed description on using libpng, read libpng-manual.txt.
|
||||||
on the png-mng-implement mailing list and not on material submitted
|
For examples of libpng in a program, see example.c and pngtest.c. For
|
||||||
privately to Guy, Andreas, or Glenn. They will forward any good
|
usage information and restrictions (what little they are) on libpng,
|
||||||
suggestions to the list.
|
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.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
|
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
|
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 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
|
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
|
some images.
|
||||||
taking advantage of the MS-DOS "far" structure allocation for the small
|
|
||||||
and medium memory models. You should also note that zlib is a
|
You should also note that zlib is a compression library that is useful
|
||||||
compression library that is useful for more things than just PNG files.
|
for more things than just PNG files. You can use zlib as a drop-in
|
||||||
You can use zlib as a drop-in replacement for fread() and fwrite() if
|
replacement for fread() and fwrite(), if you are so inclined.
|
||||||
you are so inclined.
|
|
||||||
|
|
||||||
zlib should be available at the same place that libpng is, or at
|
zlib should be available at the same place that libpng is, or at
|
||||||
ftp://ftp.simplesystems.org/pub/png/src/
|
https://zlib.net.
|
||||||
|
|
||||||
You may also want a copy of the PNG specification. It is available
|
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
|
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
|
||||||
these at http://www.libpng.org/pub/png/pngdocs.html
|
these at http://www.libpng.org/pub/png/pngdocs.html .
|
||||||
|
|
||||||
This code is currently being archived at libpng.sf.net in the
|
This code is currently being archived at libpng.sourceforge.io in the
|
||||||
[DOWNLOAD] area, and on CompuServe, Lib 20 (PNG SUPPORT)
|
[DOWNLOAD] area, and at http://libpng.download/src .
|
||||||
at GO GRAPHSUP. If you can't find it in any of those places,
|
|
||||||
e-mail me, and I'll help you find it.
|
|
||||||
|
|
||||||
If you have any code changes, requests, problems, etc., please e-mail
|
This release, based in a large way on Glenn's, Guy's and Andreas'
|
||||||
them to me. Also, I'd appreciate any make files or project files,
|
earlier work, was created and will be supported by myself and the PNG
|
||||||
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
|
|
||||||
development group.
|
development group.
|
||||||
|
|
||||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
Send comments/corrections/commendations to png-mng-implement at
|
||||||
(subscription required; visit
|
lists.sourceforge.net (subscription required; visit
|
||||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
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
|
Send general questions about the PNG specification to png-mng-misc
|
||||||
given in previous versions of this document. He and Andreas will
|
at lists.sourceforge.net (subscription required; visit
|
||||||
read mail addressed to the png-mng-implement list, however.
|
|
||||||
|
|
||||||
Please do not send general questions about PNG. Send them to
|
|
||||||
the (png-mng-misc at lists.sourceforge.net, subscription required, visit
|
|
||||||
https://lists.sourceforge.net/lists/listinfo/png-mng-misc to
|
https://lists.sourceforge.net/lists/listinfo/png-mng-misc to
|
||||||
subscribe). On the other hand, please do not send libpng questions to
|
subscribe).
|
||||||
that address, send them to me or to the png-mng-implement list. I'll
|
|
||||||
get them in the end anyway. 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 twelve 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.
|
|
||||||
|
|
||||||
Files in this distribution:
|
Files in this distribution:
|
||||||
|
|
||||||
ANNOUNCE => Announcement of this version, with recent changes
|
ANNOUNCE => Announcement of this version, with recent changes
|
||||||
|
AUTHORS => List of contributing authors
|
||||||
CHANGES => Description of changes between libpng versions
|
CHANGES => Description of changes between libpng versions
|
||||||
KNOWNBUG => List of known bugs and deficiencies
|
KNOWNBUG => List of known bugs and deficiencies
|
||||||
LICENSE => License to use and redistribute libpng
|
LICENSE => License to use and redistribute libpng
|
||||||
README => This file
|
README => This file
|
||||||
TODO => Things not implemented in the current library
|
TODO => Things not implemented in the current library
|
||||||
Y2KINFO => Statement of Y2K compliance
|
TRADEMARK => Trademark information
|
||||||
example.c => Example code for using libpng functions
|
example.c => Example code for using libpng functions
|
||||||
libpng-*-*-diff.txt => Diff from previous release
|
libpng.3 => manual page for libpng (includes libpng-manual.txt)
|
||||||
libpng.3 => manual page for libpng (includes libpng.txt)
|
libpng-manual.txt => Description of libpng and its functions
|
||||||
libpng.txt => Description of libpng and its functions
|
|
||||||
libpngpf.3 => manual page for libpng's private functions
|
libpngpf.3 => manual page for libpng's private functions
|
||||||
png.5 => manual page for the PNG format
|
png.5 => manual page for the PNG format
|
||||||
png.c => Basic interface functions common to library
|
png.c => Basic interface functions common to library
|
||||||
png.h => Library function and interface declarations
|
png.h => Library function and interface declarations (public)
|
||||||
pngconf.h => System specific library configuration
|
pngpriv.h => Library function and interface declarations (private)
|
||||||
|
pngconf.h => System specific library configuration (public)
|
||||||
|
pngstruct.h => png_struct declaration (private)
|
||||||
|
pnginfo.h => png_info struct declaration (private)
|
||||||
|
pngdebug.h => debugging macros (private)
|
||||||
pngerror.c => Error/warning message I/O functions
|
pngerror.c => Error/warning message I/O functions
|
||||||
pngget.c => Functions for retrieving info from struct
|
pngget.c => Functions for retrieving info from struct
|
||||||
pngmem.c => Memory handling functions
|
pngmem.c => Memory handling functions
|
||||||
|
@ -170,106 +144,40 @@ Files in this distribution:
|
||||||
pngwrite.c => High-level write functions
|
pngwrite.c => High-level write functions
|
||||||
pngwtran.c => Write data transformations
|
pngwtran.c => Write data transformations
|
||||||
pngwutil.c => Write utility functions
|
pngwutil.c => Write utility functions
|
||||||
|
arm => Contains optimized code for the ARM platform
|
||||||
|
powerpc => Contains optimized code for the PowerPC platform
|
||||||
contrib => Contributions
|
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
|
gregbook => source code for PNG reading and writing, from
|
||||||
Greg Roelofs' "PNG: The Definitive Guide",
|
Greg Roelofs' "PNG: The Definitive Guide",
|
||||||
O'Reilly, 1999
|
O'Reilly, 1999
|
||||||
msvctest => Builds and runs pngtest using a MSVC workspace
|
libtests => Test programs
|
||||||
pngminim => Simple pnm2pngm and png2pnmm programs
|
mips-msa => Optimized code for MIPS-MSA platform
|
||||||
pngminus => Simple pnm2png and png2pnm programs
|
pngminim => Minimal decoder, encoder, and progressive decoder
|
||||||
pngsuite => Test images
|
programs demonstrating use of pngusr.dfa
|
||||||
visupng => Contains a MSVC workspace for VisualPng
|
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
|
projects => Contains project files and workspaces for
|
||||||
building a DLL
|
building a DLL
|
||||||
beos => Contains a Beos workspace for building libpng
|
owatcom => Contains a WATCOM project for building libpng
|
||||||
c5builder => Contains a Borland workspace for building
|
visualc71 => Contains a Microsoft Visual C++ (MSVC)
|
||||||
libpng and zlib
|
workspace for building libpng and zlib
|
||||||
netware.txt => Contains instructions for downloading a set
|
vstudio => Contains a Microsoft Visual C++ (MSVC)
|
||||||
of project files for building libpng and
|
|
||||||
zlib on Netware.
|
|
||||||
visualc6 => Contains a Microsoft Visual C++ (MSVC)
|
|
||||||
workspace for building libpng and zlib
|
workspace for building libpng and zlib
|
||||||
wince.txt => Contains instructions for downloading a
|
|
||||||
Microsoft Visual C++ (Windows CD Toolkit)
|
|
||||||
workspace for building libpng and zlib on
|
|
||||||
WindowsCE
|
|
||||||
xcode => Contains xcode project files
|
|
||||||
scripts => Directory containing scripts for building libpng:
|
scripts => Directory containing scripts for building libpng:
|
||||||
descrip.mms => VMS makefile for MMS or MMK
|
(see scripts/README.txt for the list of scripts)
|
||||||
makefile.std => Generic UNIX makefile (cc, creates static
|
|
||||||
libpng.a)
|
|
||||||
makefile.elf => Linux/ELF gcc makefile symbol versioning,
|
|
||||||
creates libpng12.so.0.1.2.46)
|
|
||||||
makefile.linux => Linux/ELF makefile (gcc, creates
|
|
||||||
libpng12.so.0.1.2.46)
|
|
||||||
makefile.gcmmx => Linux/ELF makefile (gcc, creates
|
|
||||||
libpng12.so.0.1.2.46, previously
|
|
||||||
used assembler code tuned for Intel MMX
|
|
||||||
platform)
|
|
||||||
makefile.gcc => Generic makefile (gcc, creates static
|
|
||||||
libpng.a)
|
|
||||||
makefile.knr => Archaic UNIX Makefile that converts files
|
|
||||||
with ansi2knr (Requires ansi2knr.c from
|
|
||||||
ftp://ftp.cs.wisc.edu/ghost)
|
|
||||||
makefile.aix => AIX makefile
|
|
||||||
makefile.cygwin => Cygwin/gcc makefile
|
|
||||||
makefile.darwin => Darwin makefile
|
|
||||||
makefile.dec => DEC Alpha UNIX makefile
|
|
||||||
makefile.freebsd => FreeBSD makefile
|
|
||||||
makefile.hpgcc => HPUX makefile using gcc
|
|
||||||
makefile.hpux => HPUX (10.20 and 11.00) makefile
|
|
||||||
makefile.hp64 => HPUX (10.20 and 11.00) makefile, 64 bit
|
|
||||||
makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2
|
|
||||||
(static)
|
|
||||||
makefile.intel => Intel C/C++ version 4.0 and later
|
|
||||||
libpng.icc => Project file, IBM VisualAge/C++ 4.0 or later
|
|
||||||
makefile.netbsd => NetBSD/cc makefile, makes libpng.so.
|
|
||||||
makefile.ne12bsd => NetBSD/cc makefile, makes libpng12.so
|
|
||||||
makefile.openbsd => OpenBSD makefile
|
|
||||||
makefile.sgi => Silicon Graphics IRIX (cc, creates static lib)
|
|
||||||
makefile.sggcc => Silicon Graphics
|
|
||||||
(gcc, creates libpng12.so.0.1.2.46)
|
|
||||||
makefile.sunos => Sun makefile
|
|
||||||
makefile.solaris => Solaris 2.X makefile
|
|
||||||
(gcc, creates libpng12.so.0.1.2.46)
|
|
||||||
makefile.so9 => Solaris 9 makefile
|
|
||||||
(gcc, creates libpng12.so.0.1.2.46)
|
|
||||||
makefile.32sunu => Sun Ultra 32-bit makefile
|
|
||||||
makefile.64sunu => Sun Ultra 64-bit makefile
|
|
||||||
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
|
|
||||||
makefile.mips => MIPS makefile
|
|
||||||
makefile.acorn => Acorn makefile
|
|
||||||
makefile.amiga => Amiga makefile
|
|
||||||
smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC
|
|
||||||
compiler (Requires SCOPTIONS, copied from
|
|
||||||
scripts/SCOPTIONS.ppc)
|
|
||||||
makefile.atari => Atari makefile
|
|
||||||
makefile.beos => BEOS makefile for X86
|
|
||||||
makefile.bor => Borland makefile (uses bcc)
|
|
||||||
makefile.bc32 => 32-bit Borland C++ (all modules compiled in C mode)
|
|
||||||
makefile.tc3 => Turbo C 3.0 makefile
|
|
||||||
makefile.dj2 => DJGPP 2 makefile
|
|
||||||
makefile.msc => Microsoft C makefile
|
|
||||||
makefile.vcawin32=> makefile for Microsoft Visual C++ 5.0 and
|
|
||||||
later (previously used assembler code tuned
|
|
||||||
for Intel MMX platform)
|
|
||||||
makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and
|
|
||||||
later (does not use assembler code)
|
|
||||||
makefile.os2 => OS/2 Makefile (gcc and emx, requires pngos2.def)
|
|
||||||
pngos2.def => OS/2 module definition file used by makefile.os2
|
|
||||||
makefile.watcom => Watcom 10a+ Makefile, 32-bit flat memory model
|
|
||||||
makevms.com => VMS build script
|
|
||||||
SCOPTIONS.ppc => Used with smakefile.ppc
|
|
||||||
|
|
||||||
Good luck, and happy coding.
|
Good luck, and happy coding!
|
||||||
|
|
||||||
-Glenn Randers-Pehrson (current maintainer, since 1998)
|
* Cosmin Truta (current maintainer, since 2018)
|
||||||
Internet: glennrp at users.sourceforge.net
|
* Glenn Randers-Pehrson (former maintainer, 1998-2018)
|
||||||
|
* Andreas Eric Dilger (former maintainer, 1996-1997)
|
||||||
-Andreas Eric Dilger (former maintainer, 1996-1997)
|
* Guy Eric Schalnat (original author and former maintainer, 1995-1996)
|
||||||
Internet: adilger at enel.ucalgary.ca
|
(formerly of Group 42, Inc.)
|
||||||
Web: http://members.shaw.ca/adilger/
|
|
||||||
|
|
||||||
-Guy Eric Schalnat (original author and former maintainer, 1995-1996)
|
|
||||||
(formerly of Group 42, Inc)
|
|
||||||
Internet: gschal at infinet.com
|
|
||||||
|
|
|
@ -1,25 +1,23 @@
|
||||||
TODO - list of things to do for libpng:
|
TODO - list of things to do for libpng:
|
||||||
|
|
||||||
Final bug fixes.
|
* Fix all defects (duh!)
|
||||||
Improve API by hiding the png_struct and png_info structs.
|
* Better C++ wrapper / full C++ implementation (?)
|
||||||
Finish work on the no-floating-point version (including gamma compensation)
|
* Fix the problems with C++ and 'extern "C"'.
|
||||||
Better C++ wrapper/full C++ implementation?
|
* cHRM transformation.
|
||||||
Fix problem with C++ and EXTERN "C".
|
* Palette creation.
|
||||||
cHRM transformation.
|
* "grayscale->palette" transformation and "palette->grayscale" detection.
|
||||||
Improve setjmp/longjmp usage or remove it in favor of returning error codes.
|
* Improved dithering.
|
||||||
Add "grayscale->palette" transformation and "palette->grayscale" detection.
|
* Multi-lingual error and warning message support.
|
||||||
Improved dithering.
|
* Complete sRGB transformation. (Currently it simply uses gamma=0.45455.)
|
||||||
Multi-lingual error and warning message support.
|
* Man pages for function calls.
|
||||||
Complete sRGB transformation (presently it simply uses gamma=0.45455).
|
* Better documentation.
|
||||||
Man pages for function calls.
|
* Better filter selection
|
||||||
Better documentation.
|
(e.g., counting huffman bits/precompression; filter inertia; filter costs).
|
||||||
Better filter selection
|
* Histogram creation.
|
||||||
(counting huffman bits/precompression? filter inertia? filter costs?).
|
* Text conversion between different code pages (e.g., Latin-1 -> Mac).
|
||||||
Histogram creation.
|
* Avoid building gamma tables whenever possible.
|
||||||
Text conversion between different code pages (Latin-1 -> Mac and DOS).
|
* Greater precision in changing to linear gamma for compositing against
|
||||||
Should we always malloc 2^bit_depth PLTE/tRNS/hIST entries for safety?
|
background, and in doing rgb-to-gray transformations.
|
||||||
Build gamma tables using fixed point (and do away with floating point entirely).
|
* Investigate pre-incremented loop counters and other loop constructions.
|
||||||
Use greater precision when changing to linear gamma for compositing against
|
* Interpolated method of handling interlacing.
|
||||||
background and doing rgb-to-gray transformation.
|
* More validations for libpng transformations.
|
||||||
Investigate pre-incremented loop counters and other loop constructions.
|
|
||||||
Add interpolated method of handling interlacing.
|
|
||||||
|
|
8
libs/libpng-src/TRADEMARK
Normal file
8
libs/libpng-src/TRADEMARK
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
TRADEMARK
|
||||||
|
=========
|
||||||
|
|
||||||
|
The name "libpng" has not been registered by the Copyright owners
|
||||||
|
as a trademark in any jurisdiction. However, because libpng has
|
||||||
|
been distributed and maintained world-wide, continually since 1995,
|
||||||
|
the Copyright owners claim "common-law trademark protection" in any
|
||||||
|
jurisdiction where common-law trademark is recognized.
|
8835
libs/libpng-src/aclocal.m4
vendored
8835
libs/libpng-src/aclocal.m4
vendored
File diff suppressed because it is too large
Load diff
136
libs/libpng-src/arm/arm_init.c
Normal file
136
libs/libpng-src/arm/arm_init.c
Normal file
|
@ -0,0 +1,136 @@
|
||||||
|
|
||||||
|
/* arm_init.c - NEON optimised filter functions
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018 Cosmin Truta
|
||||||
|
* Copyright (c) 2014,2016 Glenn Randers-Pehrson
|
||||||
|
* Written by Mans Rullgard, 2011.
|
||||||
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Below, after checking __linux__, various non-C90 POSIX 1003.1 functions are
|
||||||
|
* called.
|
||||||
|
*/
|
||||||
|
#define _POSIX_SOURCE 1
|
||||||
|
|
||||||
|
#include "../pngpriv.h"
|
||||||
|
|
||||||
|
#ifdef PNG_READ_SUPPORTED
|
||||||
|
|
||||||
|
#if PNG_ARM_NEON_OPT > 0
|
||||||
|
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED /* Do run-time checks */
|
||||||
|
/* WARNING: it is strongly recommended that you do not build libpng with
|
||||||
|
* run-time checks for CPU features if at all possible. In the case of the ARM
|
||||||
|
* NEON instructions there is no processor-specific way of detecting the
|
||||||
|
* presence of the required support, therefore run-time detection is extremely
|
||||||
|
* OS specific.
|
||||||
|
*
|
||||||
|
* You may set the macro PNG_ARM_NEON_FILE to the file name of file containing
|
||||||
|
* a fragment of C source code which defines the png_have_neon function. There
|
||||||
|
* are a number of implementations in contrib/arm-neon, but the only one that
|
||||||
|
* has partial support is contrib/arm-neon/linux.c - a generic Linux
|
||||||
|
* implementation which reads /proc/cpufino.
|
||||||
|
*/
|
||||||
|
#ifndef PNG_ARM_NEON_FILE
|
||||||
|
# ifdef __linux__
|
||||||
|
# define PNG_ARM_NEON_FILE "contrib/arm-neon/linux.c"
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_ARM_NEON_FILE
|
||||||
|
|
||||||
|
#include <signal.h> /* for sig_atomic_t */
|
||||||
|
static int png_have_neon(png_structp png_ptr);
|
||||||
|
#include PNG_ARM_NEON_FILE
|
||||||
|
|
||||||
|
#else /* PNG_ARM_NEON_FILE */
|
||||||
|
# error "PNG_ARM_NEON_FILE undefined: no support for run-time ARM NEON checks"
|
||||||
|
#endif /* PNG_ARM_NEON_FILE */
|
||||||
|
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
|
||||||
|
|
||||||
|
#ifndef PNG_ALIGNED_MEMORY_SUPPORTED
|
||||||
|
# error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void
|
||||||
|
png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
|
||||||
|
{
|
||||||
|
/* The switch statement is compiled in for ARM_NEON_API, the call to
|
||||||
|
* png_have_neon is compiled in for ARM_NEON_CHECK. If both are defined
|
||||||
|
* the check is only performed if the API has not set the NEON option on
|
||||||
|
* or off explicitly. In this case the check controls what happens.
|
||||||
|
*
|
||||||
|
* If the CHECK is not compiled in and the option is UNSET the behavior prior
|
||||||
|
* to 1.6.7 was to use the NEON code - this was a bug caused by having the
|
||||||
|
* wrong order of the 'ON' and 'default' cases. UNSET now defaults to OFF,
|
||||||
|
* as documented in png.h
|
||||||
|
*/
|
||||||
|
png_debug(1, "in png_init_filter_functions_neon");
|
||||||
|
#ifdef PNG_ARM_NEON_API_SUPPORTED
|
||||||
|
switch ((pp->options >> PNG_ARM_NEON) & 3)
|
||||||
|
{
|
||||||
|
case PNG_OPTION_UNSET:
|
||||||
|
/* Allow the run-time check to execute if it has been enabled -
|
||||||
|
* thus both API and CHECK can be turned on. If it isn't supported
|
||||||
|
* this case will fall through to the 'default' below, which just
|
||||||
|
* returns.
|
||||||
|
*/
|
||||||
|
#endif /* PNG_ARM_NEON_API_SUPPORTED */
|
||||||
|
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED
|
||||||
|
{
|
||||||
|
static volatile sig_atomic_t no_neon = -1; /* not checked */
|
||||||
|
|
||||||
|
if (no_neon < 0)
|
||||||
|
no_neon = !png_have_neon(pp);
|
||||||
|
|
||||||
|
if (no_neon)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#ifdef PNG_ARM_NEON_API_SUPPORTED
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
|
||||||
|
|
||||||
|
#ifdef PNG_ARM_NEON_API_SUPPORTED
|
||||||
|
default: /* OFF or INVALID */
|
||||||
|
return;
|
||||||
|
|
||||||
|
case PNG_OPTION_ON:
|
||||||
|
/* Option turned on */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* IMPORTANT: any new external functions used here must be declared using
|
||||||
|
* PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the
|
||||||
|
* 'prefix' option to configure works:
|
||||||
|
*
|
||||||
|
* ./configure --with-libpng-prefix=foobar_
|
||||||
|
*
|
||||||
|
* Verify you have got this right by running the above command, doing a build
|
||||||
|
* and examining pngprefix.h; it must contain a #define for every external
|
||||||
|
* function you add. (Notice that this happens automatically for the
|
||||||
|
* initialization function.)
|
||||||
|
*/
|
||||||
|
pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_neon;
|
||||||
|
|
||||||
|
if (bpp == 3)
|
||||||
|
{
|
||||||
|
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_neon;
|
||||||
|
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_neon;
|
||||||
|
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
|
||||||
|
png_read_filter_row_paeth3_neon;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (bpp == 4)
|
||||||
|
{
|
||||||
|
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_neon;
|
||||||
|
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_neon;
|
||||||
|
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
|
||||||
|
png_read_filter_row_paeth4_neon;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||||
|
#endif /* READ */
|
253
libs/libpng-src/arm/filter_neon.S
Normal file
253
libs/libpng-src/arm/filter_neon.S
Normal file
|
@ -0,0 +1,253 @@
|
||||||
|
|
||||||
|
/* filter_neon.S - NEON optimised filter functions
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018 Cosmin Truta
|
||||||
|
* Copyright (c) 2014,2017 Glenn Randers-Pehrson
|
||||||
|
* Written by Mans Rullgard, 2011.
|
||||||
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* This is required to get the symbol renames, which are #defines, and the
|
||||||
|
* definitions (or not) of PNG_ARM_NEON_OPT and PNG_ARM_NEON_IMPLEMENTATION.
|
||||||
|
*/
|
||||||
|
#define PNG_VERSION_INFO_ONLY
|
||||||
|
#include "../pngpriv.h"
|
||||||
|
|
||||||
|
#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__ELF__)
|
||||||
|
.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef PNG_READ_SUPPORTED
|
||||||
|
|
||||||
|
/* Assembler NEON support - only works for 32-bit ARM (i.e. it does not work for
|
||||||
|
* ARM64). The code in arm/filter_neon_intrinsics.c supports ARM64, however it
|
||||||
|
* only works if -mfpu=neon is specified on the GCC command line. See pngpriv.h
|
||||||
|
* for the logic which sets PNG_USE_ARM_NEON_ASM:
|
||||||
|
*/
|
||||||
|
#if PNG_ARM_NEON_IMPLEMENTATION == 2 /* hand-coded assembler */
|
||||||
|
|
||||||
|
#if PNG_ARM_NEON_OPT > 0
|
||||||
|
|
||||||
|
#ifdef __ELF__
|
||||||
|
# define ELF
|
||||||
|
#else
|
||||||
|
# define ELF @
|
||||||
|
#endif
|
||||||
|
|
||||||
|
.arch armv7-a
|
||||||
|
.fpu neon
|
||||||
|
|
||||||
|
.macro func name, export=0
|
||||||
|
.macro endfunc
|
||||||
|
ELF .size \name, . - \name
|
||||||
|
.endfunc
|
||||||
|
.purgem endfunc
|
||||||
|
.endm
|
||||||
|
.text
|
||||||
|
|
||||||
|
/* Explicitly specifying alignment here because some versions of
|
||||||
|
* GAS don't align code correctly. This is harmless in correctly
|
||||||
|
* written versions of GAS.
|
||||||
|
*/
|
||||||
|
.align 2
|
||||||
|
|
||||||
|
.if \export
|
||||||
|
.global \name
|
||||||
|
.endif
|
||||||
|
ELF .type \name, STT_FUNC
|
||||||
|
.func \name
|
||||||
|
\name:
|
||||||
|
.endm
|
||||||
|
|
||||||
|
func png_read_filter_row_sub4_neon, export=1
|
||||||
|
ldr r3, [r0, #4] @ rowbytes
|
||||||
|
vmov.i8 d3, #0
|
||||||
|
1:
|
||||||
|
vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128]
|
||||||
|
vadd.u8 d0, d3, d4
|
||||||
|
vadd.u8 d1, d0, d5
|
||||||
|
vadd.u8 d2, d1, d6
|
||||||
|
vadd.u8 d3, d2, d7
|
||||||
|
vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]!
|
||||||
|
subs r3, r3, #16
|
||||||
|
bgt 1b
|
||||||
|
|
||||||
|
bx lr
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func png_read_filter_row_sub3_neon, export=1
|
||||||
|
ldr r3, [r0, #4] @ rowbytes
|
||||||
|
vmov.i8 d3, #0
|
||||||
|
mov r0, r1
|
||||||
|
mov r2, #3
|
||||||
|
mov r12, #12
|
||||||
|
vld1.8 {q11}, [r0], r12
|
||||||
|
1:
|
||||||
|
vext.8 d5, d22, d23, #3
|
||||||
|
vadd.u8 d0, d3, d22
|
||||||
|
vext.8 d6, d22, d23, #6
|
||||||
|
vadd.u8 d1, d0, d5
|
||||||
|
vext.8 d7, d23, d23, #1
|
||||||
|
vld1.8 {q11}, [r0], r12
|
||||||
|
vst1.32 {d0[0]}, [r1,:32], r2
|
||||||
|
vadd.u8 d2, d1, d6
|
||||||
|
vst1.32 {d1[0]}, [r1], r2
|
||||||
|
vadd.u8 d3, d2, d7
|
||||||
|
vst1.32 {d2[0]}, [r1], r2
|
||||||
|
vst1.32 {d3[0]}, [r1], r2
|
||||||
|
subs r3, r3, #12
|
||||||
|
bgt 1b
|
||||||
|
|
||||||
|
bx lr
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func png_read_filter_row_up_neon, export=1
|
||||||
|
ldr r3, [r0, #4] @ rowbytes
|
||||||
|
1:
|
||||||
|
vld1.8 {q0}, [r1,:128]
|
||||||
|
vld1.8 {q1}, [r2,:128]!
|
||||||
|
vadd.u8 q0, q0, q1
|
||||||
|
vst1.8 {q0}, [r1,:128]!
|
||||||
|
subs r3, r3, #16
|
||||||
|
bgt 1b
|
||||||
|
|
||||||
|
bx lr
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func png_read_filter_row_avg4_neon, export=1
|
||||||
|
ldr r12, [r0, #4] @ rowbytes
|
||||||
|
vmov.i8 d3, #0
|
||||||
|
1:
|
||||||
|
vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128]
|
||||||
|
vld4.32 {d16[],d17[],d18[],d19[]},[r2,:128]!
|
||||||
|
vhadd.u8 d0, d3, d16
|
||||||
|
vadd.u8 d0, d0, d4
|
||||||
|
vhadd.u8 d1, d0, d17
|
||||||
|
vadd.u8 d1, d1, d5
|
||||||
|
vhadd.u8 d2, d1, d18
|
||||||
|
vadd.u8 d2, d2, d6
|
||||||
|
vhadd.u8 d3, d2, d19
|
||||||
|
vadd.u8 d3, d3, d7
|
||||||
|
vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]!
|
||||||
|
subs r12, r12, #16
|
||||||
|
bgt 1b
|
||||||
|
|
||||||
|
bx lr
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func png_read_filter_row_avg3_neon, export=1
|
||||||
|
push {r4,lr}
|
||||||
|
ldr r12, [r0, #4] @ rowbytes
|
||||||
|
vmov.i8 d3, #0
|
||||||
|
mov r0, r1
|
||||||
|
mov r4, #3
|
||||||
|
mov lr, #12
|
||||||
|
vld1.8 {q11}, [r0], lr
|
||||||
|
1:
|
||||||
|
vld1.8 {q10}, [r2], lr
|
||||||
|
vext.8 d5, d22, d23, #3
|
||||||
|
vhadd.u8 d0, d3, d20
|
||||||
|
vext.8 d17, d20, d21, #3
|
||||||
|
vadd.u8 d0, d0, d22
|
||||||
|
vext.8 d6, d22, d23, #6
|
||||||
|
vhadd.u8 d1, d0, d17
|
||||||
|
vext.8 d18, d20, d21, #6
|
||||||
|
vadd.u8 d1, d1, d5
|
||||||
|
vext.8 d7, d23, d23, #1
|
||||||
|
vld1.8 {q11}, [r0], lr
|
||||||
|
vst1.32 {d0[0]}, [r1,:32], r4
|
||||||
|
vhadd.u8 d2, d1, d18
|
||||||
|
vst1.32 {d1[0]}, [r1], r4
|
||||||
|
vext.8 d19, d21, d21, #1
|
||||||
|
vadd.u8 d2, d2, d6
|
||||||
|
vhadd.u8 d3, d2, d19
|
||||||
|
vst1.32 {d2[0]}, [r1], r4
|
||||||
|
vadd.u8 d3, d3, d7
|
||||||
|
vst1.32 {d3[0]}, [r1], r4
|
||||||
|
subs r12, r12, #12
|
||||||
|
bgt 1b
|
||||||
|
|
||||||
|
pop {r4,pc}
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
.macro paeth rx, ra, rb, rc
|
||||||
|
vaddl.u8 q12, \ra, \rb @ a + b
|
||||||
|
vaddl.u8 q15, \rc, \rc @ 2*c
|
||||||
|
vabdl.u8 q13, \rb, \rc @ pa
|
||||||
|
vabdl.u8 q14, \ra, \rc @ pb
|
||||||
|
vabd.u16 q15, q12, q15 @ pc
|
||||||
|
vcle.u16 q12, q13, q14 @ pa <= pb
|
||||||
|
vcle.u16 q13, q13, q15 @ pa <= pc
|
||||||
|
vcle.u16 q14, q14, q15 @ pb <= pc
|
||||||
|
vand q12, q12, q13 @ pa <= pb && pa <= pc
|
||||||
|
vmovn.u16 d28, q14
|
||||||
|
vmovn.u16 \rx, q12
|
||||||
|
vbsl d28, \rb, \rc
|
||||||
|
vbsl \rx, \ra, d28
|
||||||
|
.endm
|
||||||
|
|
||||||
|
func png_read_filter_row_paeth4_neon, export=1
|
||||||
|
ldr r12, [r0, #4] @ rowbytes
|
||||||
|
vmov.i8 d3, #0
|
||||||
|
vmov.i8 d20, #0
|
||||||
|
1:
|
||||||
|
vld4.32 {d4[],d5[],d6[],d7[]}, [r1,:128]
|
||||||
|
vld4.32 {d16[],d17[],d18[],d19[]},[r2,:128]!
|
||||||
|
paeth d0, d3, d16, d20
|
||||||
|
vadd.u8 d0, d0, d4
|
||||||
|
paeth d1, d0, d17, d16
|
||||||
|
vadd.u8 d1, d1, d5
|
||||||
|
paeth d2, d1, d18, d17
|
||||||
|
vadd.u8 d2, d2, d6
|
||||||
|
paeth d3, d2, d19, d18
|
||||||
|
vmov d20, d19
|
||||||
|
vadd.u8 d3, d3, d7
|
||||||
|
vst4.32 {d0[0],d1[0],d2[0],d3[0]},[r1,:128]!
|
||||||
|
subs r12, r12, #16
|
||||||
|
bgt 1b
|
||||||
|
|
||||||
|
bx lr
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func png_read_filter_row_paeth3_neon, export=1
|
||||||
|
push {r4,lr}
|
||||||
|
ldr r12, [r0, #4] @ rowbytes
|
||||||
|
vmov.i8 d3, #0
|
||||||
|
vmov.i8 d4, #0
|
||||||
|
mov r0, r1
|
||||||
|
mov r4, #3
|
||||||
|
mov lr, #12
|
||||||
|
vld1.8 {q11}, [r0], lr
|
||||||
|
1:
|
||||||
|
vld1.8 {q10}, [r2], lr
|
||||||
|
paeth d0, d3, d20, d4
|
||||||
|
vext.8 d5, d22, d23, #3
|
||||||
|
vadd.u8 d0, d0, d22
|
||||||
|
vext.8 d17, d20, d21, #3
|
||||||
|
paeth d1, d0, d17, d20
|
||||||
|
vst1.32 {d0[0]}, [r1,:32], r4
|
||||||
|
vext.8 d6, d22, d23, #6
|
||||||
|
vadd.u8 d1, d1, d5
|
||||||
|
vext.8 d18, d20, d21, #6
|
||||||
|
paeth d2, d1, d18, d17
|
||||||
|
vext.8 d7, d23, d23, #1
|
||||||
|
vld1.8 {q11}, [r0], lr
|
||||||
|
vst1.32 {d1[0]}, [r1], r4
|
||||||
|
vadd.u8 d2, d2, d6
|
||||||
|
vext.8 d19, d21, d21, #1
|
||||||
|
paeth d3, d2, d19, d18
|
||||||
|
vst1.32 {d2[0]}, [r1], r4
|
||||||
|
vmov d4, d19
|
||||||
|
vadd.u8 d3, d3, d7
|
||||||
|
vst1.32 {d3[0]}, [r1], r4
|
||||||
|
subs r12, r12, #12
|
||||||
|
bgt 1b
|
||||||
|
|
||||||
|
pop {r4,pc}
|
||||||
|
endfunc
|
||||||
|
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||||
|
#endif /* PNG_ARM_NEON_IMPLEMENTATION == 2 (assembler) */
|
||||||
|
#endif /* READ */
|
402
libs/libpng-src/arm/filter_neon_intrinsics.c
Normal file
402
libs/libpng-src/arm/filter_neon_intrinsics.c
Normal file
|
@ -0,0 +1,402 @@
|
||||||
|
|
||||||
|
/* filter_neon_intrinsics.c - NEON optimised filter functions
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018 Cosmin Truta
|
||||||
|
* Copyright (c) 2014,2016 Glenn Randers-Pehrson
|
||||||
|
* Written by James Yu <james.yu at linaro.org>, October 2013.
|
||||||
|
* Based on filter_neon.S, written by Mans Rullgard, 2011.
|
||||||
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../pngpriv.h"
|
||||||
|
|
||||||
|
#ifdef PNG_READ_SUPPORTED
|
||||||
|
|
||||||
|
/* This code requires -mfpu=neon on the command line: */
|
||||||
|
#if PNG_ARM_NEON_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && defined(_M_ARM64)
|
||||||
|
# include <arm64_neon.h>
|
||||||
|
#else
|
||||||
|
# include <arm_neon.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* libpng row pointers are not necessarily aligned to any particular boundary,
|
||||||
|
* however this code will only work with appropriate alignment. arm/arm_init.c
|
||||||
|
* checks for this (and will not compile unless it is done). This code uses
|
||||||
|
* variants of png_aligncast to avoid compiler warnings.
|
||||||
|
*/
|
||||||
|
#define png_ptr(type,pointer) png_aligncast(type *,pointer)
|
||||||
|
#define png_ptrc(type,pointer) png_aligncastconst(const type *,pointer)
|
||||||
|
|
||||||
|
/* The following relies on a variable 'temp_pointer' being declared with type
|
||||||
|
* 'type'. This is written this way just to hide the GCC strict aliasing
|
||||||
|
* warning; note that the code is safe because there never is an alias between
|
||||||
|
* the input and output pointers.
|
||||||
|
*
|
||||||
|
* When compiling with MSVC ARM64, the png_ldr macro can't be passed directly
|
||||||
|
* to vst4_lane_u32, because of an internal compiler error inside MSVC.
|
||||||
|
* To avoid this compiler bug, we use a temporary variable (vdest_val) to store
|
||||||
|
* the result of png_ldr.
|
||||||
|
*/
|
||||||
|
#define png_ldr(type,pointer)\
|
||||||
|
(temp_pointer = png_ptr(type,pointer), *temp_pointer)
|
||||||
|
|
||||||
|
#if PNG_ARM_NEON_OPT > 0
|
||||||
|
|
||||||
|
void
|
||||||
|
png_read_filter_row_up_neon(png_row_infop row_info, png_bytep row,
|
||||||
|
png_const_bytep prev_row)
|
||||||
|
{
|
||||||
|
png_bytep rp = row;
|
||||||
|
png_bytep rp_stop = row + row_info->rowbytes;
|
||||||
|
png_const_bytep pp = prev_row;
|
||||||
|
|
||||||
|
png_debug(1, "in png_read_filter_row_up_neon");
|
||||||
|
|
||||||
|
for (; rp < rp_stop; rp += 16, pp += 16)
|
||||||
|
{
|
||||||
|
uint8x16_t qrp, qpp;
|
||||||
|
|
||||||
|
qrp = vld1q_u8(rp);
|
||||||
|
qpp = vld1q_u8(pp);
|
||||||
|
qrp = vaddq_u8(qrp, qpp);
|
||||||
|
vst1q_u8(rp, qrp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
png_read_filter_row_sub3_neon(png_row_infop row_info, png_bytep row,
|
||||||
|
png_const_bytep prev_row)
|
||||||
|
{
|
||||||
|
png_bytep rp = row;
|
||||||
|
png_bytep rp_stop = row + row_info->rowbytes;
|
||||||
|
|
||||||
|
uint8x16_t vtmp = vld1q_u8(rp);
|
||||||
|
uint8x8x2_t *vrpt = png_ptr(uint8x8x2_t, &vtmp);
|
||||||
|
uint8x8x2_t vrp = *vrpt;
|
||||||
|
|
||||||
|
uint8x8x4_t vdest;
|
||||||
|
vdest.val[3] = vdup_n_u8(0);
|
||||||
|
|
||||||
|
png_debug(1, "in png_read_filter_row_sub3_neon");
|
||||||
|
|
||||||
|
for (; rp < rp_stop;)
|
||||||
|
{
|
||||||
|
uint8x8_t vtmp1, vtmp2;
|
||||||
|
uint32x2_t *temp_pointer;
|
||||||
|
|
||||||
|
vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3);
|
||||||
|
vdest.val[0] = vadd_u8(vdest.val[3], vrp.val[0]);
|
||||||
|
vtmp2 = vext_u8(vrp.val[0], vrp.val[1], 6);
|
||||||
|
vdest.val[1] = vadd_u8(vdest.val[0], vtmp1);
|
||||||
|
|
||||||
|
vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1);
|
||||||
|
vdest.val[2] = vadd_u8(vdest.val[1], vtmp2);
|
||||||
|
vdest.val[3] = vadd_u8(vdest.val[2], vtmp1);
|
||||||
|
|
||||||
|
vtmp = vld1q_u8(rp + 12);
|
||||||
|
vrpt = png_ptr(uint8x8x2_t, &vtmp);
|
||||||
|
vrp = *vrpt;
|
||||||
|
|
||||||
|
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0);
|
||||||
|
rp += 3;
|
||||||
|
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0);
|
||||||
|
rp += 3;
|
||||||
|
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0);
|
||||||
|
rp += 3;
|
||||||
|
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0);
|
||||||
|
rp += 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
PNG_UNUSED(prev_row)
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
png_read_filter_row_sub4_neon(png_row_infop row_info, png_bytep row,
|
||||||
|
png_const_bytep prev_row)
|
||||||
|
{
|
||||||
|
png_bytep rp = row;
|
||||||
|
png_bytep rp_stop = row + row_info->rowbytes;
|
||||||
|
|
||||||
|
uint8x8x4_t vdest;
|
||||||
|
vdest.val[3] = vdup_n_u8(0);
|
||||||
|
|
||||||
|
png_debug(1, "in png_read_filter_row_sub4_neon");
|
||||||
|
|
||||||
|
for (; rp < rp_stop; rp += 16)
|
||||||
|
{
|
||||||
|
uint32x2x4_t vtmp = vld4_u32(png_ptr(uint32_t,rp));
|
||||||
|
uint8x8x4_t *vrpt = png_ptr(uint8x8x4_t,&vtmp);
|
||||||
|
uint8x8x4_t vrp = *vrpt;
|
||||||
|
uint32x2x4_t *temp_pointer;
|
||||||
|
uint32x2x4_t vdest_val;
|
||||||
|
|
||||||
|
vdest.val[0] = vadd_u8(vdest.val[3], vrp.val[0]);
|
||||||
|
vdest.val[1] = vadd_u8(vdest.val[0], vrp.val[1]);
|
||||||
|
vdest.val[2] = vadd_u8(vdest.val[1], vrp.val[2]);
|
||||||
|
vdest.val[3] = vadd_u8(vdest.val[2], vrp.val[3]);
|
||||||
|
|
||||||
|
vdest_val = png_ldr(uint32x2x4_t, &vdest);
|
||||||
|
vst4_lane_u32(png_ptr(uint32_t,rp), vdest_val, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
PNG_UNUSED(prev_row)
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
png_read_filter_row_avg3_neon(png_row_infop row_info, png_bytep row,
|
||||||
|
png_const_bytep prev_row)
|
||||||
|
{
|
||||||
|
png_bytep rp = row;
|
||||||
|
png_const_bytep pp = prev_row;
|
||||||
|
png_bytep rp_stop = row + row_info->rowbytes;
|
||||||
|
|
||||||
|
uint8x16_t vtmp;
|
||||||
|
uint8x8x2_t *vrpt;
|
||||||
|
uint8x8x2_t vrp;
|
||||||
|
uint8x8x4_t vdest;
|
||||||
|
vdest.val[3] = vdup_n_u8(0);
|
||||||
|
|
||||||
|
vtmp = vld1q_u8(rp);
|
||||||
|
vrpt = png_ptr(uint8x8x2_t,&vtmp);
|
||||||
|
vrp = *vrpt;
|
||||||
|
|
||||||
|
png_debug(1, "in png_read_filter_row_avg3_neon");
|
||||||
|
|
||||||
|
for (; rp < rp_stop; pp += 12)
|
||||||
|
{
|
||||||
|
uint8x8_t vtmp1, vtmp2, vtmp3;
|
||||||
|
|
||||||
|
uint8x8x2_t *vppt;
|
||||||
|
uint8x8x2_t vpp;
|
||||||
|
|
||||||
|
uint32x2_t *temp_pointer;
|
||||||
|
|
||||||
|
vtmp = vld1q_u8(pp);
|
||||||
|
vppt = png_ptr(uint8x8x2_t,&vtmp);
|
||||||
|
vpp = *vppt;
|
||||||
|
|
||||||
|
vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3);
|
||||||
|
vdest.val[0] = vhadd_u8(vdest.val[3], vpp.val[0]);
|
||||||
|
vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);
|
||||||
|
|
||||||
|
vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 3);
|
||||||
|
vtmp3 = vext_u8(vrp.val[0], vrp.val[1], 6);
|
||||||
|
vdest.val[1] = vhadd_u8(vdest.val[0], vtmp2);
|
||||||
|
vdest.val[1] = vadd_u8(vdest.val[1], vtmp1);
|
||||||
|
|
||||||
|
vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 6);
|
||||||
|
vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1);
|
||||||
|
|
||||||
|
vtmp = vld1q_u8(rp + 12);
|
||||||
|
vrpt = png_ptr(uint8x8x2_t,&vtmp);
|
||||||
|
vrp = *vrpt;
|
||||||
|
|
||||||
|
vdest.val[2] = vhadd_u8(vdest.val[1], vtmp2);
|
||||||
|
vdest.val[2] = vadd_u8(vdest.val[2], vtmp3);
|
||||||
|
|
||||||
|
vtmp2 = vext_u8(vpp.val[1], vpp.val[1], 1);
|
||||||
|
|
||||||
|
vdest.val[3] = vhadd_u8(vdest.val[2], vtmp2);
|
||||||
|
vdest.val[3] = vadd_u8(vdest.val[3], vtmp1);
|
||||||
|
|
||||||
|
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0);
|
||||||
|
rp += 3;
|
||||||
|
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0);
|
||||||
|
rp += 3;
|
||||||
|
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0);
|
||||||
|
rp += 3;
|
||||||
|
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0);
|
||||||
|
rp += 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
png_read_filter_row_avg4_neon(png_row_infop row_info, png_bytep row,
|
||||||
|
png_const_bytep prev_row)
|
||||||
|
{
|
||||||
|
png_bytep rp = row;
|
||||||
|
png_bytep rp_stop = row + row_info->rowbytes;
|
||||||
|
png_const_bytep pp = prev_row;
|
||||||
|
|
||||||
|
uint8x8x4_t vdest;
|
||||||
|
vdest.val[3] = vdup_n_u8(0);
|
||||||
|
|
||||||
|
png_debug(1, "in png_read_filter_row_avg4_neon");
|
||||||
|
|
||||||
|
for (; rp < rp_stop; rp += 16, pp += 16)
|
||||||
|
{
|
||||||
|
uint32x2x4_t vtmp;
|
||||||
|
uint8x8x4_t *vrpt, *vppt;
|
||||||
|
uint8x8x4_t vrp, vpp;
|
||||||
|
uint32x2x4_t *temp_pointer;
|
||||||
|
uint32x2x4_t vdest_val;
|
||||||
|
|
||||||
|
vtmp = vld4_u32(png_ptr(uint32_t,rp));
|
||||||
|
vrpt = png_ptr(uint8x8x4_t,&vtmp);
|
||||||
|
vrp = *vrpt;
|
||||||
|
vtmp = vld4_u32(png_ptrc(uint32_t,pp));
|
||||||
|
vppt = png_ptr(uint8x8x4_t,&vtmp);
|
||||||
|
vpp = *vppt;
|
||||||
|
|
||||||
|
vdest.val[0] = vhadd_u8(vdest.val[3], vpp.val[0]);
|
||||||
|
vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);
|
||||||
|
vdest.val[1] = vhadd_u8(vdest.val[0], vpp.val[1]);
|
||||||
|
vdest.val[1] = vadd_u8(vdest.val[1], vrp.val[1]);
|
||||||
|
vdest.val[2] = vhadd_u8(vdest.val[1], vpp.val[2]);
|
||||||
|
vdest.val[2] = vadd_u8(vdest.val[2], vrp.val[2]);
|
||||||
|
vdest.val[3] = vhadd_u8(vdest.val[2], vpp.val[3]);
|
||||||
|
vdest.val[3] = vadd_u8(vdest.val[3], vrp.val[3]);
|
||||||
|
|
||||||
|
vdest_val = png_ldr(uint32x2x4_t, &vdest);
|
||||||
|
vst4_lane_u32(png_ptr(uint32_t,rp), vdest_val, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static uint8x8_t
|
||||||
|
paeth(uint8x8_t a, uint8x8_t b, uint8x8_t c)
|
||||||
|
{
|
||||||
|
uint8x8_t d, e;
|
||||||
|
uint16x8_t p1, pa, pb, pc;
|
||||||
|
|
||||||
|
p1 = vaddl_u8(a, b); /* a + b */
|
||||||
|
pc = vaddl_u8(c, c); /* c * 2 */
|
||||||
|
pa = vabdl_u8(b, c); /* pa */
|
||||||
|
pb = vabdl_u8(a, c); /* pb */
|
||||||
|
pc = vabdq_u16(p1, pc); /* pc */
|
||||||
|
|
||||||
|
p1 = vcleq_u16(pa, pb); /* pa <= pb */
|
||||||
|
pa = vcleq_u16(pa, pc); /* pa <= pc */
|
||||||
|
pb = vcleq_u16(pb, pc); /* pb <= pc */
|
||||||
|
|
||||||
|
p1 = vandq_u16(p1, pa); /* pa <= pb && pa <= pc */
|
||||||
|
|
||||||
|
d = vmovn_u16(pb);
|
||||||
|
e = vmovn_u16(p1);
|
||||||
|
|
||||||
|
d = vbsl_u8(d, b, c);
|
||||||
|
e = vbsl_u8(e, a, d);
|
||||||
|
|
||||||
|
return e;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
png_read_filter_row_paeth3_neon(png_row_infop row_info, png_bytep row,
|
||||||
|
png_const_bytep prev_row)
|
||||||
|
{
|
||||||
|
png_bytep rp = row;
|
||||||
|
png_const_bytep pp = prev_row;
|
||||||
|
png_bytep rp_stop = row + row_info->rowbytes;
|
||||||
|
|
||||||
|
uint8x16_t vtmp;
|
||||||
|
uint8x8x2_t *vrpt;
|
||||||
|
uint8x8x2_t vrp;
|
||||||
|
uint8x8_t vlast = vdup_n_u8(0);
|
||||||
|
uint8x8x4_t vdest;
|
||||||
|
vdest.val[3] = vdup_n_u8(0);
|
||||||
|
|
||||||
|
vtmp = vld1q_u8(rp);
|
||||||
|
vrpt = png_ptr(uint8x8x2_t,&vtmp);
|
||||||
|
vrp = *vrpt;
|
||||||
|
|
||||||
|
png_debug(1, "in png_read_filter_row_paeth3_neon");
|
||||||
|
|
||||||
|
for (; rp < rp_stop; pp += 12)
|
||||||
|
{
|
||||||
|
uint8x8x2_t *vppt;
|
||||||
|
uint8x8x2_t vpp;
|
||||||
|
uint8x8_t vtmp1, vtmp2, vtmp3;
|
||||||
|
uint32x2_t *temp_pointer;
|
||||||
|
|
||||||
|
vtmp = vld1q_u8(pp);
|
||||||
|
vppt = png_ptr(uint8x8x2_t,&vtmp);
|
||||||
|
vpp = *vppt;
|
||||||
|
|
||||||
|
vdest.val[0] = paeth(vdest.val[3], vpp.val[0], vlast);
|
||||||
|
vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);
|
||||||
|
|
||||||
|
vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3);
|
||||||
|
vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 3);
|
||||||
|
vdest.val[1] = paeth(vdest.val[0], vtmp2, vpp.val[0]);
|
||||||
|
vdest.val[1] = vadd_u8(vdest.val[1], vtmp1);
|
||||||
|
|
||||||
|
vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 6);
|
||||||
|
vtmp3 = vext_u8(vpp.val[0], vpp.val[1], 6);
|
||||||
|
vdest.val[2] = paeth(vdest.val[1], vtmp3, vtmp2);
|
||||||
|
vdest.val[2] = vadd_u8(vdest.val[2], vtmp1);
|
||||||
|
|
||||||
|
vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1);
|
||||||
|
vtmp2 = vext_u8(vpp.val[1], vpp.val[1], 1);
|
||||||
|
|
||||||
|
vtmp = vld1q_u8(rp + 12);
|
||||||
|
vrpt = png_ptr(uint8x8x2_t,&vtmp);
|
||||||
|
vrp = *vrpt;
|
||||||
|
|
||||||
|
vdest.val[3] = paeth(vdest.val[2], vtmp2, vtmp3);
|
||||||
|
vdest.val[3] = vadd_u8(vdest.val[3], vtmp1);
|
||||||
|
|
||||||
|
vlast = vtmp2;
|
||||||
|
|
||||||
|
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0);
|
||||||
|
rp += 3;
|
||||||
|
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0);
|
||||||
|
rp += 3;
|
||||||
|
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0);
|
||||||
|
rp += 3;
|
||||||
|
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0);
|
||||||
|
rp += 3;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
png_read_filter_row_paeth4_neon(png_row_infop row_info, png_bytep row,
|
||||||
|
png_const_bytep prev_row)
|
||||||
|
{
|
||||||
|
png_bytep rp = row;
|
||||||
|
png_bytep rp_stop = row + row_info->rowbytes;
|
||||||
|
png_const_bytep pp = prev_row;
|
||||||
|
|
||||||
|
uint8x8_t vlast = vdup_n_u8(0);
|
||||||
|
uint8x8x4_t vdest;
|
||||||
|
vdest.val[3] = vdup_n_u8(0);
|
||||||
|
|
||||||
|
png_debug(1, "in png_read_filter_row_paeth4_neon");
|
||||||
|
|
||||||
|
for (; rp < rp_stop; rp += 16, pp += 16)
|
||||||
|
{
|
||||||
|
uint32x2x4_t vtmp;
|
||||||
|
uint8x8x4_t *vrpt, *vppt;
|
||||||
|
uint8x8x4_t vrp, vpp;
|
||||||
|
uint32x2x4_t *temp_pointer;
|
||||||
|
uint32x2x4_t vdest_val;
|
||||||
|
|
||||||
|
vtmp = vld4_u32(png_ptr(uint32_t,rp));
|
||||||
|
vrpt = png_ptr(uint8x8x4_t,&vtmp);
|
||||||
|
vrp = *vrpt;
|
||||||
|
vtmp = vld4_u32(png_ptrc(uint32_t,pp));
|
||||||
|
vppt = png_ptr(uint8x8x4_t,&vtmp);
|
||||||
|
vpp = *vppt;
|
||||||
|
|
||||||
|
vdest.val[0] = paeth(vdest.val[3], vpp.val[0], vlast);
|
||||||
|
vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);
|
||||||
|
vdest.val[1] = paeth(vdest.val[0], vpp.val[1], vpp.val[0]);
|
||||||
|
vdest.val[1] = vadd_u8(vdest.val[1], vrp.val[1]);
|
||||||
|
vdest.val[2] = paeth(vdest.val[1], vpp.val[2], vpp.val[1]);
|
||||||
|
vdest.val[2] = vadd_u8(vdest.val[2], vrp.val[2]);
|
||||||
|
vdest.val[3] = paeth(vdest.val[2], vpp.val[3], vpp.val[2]);
|
||||||
|
vdest.val[3] = vadd_u8(vdest.val[3], vrp.val[3]);
|
||||||
|
|
||||||
|
vlast = vpp.val[3];
|
||||||
|
|
||||||
|
vdest_val = png_ldr(uint32x2x4_t, &vdest);
|
||||||
|
vst4_lane_u32(png_ptr(uint32_t,rp), vdest_val, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||||
|
#endif /* PNG_ARM_NEON_IMPLEMENTATION == 1 (intrinsics) */
|
||||||
|
#endif /* READ */
|
149
libs/libpng-src/arm/palette_neon_intrinsics.c
Normal file
149
libs/libpng-src/arm/palette_neon_intrinsics.c
Normal file
|
@ -0,0 +1,149 @@
|
||||||
|
|
||||||
|
/* palette_neon_intrinsics.c - NEON optimised palette expansion functions
|
||||||
|
*
|
||||||
|
* Copyright (c) 2018-2019 Cosmin Truta
|
||||||
|
* Copyright (c) 2017-2018 Arm Holdings. All rights reserved.
|
||||||
|
* Written by Richard Townsend <Richard.Townsend@arm.com>, February 2017.
|
||||||
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../pngpriv.h"
|
||||||
|
|
||||||
|
#if PNG_ARM_NEON_IMPLEMENTATION == 1
|
||||||
|
|
||||||
|
#if defined(_MSC_VER) && defined(_M_ARM64)
|
||||||
|
# include <arm64_neon.h>
|
||||||
|
#else
|
||||||
|
# include <arm_neon.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Build an RGBA8 palette from the separate RGB and alpha palettes. */
|
||||||
|
void
|
||||||
|
png_riffle_palette_neon(png_structrp png_ptr)
|
||||||
|
{
|
||||||
|
png_const_colorp palette = png_ptr->palette;
|
||||||
|
png_bytep riffled_palette = png_ptr->riffled_palette;
|
||||||
|
png_const_bytep trans_alpha = png_ptr->trans_alpha;
|
||||||
|
int num_trans = png_ptr->num_trans;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
png_debug(1, "in png_riffle_palette_neon");
|
||||||
|
|
||||||
|
/* Initially black, opaque. */
|
||||||
|
uint8x16x4_t w = {{
|
||||||
|
vdupq_n_u8(0x00),
|
||||||
|
vdupq_n_u8(0x00),
|
||||||
|
vdupq_n_u8(0x00),
|
||||||
|
vdupq_n_u8(0xff),
|
||||||
|
}};
|
||||||
|
|
||||||
|
/* First, riffle the RGB colours into an RGBA8 palette.
|
||||||
|
* The alpha component is set to opaque for now.
|
||||||
|
*/
|
||||||
|
for (i = 0; i < 256; i += 16)
|
||||||
|
{
|
||||||
|
uint8x16x3_t v = vld3q_u8((png_const_bytep)(palette + i));
|
||||||
|
w.val[0] = v.val[0];
|
||||||
|
w.val[1] = v.val[1];
|
||||||
|
w.val[2] = v.val[2];
|
||||||
|
vst4q_u8(riffled_palette + (i << 2), w);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fix up the missing transparency values. */
|
||||||
|
for (i = 0; i < num_trans; i++)
|
||||||
|
riffled_palette[(i << 2) + 3] = trans_alpha[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Expands a palettized row into RGBA8. */
|
||||||
|
int
|
||||||
|
png_do_expand_palette_rgba8_neon(png_structrp png_ptr, png_row_infop row_info,
|
||||||
|
png_const_bytep row, png_bytepp ssp, png_bytepp ddp)
|
||||||
|
{
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
const png_uint_32 *riffled_palette =
|
||||||
|
(const png_uint_32 *)png_ptr->riffled_palette;
|
||||||
|
const png_int_32 pixels_per_chunk = 4;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
png_debug(1, "in png_do_expand_palette_rgba8_neon");
|
||||||
|
|
||||||
|
if (row_width < pixels_per_chunk)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* This function originally gets the last byte of the output row.
|
||||||
|
* The NEON part writes forward from a given position, so we have
|
||||||
|
* to seek this back by 4 pixels x 4 bytes.
|
||||||
|
*/
|
||||||
|
*ddp = *ddp - ((pixels_per_chunk * sizeof(png_uint_32)) - 1);
|
||||||
|
|
||||||
|
for (i = 0; i < row_width; i += pixels_per_chunk)
|
||||||
|
{
|
||||||
|
uint32x4_t cur;
|
||||||
|
png_bytep sp = *ssp - i, dp = *ddp - (i << 2);
|
||||||
|
cur = vld1q_dup_u32 (riffled_palette + *(sp - 3));
|
||||||
|
cur = vld1q_lane_u32(riffled_palette + *(sp - 2), cur, 1);
|
||||||
|
cur = vld1q_lane_u32(riffled_palette + *(sp - 1), cur, 2);
|
||||||
|
cur = vld1q_lane_u32(riffled_palette + *(sp - 0), cur, 3);
|
||||||
|
vst1q_u32((void *)dp, cur);
|
||||||
|
}
|
||||||
|
if (i != row_width)
|
||||||
|
{
|
||||||
|
/* Remove the amount that wasn't processed. */
|
||||||
|
i -= pixels_per_chunk;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Decrement output pointers. */
|
||||||
|
*ssp = *ssp - i;
|
||||||
|
*ddp = *ddp - (i << 2);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Expands a palettized row into RGB8. */
|
||||||
|
int
|
||||||
|
png_do_expand_palette_rgb8_neon(png_structrp png_ptr, png_row_infop row_info,
|
||||||
|
png_const_bytep row, png_bytepp ssp, png_bytepp ddp)
|
||||||
|
{
|
||||||
|
png_uint_32 row_width = row_info->width;
|
||||||
|
png_const_bytep palette = (png_const_bytep)png_ptr->palette;
|
||||||
|
const png_uint_32 pixels_per_chunk = 8;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
png_debug(1, "in png_do_expand_palette_rgb8_neon");
|
||||||
|
|
||||||
|
if (row_width <= pixels_per_chunk)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
/* Seeking this back by 8 pixels x 3 bytes. */
|
||||||
|
*ddp = *ddp - ((pixels_per_chunk * sizeof(png_color)) - 1);
|
||||||
|
|
||||||
|
for (i = 0; i < row_width; i += pixels_per_chunk)
|
||||||
|
{
|
||||||
|
uint8x8x3_t cur;
|
||||||
|
png_bytep sp = *ssp - i, dp = *ddp - ((i << 1) + i);
|
||||||
|
cur = vld3_dup_u8(palette + sizeof(png_color) * (*(sp - 7)));
|
||||||
|
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 6)), cur, 1);
|
||||||
|
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 5)), cur, 2);
|
||||||
|
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 4)), cur, 3);
|
||||||
|
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 3)), cur, 4);
|
||||||
|
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 2)), cur, 5);
|
||||||
|
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 1)), cur, 6);
|
||||||
|
cur = vld3_lane_u8(palette + sizeof(png_color) * (*(sp - 0)), cur, 7);
|
||||||
|
vst3_u8((void *)dp, cur);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i != row_width)
|
||||||
|
{
|
||||||
|
/* Remove the amount that wasn't processed. */
|
||||||
|
i -= pixels_per_chunk;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Decrement output pointers. */
|
||||||
|
*ssp = *ssp - i;
|
||||||
|
*ddp = *ddp - ((i << 1) + i);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* PNG_ARM_NEON_IMPLEMENTATION */
|
|
@ -1,25 +1,225 @@
|
||||||
#! /bin/sh
|
#! /bin/sh
|
||||||
# a quick hack script to generate necessary files from
|
|
||||||
# auto* tools.
|
|
||||||
#
|
#
|
||||||
# WARNING: if you run this you will change the versions
|
# Run 'autoreconf' to build 'configure', 'Makefile.in' and other configure
|
||||||
# of the tools which are used and, maybe, required!
|
# control files.
|
||||||
touch Makefile.am configure.ac
|
#
|
||||||
{
|
# The first time this is run on a GIT checkout the only files that exist are
|
||||||
echo "running libtoolize" >&2
|
# configure.ac and Makefile.am; all of the autotools support scripts are
|
||||||
libtoolize --force --copy --automake
|
# missing. They are instantiated with autoreconf --force --install.
|
||||||
} && {
|
#
|
||||||
echo "running aclocal" >&2
|
# For regular ("tarball") distributions all the files should exist. We do not
|
||||||
aclocal
|
# want them to be updated *under any circumstances*. It should never be
|
||||||
} && {
|
# necessary to run autogen.sh because ./configure --enable-maintainer-mode says
|
||||||
echo "running autoheader [ignore the warnings]" >&2
|
# what to do if Makefile.am or configure.ac are changed.
|
||||||
autoheader
|
#
|
||||||
} && {
|
# It is *probably* OK to update the files on a GIT checkout, because they have
|
||||||
echo "running automake" >&2
|
# come from the local tools, but leave that to the user who is assumed to know
|
||||||
automake --force-missing --foreign -a -c
|
# whether it is ok or required.
|
||||||
} && {
|
#
|
||||||
echo "running autoconf" >&2
|
# This script is intended to work without arguments, there are, however, hidden
|
||||||
autoconf
|
# arguments (a) for use while testing the script and (b) to fix up systems that
|
||||||
} &&
|
# have been broken. If (b) is required the script prompts for the correct
|
||||||
echo "autogen complete" >&2 ||
|
# options. For this reason the options are *NOT* documented in the help; this
|
||||||
echo "ERROR: autogen.sh failed, autogen is incomplete" >&2
|
# is deliberate; UTSL.
|
||||||
|
#
|
||||||
|
clean=
|
||||||
|
maintainer=
|
||||||
|
while test $# -gt 0
|
||||||
|
do
|
||||||
|
case "$1" in
|
||||||
|
--maintainer)
|
||||||
|
maintainer=1;;
|
||||||
|
|
||||||
|
--clean)
|
||||||
|
clean=1;;
|
||||||
|
|
||||||
|
*)
|
||||||
|
exec >&2
|
||||||
|
echo "$0: usage: ./autogen.sh"
|
||||||
|
if test -d .git
|
||||||
|
then
|
||||||
|
echo " ./autogen.sh generates the configure script and"
|
||||||
|
echo " Makefile.in, or refreshes them after changes to Makefile.am"
|
||||||
|
echo " or configure.ac. You may prefer to just run autoreconf."
|
||||||
|
elif test -z "$maintainer"
|
||||||
|
then
|
||||||
|
echo " DO NOT RUN THIS SCRIPT."
|
||||||
|
echo " If you need to change Makefile.am or configure.ac then you"
|
||||||
|
echo " also need to run ./configure --enable-maintainer-mode and"
|
||||||
|
echo " use the appropriate autotools, *NOT* this script, to update"
|
||||||
|
echo " everything, please check the documentation of autoreconf."
|
||||||
|
echo " WARNING: libpng is intentionally generated with a known,"
|
||||||
|
echo " fixed, set of autotools. It is known *NOT* to work with"
|
||||||
|
echo " the collection of autotools distributed on highly reputable"
|
||||||
|
echo " operating systems."
|
||||||
|
echo " Remember: autotools is GNU software, you are expected to"
|
||||||
|
echo " pay for support."
|
||||||
|
else
|
||||||
|
echo " You have run autogen.sh with --maintainer enabled and you"
|
||||||
|
echo " are not using a GIT distribution, then you have given an"
|
||||||
|
echo " unrecognized argument. This is not good. --maintainer"
|
||||||
|
echo " switches off any assumptions that you might not know what"
|
||||||
|
echo " you are doing."
|
||||||
|
fi
|
||||||
|
exit 1;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
#
|
||||||
|
# First check for a set of the autotools files; if absent then this is assumed
|
||||||
|
# to be a GIT version and the local autotools must be used. If present this
|
||||||
|
# is a tarball distribution and the script should not be used. If partially
|
||||||
|
# present bad things are happening.
|
||||||
|
#
|
||||||
|
# The autotools generated files:
|
||||||
|
libpng_autotools_files="Makefile.in aclocal.m4 config.guess config.h.in
|
||||||
|
config.sub configure depcomp install-sh ltmain.sh missing\
|
||||||
|
test-driver"
|
||||||
|
#
|
||||||
|
# Files generated by versions of configue >2.68 or automake >1.13 (i.e. later
|
||||||
|
# versions than those required by configure.ac):
|
||||||
|
libpng_autotools_extra="compile config.h.in~"
|
||||||
|
#
|
||||||
|
# These are separate because 'maintainer-clean' does not remove them.
|
||||||
|
libpng_libtool_files="scripts/libtool.m4 scripts/ltoptions.m4\
|
||||||
|
scripts/ltsugar.m4 scripts/ltversion.m4 scripts/lt~obsolete.m4"
|
||||||
|
|
||||||
|
libpng_autotools_dirs="autom4te.cache" # not required
|
||||||
|
#
|
||||||
|
# The configure generated files:
|
||||||
|
libpng_configure_files="Makefile config.h config.log config.status\
|
||||||
|
libpng-config libpng.pc libtool stamp-h1"
|
||||||
|
|
||||||
|
libpng_configure_dirs=".deps"
|
||||||
|
#
|
||||||
|
# We must remove the configure generated files as well as the autotools
|
||||||
|
# generated files if autotools are regenerated because otherwise if configure
|
||||||
|
# has been run without "--enable-maintainer-mode" make can do a partial update
|
||||||
|
# of Makefile. These functions do the two bits of cleaning.
|
||||||
|
clean_autotools(){
|
||||||
|
rm -rf $libpng_autotools_files $libpng_libtool_files $libpng_autotools_dirs
|
||||||
|
rm -rf $libpng_autotools_extra
|
||||||
|
}
|
||||||
|
|
||||||
|
clean_configure(){
|
||||||
|
rm -rf $libpng_configure_files $libpng_configure_dirs
|
||||||
|
}
|
||||||
|
#
|
||||||
|
# Clean: remove everything (this is to help with testing)
|
||||||
|
if test -n "$clean"
|
||||||
|
then
|
||||||
|
clean_configure
|
||||||
|
if test -n "$maintainer"
|
||||||
|
then
|
||||||
|
clean_autotools
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
#
|
||||||
|
# Validate the distribution.
|
||||||
|
libpng_autotools_file_found=
|
||||||
|
libpng_autotools_file_missing=
|
||||||
|
for file in $libpng_autotools_files
|
||||||
|
do
|
||||||
|
if test -f "$file"
|
||||||
|
then
|
||||||
|
libpng_autotools_file_found=1
|
||||||
|
else
|
||||||
|
libpng_autotools_file_missing=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
#
|
||||||
|
# Presence of one of these does not *invalidate* missing, but absence
|
||||||
|
# invalidates found.
|
||||||
|
for file in $libpng_libtool_files
|
||||||
|
do
|
||||||
|
if test ! -f "$file"
|
||||||
|
then
|
||||||
|
libpng_autotools_file_missing=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
#
|
||||||
|
# The cache directory doesn't matter - it will be regenerated and does not exist
|
||||||
|
# anyway in a tarball.
|
||||||
|
#
|
||||||
|
# Either everything is missing or everything is there, the --maintainer option
|
||||||
|
# just changes this so that the mode is set to generate all the files.
|
||||||
|
mode=
|
||||||
|
if test -z "$libpng_autotools_file_found" -o -n "$maintainer"
|
||||||
|
then
|
||||||
|
mode="autoreconf"
|
||||||
|
else
|
||||||
|
if test -n "$libpng_autotools_file_missing"
|
||||||
|
then
|
||||||
|
mode="broken"
|
||||||
|
else
|
||||||
|
mode="configure"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
#
|
||||||
|
# So:
|
||||||
|
case "$mode" in
|
||||||
|
autoreconf)
|
||||||
|
# Clean in case configure files exist
|
||||||
|
clean_configure
|
||||||
|
clean_autotools
|
||||||
|
# Everything must be initialized, so use --force
|
||||||
|
if autoreconf --warnings=all --force --install
|
||||||
|
then
|
||||||
|
missing=
|
||||||
|
for file in $libpng_autotools_files
|
||||||
|
do
|
||||||
|
test -f "$file" || missing=1
|
||||||
|
done
|
||||||
|
# ignore the cache directory
|
||||||
|
test -z "$missing" || {
|
||||||
|
exec >&2
|
||||||
|
echo "autoreconf was run, but did not produce all the expected"
|
||||||
|
echo "files. It is likely that your autotools installation is"
|
||||||
|
echo "not compatible with that expected by libpng."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
else
|
||||||
|
exec >&2
|
||||||
|
echo "autoreconf failed: your version of autotools is incompatible"
|
||||||
|
echo "with this libpng version. Please use a distributed archive"
|
||||||
|
echo "(which includes the autotools generated files) and run configure"
|
||||||
|
echo "instead."
|
||||||
|
exit 1
|
||||||
|
fi;;
|
||||||
|
|
||||||
|
configure)
|
||||||
|
if test -d .git
|
||||||
|
then
|
||||||
|
exec >&2
|
||||||
|
echo "ERROR: running autoreconf on an initialized system"
|
||||||
|
echo " This is not necessary; it is only necessary to remake the"
|
||||||
|
echo " autotools generated files if Makefile.am or configure.ac"
|
||||||
|
echo " change and make does the right thing with:"
|
||||||
|
echo
|
||||||
|
echo " ./configure --enable-maintainer-mode."
|
||||||
|
echo
|
||||||
|
echo " You can run autoreconf yourself if you don't like maintainer"
|
||||||
|
echo " mode and you can also just run autoreconf -f -i to initialize"
|
||||||
|
echo " everything in the first place; this script is only for"
|
||||||
|
echo " compatibility with prior releases."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
exec >&2
|
||||||
|
echo "autogen.sh is intended only to generate 'configure' on systems"
|
||||||
|
echo "that do not have it. You have a complete 'configure', if you"
|
||||||
|
echo "need to change Makefile.am or configure.ac you also need to"
|
||||||
|
echo "run configure with the --enable-maintainer-mode option."
|
||||||
|
exit 1
|
||||||
|
fi;;
|
||||||
|
|
||||||
|
broken)
|
||||||
|
exec >&2
|
||||||
|
echo "Your system has a partial set of autotools generated files."
|
||||||
|
echo "autogen.sh is unable to proceed. The full set of files is"
|
||||||
|
echo "contained in the libpng 'tar' distribution archive and you do"
|
||||||
|
echo "not need to run autogen.sh if you use it."
|
||||||
|
exit 1;;
|
||||||
|
esac
|
||||||
|
|
348
libs/libpng-src/compile
Normal file
348
libs/libpng-src/compile
Normal file
|
@ -0,0 +1,348 @@
|
||||||
|
#! /bin/sh
|
||||||
|
# Wrapper for compilers which do not understand '-c -o'.
|
||||||
|
|
||||||
|
scriptversion=2018-03-07.03; # UTC
|
||||||
|
|
||||||
|
# Copyright (C) 1999-2018 Free Software Foundation, Inc.
|
||||||
|
# Written by Tom Tromey <tromey@cygnus.com>.
|
||||||
|
#
|
||||||
|
# This program is free software; you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation; either version 2, or (at your option)
|
||||||
|
# any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
# As a special exception to the GNU General Public License, if you
|
||||||
|
# distribute this file as part of a program that contains a
|
||||||
|
# configuration script generated by Autoconf, you may include it under
|
||||||
|
# the same distribution terms that you use for the rest of that program.
|
||||||
|
|
||||||
|
# This file is maintained in Automake, please report
|
||||||
|
# bugs to <bug-automake@gnu.org> or send patches to
|
||||||
|
# <automake-patches@gnu.org>.
|
||||||
|
|
||||||
|
nl='
|
||||||
|
'
|
||||||
|
|
||||||
|
# We need space, tab and new line, in precisely that order. Quoting is
|
||||||
|
# there to prevent tools from complaining about whitespace usage.
|
||||||
|
IFS=" "" $nl"
|
||||||
|
|
||||||
|
file_conv=
|
||||||
|
|
||||||
|
# func_file_conv build_file lazy
|
||||||
|
# Convert a $build file to $host form and store it in $file
|
||||||
|
# Currently only supports Windows hosts. If the determined conversion
|
||||||
|
# type is listed in (the comma separated) LAZY, no conversion will
|
||||||
|
# take place.
|
||||||
|
func_file_conv ()
|
||||||
|
{
|
||||||
|
file=$1
|
||||||
|
case $file in
|
||||||
|
/ | /[!/]*) # absolute file, and not a UNC file
|
||||||
|
if test -z "$file_conv"; then
|
||||||
|
# lazily determine how to convert abs files
|
||||||
|
case `uname -s` in
|
||||||
|
MINGW*)
|
||||||
|
file_conv=mingw
|
||||||
|
;;
|
||||||
|
CYGWIN*)
|
||||||
|
file_conv=cygwin
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
file_conv=wine
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
case $file_conv/,$2, in
|
||||||
|
*,$file_conv,*)
|
||||||
|
;;
|
||||||
|
mingw/*)
|
||||||
|
file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'`
|
||||||
|
;;
|
||||||
|
cygwin/*)
|
||||||
|
file=`cygpath -m "$file" || echo "$file"`
|
||||||
|
;;
|
||||||
|
wine/*)
|
||||||
|
file=`winepath -w "$file" || echo "$file"`
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
|
||||||
|
# func_cl_dashL linkdir
|
||||||
|
# Make cl look for libraries in LINKDIR
|
||||||
|
func_cl_dashL ()
|
||||||
|
{
|
||||||
|
func_file_conv "$1"
|
||||||
|
if test -z "$lib_path"; then
|
||||||
|
lib_path=$file
|
||||||
|
else
|
||||||
|
lib_path="$lib_path;$file"
|
||||||
|
fi
|
||||||
|
linker_opts="$linker_opts -LIBPATH:$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# func_cl_dashl library
|
||||||
|
# Do a library search-path lookup for cl
|
||||||
|
func_cl_dashl ()
|
||||||
|
{
|
||||||
|
lib=$1
|
||||||
|
found=no
|
||||||
|
save_IFS=$IFS
|
||||||
|
IFS=';'
|
||||||
|
for dir in $lib_path $LIB
|
||||||
|
do
|
||||||
|
IFS=$save_IFS
|
||||||
|
if $shared && test -f "$dir/$lib.dll.lib"; then
|
||||||
|
found=yes
|
||||||
|
lib=$dir/$lib.dll.lib
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
if test -f "$dir/$lib.lib"; then
|
||||||
|
found=yes
|
||||||
|
lib=$dir/$lib.lib
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
if test -f "$dir/lib$lib.a"; then
|
||||||
|
found=yes
|
||||||
|
lib=$dir/lib$lib.a
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
IFS=$save_IFS
|
||||||
|
|
||||||
|
if test "$found" != yes; then
|
||||||
|
lib=$lib.lib
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# func_cl_wrapper cl arg...
|
||||||
|
# Adjust compile command to suit cl
|
||||||
|
func_cl_wrapper ()
|
||||||
|
{
|
||||||
|
# Assume a capable shell
|
||||||
|
lib_path=
|
||||||
|
shared=:
|
||||||
|
linker_opts=
|
||||||
|
for arg
|
||||||
|
do
|
||||||
|
if test -n "$eat"; then
|
||||||
|
eat=
|
||||||
|
else
|
||||||
|
case $1 in
|
||||||
|
-o)
|
||||||
|
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||||
|
eat=1
|
||||||
|
case $2 in
|
||||||
|
*.o | *.[oO][bB][jJ])
|
||||||
|
func_file_conv "$2"
|
||||||
|
set x "$@" -Fo"$file"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
func_file_conv "$2"
|
||||||
|
set x "$@" -Fe"$file"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
-I)
|
||||||
|
eat=1
|
||||||
|
func_file_conv "$2" mingw
|
||||||
|
set x "$@" -I"$file"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-I*)
|
||||||
|
func_file_conv "${1#-I}" mingw
|
||||||
|
set x "$@" -I"$file"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-l)
|
||||||
|
eat=1
|
||||||
|
func_cl_dashl "$2"
|
||||||
|
set x "$@" "$lib"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-l*)
|
||||||
|
func_cl_dashl "${1#-l}"
|
||||||
|
set x "$@" "$lib"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
-L)
|
||||||
|
eat=1
|
||||||
|
func_cl_dashL "$2"
|
||||||
|
;;
|
||||||
|
-L*)
|
||||||
|
func_cl_dashL "${1#-L}"
|
||||||
|
;;
|
||||||
|
-static)
|
||||||
|
shared=false
|
||||||
|
;;
|
||||||
|
-Wl,*)
|
||||||
|
arg=${1#-Wl,}
|
||||||
|
save_ifs="$IFS"; IFS=','
|
||||||
|
for flag in $arg; do
|
||||||
|
IFS="$save_ifs"
|
||||||
|
linker_opts="$linker_opts $flag"
|
||||||
|
done
|
||||||
|
IFS="$save_ifs"
|
||||||
|
;;
|
||||||
|
-Xlinker)
|
||||||
|
eat=1
|
||||||
|
linker_opts="$linker_opts $2"
|
||||||
|
;;
|
||||||
|
-*)
|
||||||
|
set x "$@" "$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*.cc | *.CC | *.cxx | *.CXX | *.[cC]++)
|
||||||
|
func_file_conv "$1"
|
||||||
|
set x "$@" -Tp"$file"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO])
|
||||||
|
func_file_conv "$1" mingw
|
||||||
|
set x "$@" "$file"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
set x "$@" "$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
if test -n "$linker_opts"; then
|
||||||
|
linker_opts="-link$linker_opts"
|
||||||
|
fi
|
||||||
|
exec "$@" $linker_opts
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
eat=
|
||||||
|
|
||||||
|
case $1 in
|
||||||
|
'')
|
||||||
|
echo "$0: No command. Try '$0 --help' for more information." 1>&2
|
||||||
|
exit 1;
|
||||||
|
;;
|
||||||
|
-h | --h*)
|
||||||
|
cat <<\EOF
|
||||||
|
Usage: compile [--help] [--version] PROGRAM [ARGS]
|
||||||
|
|
||||||
|
Wrapper for compilers which do not understand '-c -o'.
|
||||||
|
Remove '-o dest.o' from ARGS, run PROGRAM with the remaining
|
||||||
|
arguments, and rename the output as expected.
|
||||||
|
|
||||||
|
If you are trying to build a whole package this is not the
|
||||||
|
right script to run: please start by reading the file 'INSTALL'.
|
||||||
|
|
||||||
|
Report bugs to <bug-automake@gnu.org>.
|
||||||
|
EOF
|
||||||
|
exit $?
|
||||||
|
;;
|
||||||
|
-v | --v*)
|
||||||
|
echo "compile $scriptversion"
|
||||||
|
exit $?
|
||||||
|
;;
|
||||||
|
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
|
||||||
|
icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
|
||||||
|
func_cl_wrapper "$@" # Doesn't return...
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
ofile=
|
||||||
|
cfile=
|
||||||
|
|
||||||
|
for arg
|
||||||
|
do
|
||||||
|
if test -n "$eat"; then
|
||||||
|
eat=
|
||||||
|
else
|
||||||
|
case $1 in
|
||||||
|
-o)
|
||||||
|
# configure might choose to run compile as 'compile cc -o foo foo.c'.
|
||||||
|
# So we strip '-o arg' only if arg is an object.
|
||||||
|
eat=1
|
||||||
|
case $2 in
|
||||||
|
*.o | *.obj)
|
||||||
|
ofile=$2
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
set x "$@" -o "$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
*.c)
|
||||||
|
cfile=$1
|
||||||
|
set x "$@" "$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
set x "$@" "$1"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
if test -z "$ofile" || test -z "$cfile"; then
|
||||||
|
# If no '-o' option was seen then we might have been invoked from a
|
||||||
|
# pattern rule where we don't need one. That is ok -- this is a
|
||||||
|
# normal compilation that the losing compiler can handle. If no
|
||||||
|
# '.c' file was seen then we are probably linking. That is also
|
||||||
|
# ok.
|
||||||
|
exec "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Name of file we expect compiler to create.
|
||||||
|
cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'`
|
||||||
|
|
||||||
|
# Create the lock directory.
|
||||||
|
# Note: use '[/\\:.-]' here to ensure that we don't use the same name
|
||||||
|
# that we are using for the .o file. Also, base the name on the expected
|
||||||
|
# object file name, since that is what matters with a parallel build.
|
||||||
|
lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d
|
||||||
|
while true; do
|
||||||
|
if mkdir "$lockdir" >/dev/null 2>&1; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
# FIXME: race condition here if user kills between mkdir and trap.
|
||||||
|
trap "rmdir '$lockdir'; exit 1" 1 2 15
|
||||||
|
|
||||||
|
# Run the compile.
|
||||||
|
"$@"
|
||||||
|
ret=$?
|
||||||
|
|
||||||
|
if test -f "$cofile"; then
|
||||||
|
test "$cofile" = "$ofile" || mv "$cofile" "$ofile"
|
||||||
|
elif test -f "${cofile}bj"; then
|
||||||
|
test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile"
|
||||||
|
fi
|
||||||
|
|
||||||
|
rmdir "$lockdir"
|
||||||
|
exit $ret
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# mode: shell-script
|
||||||
|
# sh-indentation: 2
|
||||||
|
# eval: (add-hook 'before-save-hook 'time-stamp)
|
||||||
|
# time-stamp-start: "scriptversion="
|
||||||
|
# time-stamp-format: "%:y-%02m-%02d.%02H"
|
||||||
|
# time-stamp-time-zone: "UTC0"
|
||||||
|
# time-stamp-end: "; # UTC"
|
||||||
|
# End:
|
1233
libs/libpng-src/config.guess
vendored
1233
libs/libpng-src/config.guess
vendored
File diff suppressed because it is too large
Load diff
127
libs/libpng-src/config.h
Normal file
127
libs/libpng-src/config.h
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
/* config.h. Generated from config.h.in by configure. */
|
||||||
|
/* config.h.in. Generated from configure.ac by autoheader. */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||||
|
/* #undef HAVE_DLFCN_H */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `feenableexcept' function. */
|
||||||
|
/* #undef HAVE_FEENABLEEXCEPT */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
|
#define HAVE_INTTYPES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `m' library (-lm). */
|
||||||
|
/* #undef HAVE_LIBM */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `z' library (-lz). */
|
||||||
|
#define HAVE_LIBZ 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
|
#define HAVE_MEMORY_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `pow' function. */
|
||||||
|
#define HAVE_POW 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdint.h> header file. */
|
||||||
|
#define HAVE_STDINT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <stdlib.h> header file. */
|
||||||
|
#define HAVE_STDLIB_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <strings.h> header file. */
|
||||||
|
#define HAVE_STRINGS_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <string.h> header file. */
|
||||||
|
#define HAVE_STRING_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/stat.h> header file. */
|
||||||
|
#define HAVE_SYS_STAT_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||||
|
#define HAVE_SYS_TYPES_H 1
|
||||||
|
|
||||||
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
|
#define HAVE_UNISTD_H 1
|
||||||
|
|
||||||
|
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
||||||
|
#define LT_OBJDIR ".libs/"
|
||||||
|
|
||||||
|
/* Name of package */
|
||||||
|
#define PACKAGE "libpng"
|
||||||
|
|
||||||
|
/* Define to the address where bug reports for this package should be sent. */
|
||||||
|
#define PACKAGE_BUGREPORT "png-mng-implement@lists.sourceforge.net"
|
||||||
|
|
||||||
|
/* Define to the full name of this package. */
|
||||||
|
#define PACKAGE_NAME "libpng"
|
||||||
|
|
||||||
|
/* Define to the full name and version of this package. */
|
||||||
|
#define PACKAGE_STRING "libpng 1.6.37"
|
||||||
|
|
||||||
|
/* Define to the one symbol short name of this package. */
|
||||||
|
#define PACKAGE_TARNAME "libpng"
|
||||||
|
|
||||||
|
/* Define to the home page for this package. */
|
||||||
|
#define PACKAGE_URL ""
|
||||||
|
|
||||||
|
/* Define to the version of this package. */
|
||||||
|
#define PACKAGE_VERSION "1.6.37"
|
||||||
|
|
||||||
|
/* Turn on ARM Neon optimizations at run-time */
|
||||||
|
/* #undef PNG_ARM_NEON_API_SUPPORTED */
|
||||||
|
|
||||||
|
/* Check for ARM Neon support at run-time */
|
||||||
|
/* #undef PNG_ARM_NEON_CHECK_SUPPORTED */
|
||||||
|
|
||||||
|
/* Enable ARM Neon optimizations */
|
||||||
|
/* #undef PNG_ARM_NEON_OPT */
|
||||||
|
|
||||||
|
/* Enable Intel SSE optimizations */
|
||||||
|
/* #undef PNG_INTEL_SSE_OPT */
|
||||||
|
|
||||||
|
/* Turn on MIPS MSA optimizations at run-time */
|
||||||
|
/* #undef PNG_MIPS_MSA_API_SUPPORTED */
|
||||||
|
|
||||||
|
/* Check for MIPS MSA support at run-time */
|
||||||
|
/* #undef PNG_MIPS_MSA_CHECK_SUPPORTED */
|
||||||
|
|
||||||
|
/* Enable MIPS MSA optimizations */
|
||||||
|
/* #undef PNG_MIPS_MSA_OPT */
|
||||||
|
|
||||||
|
/* Turn on POWERPC VSX optimizations at run-time */
|
||||||
|
/* #undef PNG_POWERPC_VSX_API_SUPPORTED */
|
||||||
|
|
||||||
|
/* Check for POWERPC VSX support at run-time */
|
||||||
|
/* #undef PNG_POWERPC_VSX_CHECK_SUPPORTED */
|
||||||
|
|
||||||
|
/* Enable POWERPC VSX optimizations */
|
||||||
|
/* #undef PNG_POWERPC_VSX_OPT */
|
||||||
|
|
||||||
|
/* Define to 1 if you have the ANSI C header files. */
|
||||||
|
#define STDC_HEADERS 1
|
||||||
|
|
||||||
|
/* Define to 1 if your <sys/time.h> declares `struct tm'. */
|
||||||
|
/* #undef TM_IN_SYS_TIME */
|
||||||
|
|
||||||
|
/* Version number of package */
|
||||||
|
#define VERSION "1.6.37"
|
||||||
|
|
||||||
|
/* Define to empty if `const' does not conform to ANSI C. */
|
||||||
|
/* #undef const */
|
||||||
|
|
||||||
|
/* Define to the equivalent of the C99 'restrict' keyword, or to
|
||||||
|
nothing if this is not supported. Do not define if restrict is
|
||||||
|
supported directly. */
|
||||||
|
#define restrict __restrict
|
||||||
|
/* Work around a bug in Sun C++: it does not support _Restrict or
|
||||||
|
__restrict__, even though the corresponding Sun C compiler ends up with
|
||||||
|
"#define restrict _Restrict" or "#define restrict __restrict__" in the
|
||||||
|
previous line. Perhaps some future version of Sun C++ will work with
|
||||||
|
restrict; if so, hopefully it defines __RESTRICT like Sun C does. */
|
||||||
|
#if defined __SUNPRO_CC && !defined __RESTRICT
|
||||||
|
# define _Restrict
|
||||||
|
# define __restrict__
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||||
|
/* #undef size_t */
|
|
@ -3,6 +3,9 @@
|
||||||
/* Define to 1 if you have the <dlfcn.h> header file. */
|
/* Define to 1 if you have the <dlfcn.h> header file. */
|
||||||
#undef HAVE_DLFCN_H
|
#undef HAVE_DLFCN_H
|
||||||
|
|
||||||
|
/* Define to 1 if you have the `feenableexcept' function. */
|
||||||
|
#undef HAVE_FEENABLEEXCEPT
|
||||||
|
|
||||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
#undef HAVE_INTTYPES_H
|
#undef HAVE_INTTYPES_H
|
||||||
|
|
||||||
|
@ -12,15 +15,9 @@
|
||||||
/* Define to 1 if you have the `z' library (-lz). */
|
/* Define to 1 if you have the `z' library (-lz). */
|
||||||
#undef HAVE_LIBZ
|
#undef HAVE_LIBZ
|
||||||
|
|
||||||
/* Define to 1 if you have the <malloc.h> header file. */
|
|
||||||
#undef HAVE_MALLOC_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <memory.h> header file. */
|
/* Define to 1 if you have the <memory.h> header file. */
|
||||||
#undef HAVE_MEMORY_H
|
#undef HAVE_MEMORY_H
|
||||||
|
|
||||||
/* Define to 1 if you have the `memset' function. */
|
|
||||||
#undef HAVE_MEMSET
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `pow' function. */
|
/* Define to 1 if you have the `pow' function. */
|
||||||
#undef HAVE_POW
|
#undef HAVE_POW
|
||||||
|
|
||||||
|
@ -45,8 +42,7 @@
|
||||||
/* Define to 1 if you have the <unistd.h> header file. */
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
#undef HAVE_UNISTD_H
|
#undef HAVE_UNISTD_H
|
||||||
|
|
||||||
/* Define to the sub-directory in which libtool stores uninstalled libraries.
|
/* Define to the sub-directory where libtool stores uninstalled libraries. */
|
||||||
*/
|
|
||||||
#undef LT_OBJDIR
|
#undef LT_OBJDIR
|
||||||
|
|
||||||
/* Name of package */
|
/* Name of package */
|
||||||
|
@ -70,6 +66,36 @@
|
||||||
/* Define to the version of this package. */
|
/* Define to the version of this package. */
|
||||||
#undef PACKAGE_VERSION
|
#undef PACKAGE_VERSION
|
||||||
|
|
||||||
|
/* Turn on ARM Neon optimizations at run-time */
|
||||||
|
#undef PNG_ARM_NEON_API_SUPPORTED
|
||||||
|
|
||||||
|
/* Check for ARM Neon support at run-time */
|
||||||
|
#undef PNG_ARM_NEON_CHECK_SUPPORTED
|
||||||
|
|
||||||
|
/* Enable ARM Neon optimizations */
|
||||||
|
#undef PNG_ARM_NEON_OPT
|
||||||
|
|
||||||
|
/* Enable Intel SSE optimizations */
|
||||||
|
#undef PNG_INTEL_SSE_OPT
|
||||||
|
|
||||||
|
/* Turn on MIPS MSA optimizations at run-time */
|
||||||
|
#undef PNG_MIPS_MSA_API_SUPPORTED
|
||||||
|
|
||||||
|
/* Check for MIPS MSA support at run-time */
|
||||||
|
#undef PNG_MIPS_MSA_CHECK_SUPPORTED
|
||||||
|
|
||||||
|
/* Enable MIPS MSA optimizations */
|
||||||
|
#undef PNG_MIPS_MSA_OPT
|
||||||
|
|
||||||
|
/* Turn on POWERPC VSX optimizations at run-time */
|
||||||
|
#undef PNG_POWERPC_VSX_API_SUPPORTED
|
||||||
|
|
||||||
|
/* Check for POWERPC VSX support at run-time */
|
||||||
|
#undef PNG_POWERPC_VSX_CHECK_SUPPORTED
|
||||||
|
|
||||||
|
/* Enable POWERPC VSX optimizations */
|
||||||
|
#undef PNG_POWERPC_VSX_OPT
|
||||||
|
|
||||||
/* Define to 1 if you have the ANSI C header files. */
|
/* Define to 1 if you have the ANSI C header files. */
|
||||||
#undef STDC_HEADERS
|
#undef STDC_HEADERS
|
||||||
|
|
||||||
|
@ -82,5 +108,19 @@
|
||||||
/* Define to empty if `const' does not conform to ANSI C. */
|
/* Define to empty if `const' does not conform to ANSI C. */
|
||||||
#undef const
|
#undef const
|
||||||
|
|
||||||
|
/* Define to the equivalent of the C99 'restrict' keyword, or to
|
||||||
|
nothing if this is not supported. Do not define if restrict is
|
||||||
|
supported directly. */
|
||||||
|
#undef restrict
|
||||||
|
/* Work around a bug in Sun C++: it does not support _Restrict or
|
||||||
|
__restrict__, even though the corresponding Sun C compiler ends up with
|
||||||
|
"#define restrict _Restrict" or "#define restrict __restrict__" in the
|
||||||
|
previous line. Perhaps some future version of Sun C++ will work with
|
||||||
|
restrict; if so, hopefully it defines __RESTRICT like Sun C does. */
|
||||||
|
#if defined __SUNPRO_CC && !defined __RESTRICT
|
||||||
|
# define _Restrict
|
||||||
|
# define __restrict__
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
/* Define to `unsigned int' if <sys/types.h> does not define. */
|
||||||
#undef size_t
|
#undef size_t
|
||||||
|
|
2026
libs/libpng-src/config.status
Normal file
2026
libs/libpng-src/config.status
Normal file
File diff suppressed because it is too large
Load diff
579
libs/libpng-src/config.sub
vendored
579
libs/libpng-src/config.sub
vendored
File diff suppressed because it is too large
Load diff
7135
libs/libpng-src/configure
vendored
7135
libs/libpng-src/configure
vendored
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,12 @@
|
||||||
# configure.ac
|
# configure.ac
|
||||||
|
|
||||||
|
# Copyright (c) 2018 Cosmin Truta
|
||||||
|
# Copyright (c) 2004-2016 Glenn Randers-Pehrson
|
||||||
|
|
||||||
|
# This code is released under the libpng license.
|
||||||
|
# For conditions of distribution and use, see the disclaimer
|
||||||
|
# and license in png.h
|
||||||
|
|
||||||
dnl Process this file with autoconf to produce a configure script.
|
dnl Process this file with autoconf to produce a configure script.
|
||||||
dnl
|
dnl
|
||||||
dnl Minor upgrades (compatible ABI): increment the package version
|
dnl Minor upgrades (compatible ABI): increment the package version
|
||||||
|
@ -14,72 +21,178 @@ dnl Makefile.am to upgrade the package name.
|
||||||
dnl This is here to prevent earlier autoconf from being used, it
|
dnl This is here to prevent earlier autoconf from being used, it
|
||||||
dnl should not be necessary to regenerate configure if the time
|
dnl should not be necessary to regenerate configure if the time
|
||||||
dnl stamps are correct
|
dnl stamps are correct
|
||||||
AC_PREREQ(2.59)
|
AC_PREREQ([2.68])
|
||||||
|
|
||||||
dnl Version number stuff here:
|
dnl Version number stuff here:
|
||||||
|
|
||||||
AC_INIT([libpng], [1.2.46], [png-mng-implement@lists.sourceforge.net])
|
AC_INIT([libpng],[1.6.37],[png-mng-implement@lists.sourceforge.net])
|
||||||
AM_INIT_AUTOMAKE
|
AC_CONFIG_MACRO_DIR([scripts])
|
||||||
dnl stop configure from automagically running automake
|
|
||||||
|
# libpng does not follow GNU file name conventions (hence 'foreign')
|
||||||
|
# color-tests requires automake 1.11 or later
|
||||||
|
# silent-rules requires automake 1.11 or later
|
||||||
|
# dist-xz requires automake 1.11 or later
|
||||||
|
# 1.12.2 fixes a security issue in 1.11.2 and 1.12.1
|
||||||
|
# 1.13 is required for parallel tests
|
||||||
|
AM_INIT_AUTOMAKE([1.13 foreign dist-xz color-tests silent-rules subdir-objects])
|
||||||
|
# The following line causes --disable-maintainer-mode to be the default to
|
||||||
|
# configure. This is necessary because libpng distributions cannot rely on the
|
||||||
|
# time stamps of the autotools generated files being correct
|
||||||
AM_MAINTAINER_MODE
|
AM_MAINTAINER_MODE
|
||||||
|
|
||||||
PNGLIB_VERSION=1.2.46
|
dnl configure.ac and Makefile.am expect automake 1.11.2 or a compatible later
|
||||||
|
dnl version; aclocal.m4 will generate a failure if you use a prior version of
|
||||||
|
dnl automake, so the following is not necessary (and is not defined anyway):
|
||||||
|
dnl AM_PREREQ([1.11.2])
|
||||||
|
dnl stop configure from automagically running automake
|
||||||
|
|
||||||
|
PNGLIB_VERSION=1.6.37
|
||||||
PNGLIB_MAJOR=1
|
PNGLIB_MAJOR=1
|
||||||
PNGLIB_MINOR=2
|
PNGLIB_MINOR=6
|
||||||
PNGLIB_RELEASE=46
|
PNGLIB_RELEASE=37
|
||||||
|
|
||||||
dnl End of version number stuff
|
dnl End of version number stuff
|
||||||
|
|
||||||
AC_CONFIG_SRCDIR([pngget.c])
|
AC_CONFIG_SRCDIR([pngget.c])
|
||||||
AM_CONFIG_HEADER(config.h)
|
AC_CONFIG_HEADERS([config.h])
|
||||||
|
|
||||||
# Checks for programs.
|
# Checks for programs.
|
||||||
|
AC_LANG([C])
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
AC_PROG_LD
|
AM_PROG_AS
|
||||||
|
LT_PATH_LD
|
||||||
AC_PROG_CPP
|
AC_PROG_CPP
|
||||||
AC_CHECK_TOOL(SED, sed, :)
|
AC_PROG_AWK
|
||||||
AC_LIBTOOL_WIN32_DLL
|
|
||||||
AC_PROG_INSTALL
|
AC_PROG_INSTALL
|
||||||
AC_PROG_LN_S
|
AC_PROG_LN_S
|
||||||
AC_PROG_MAKE_SET
|
AC_PROG_MAKE_SET
|
||||||
AC_PROG_LIBTOOL
|
|
||||||
|
dnl libtool/libtoolize; version 2.4.2 is the tested version. This or any
|
||||||
|
dnl compatible later version may be used
|
||||||
|
LT_INIT([win32-dll])
|
||||||
|
LT_PREREQ([2.4.2])
|
||||||
|
|
||||||
|
# Some awks crash when confronted with pnglibconf.dfa, do a test run now
|
||||||
|
# to make sure this doesn't happen
|
||||||
|
AC_MSG_CHECKING([that AWK works])
|
||||||
|
if ${AWK} -f ${srcdir}/scripts/options.awk out="/dev/null" version=search\
|
||||||
|
${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\
|
||||||
|
${srcdir}/pngusr.dfa 1>&2
|
||||||
|
then
|
||||||
|
AC_MSG_RESULT([ok])
|
||||||
|
else
|
||||||
|
AC_MSG_FAILURE([failed], 1)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# This is a remnant of the old cc -E validation, where it may have been
|
||||||
|
# necessary to use a different preprocessor for .dfn files
|
||||||
|
DFNCPP="$CPP"
|
||||||
|
AC_SUBST(DFNCPP)
|
||||||
|
|
||||||
|
# -Werror cannot be passed to GCC in CFLAGS because configure will fail (it
|
||||||
|
# checks the compiler with a program that generates a warning), add the
|
||||||
|
# following option to deal with this
|
||||||
|
AC_ARG_VAR(PNG_COPTS,
|
||||||
|
[additional flags for the C compiler, use this for options that would]
|
||||||
|
[cause configure itself to fail])
|
||||||
|
AC_ARG_ENABLE(werror,
|
||||||
|
AS_HELP_STRING([[[--enable-werror[=OPT]]]],
|
||||||
|
[Pass -Werror or the given argument to the compiler if it is supported]),
|
||||||
|
[test "$enable_werror" = "yes" && enable_werror="-Werror"
|
||||||
|
if test "$enable_werror" != "no"; then
|
||||||
|
sav_CFLAGS="$CFLAGS"
|
||||||
|
CFLAGS="$enable_werror $CFLAGS"
|
||||||
|
AC_MSG_CHECKING([if the compiler allows $enable_werror])
|
||||||
|
AC_COMPILE_IFELSE(
|
||||||
|
[AC_LANG_SOURCE([
|
||||||
|
[int main(int argc, char **argv){]
|
||||||
|
[return argv[argc-1][0];]
|
||||||
|
[}]])],
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
PNG_COPTS="$PNG_COPTS $enable_werror",
|
||||||
|
AC_MSG_RESULT(no))
|
||||||
|
CFLAGS="$sav_CFLAGS"
|
||||||
|
fi],)
|
||||||
|
|
||||||
|
# For GCC 5 the default mode for C is -std=gnu11 instead of -std=gnu89
|
||||||
|
# In pngpriv.h we request just the POSIX 1003.1 and C89 APIs by defining _POSIX_SOURCE to 1
|
||||||
|
# This is incompatible with the new default mode, so we test for that and force the
|
||||||
|
# "-std=c89" compiler option:
|
||||||
|
AC_MSG_CHECKING([if we need to force back C standard to C89])
|
||||||
|
AC_COMPILE_IFELSE(
|
||||||
|
[AC_LANG_PROGRAM([
|
||||||
|
[#define _POSIX_SOURCE 1]
|
||||||
|
[#include <stdio.h>]
|
||||||
|
])],
|
||||||
|
AC_MSG_RESULT(no),[
|
||||||
|
if test "x$GCC" != "xyes"; then
|
||||||
|
AC_MSG_ERROR(
|
||||||
|
[Forcing back to C89 is required but the flags are only known for GCC])
|
||||||
|
fi
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
CFLAGS="$CFLAGS -std=c89"
|
||||||
|
])
|
||||||
|
|
||||||
# Checks for header files.
|
# Checks for header files.
|
||||||
AC_HEADER_STDC
|
AC_HEADER_STDC
|
||||||
AC_CHECK_HEADERS([malloc.h stdlib.h string.h strings.h])
|
|
||||||
|
|
||||||
# Checks for typedefs, structures, and compiler characteristics.
|
# Checks for typedefs, structures, and compiler characteristics.
|
||||||
AC_C_CONST
|
AC_C_CONST
|
||||||
AC_TYPE_SIZE_T
|
AC_TYPE_SIZE_T
|
||||||
AC_STRUCT_TM
|
AC_STRUCT_TM
|
||||||
|
AC_C_RESTRICT
|
||||||
|
|
||||||
# Checks for library functions.
|
# Checks for library functions.
|
||||||
AC_FUNC_STRTOD
|
AC_FUNC_STRTOD
|
||||||
AC_CHECK_FUNCS([memset], , AC_ERROR([memset not found in libc]))
|
AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_MSG_ERROR(cannot find pow)) )
|
||||||
AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_ERROR([cannot find pow])) )
|
|
||||||
AC_CHECK_LIB(z, zlibVersion, , AC_ERROR([zlib not installed]))
|
|
||||||
|
|
||||||
case $host_os in
|
# Some later POSIX 1003.1 functions are required for test programs, failure here
|
||||||
aix*)
|
# is soft (the corresponding test program is not built).
|
||||||
LIBPNG_DEFINES=-DPNG_CONFIGURE_LIBPNG -D_ALL_SOURCE;;
|
AC_CHECK_FUNC([clock_gettime],,[AC_MSG_WARN([not building timepng])])
|
||||||
*)
|
AM_CONDITIONAL([HAVE_CLOCK_GETTIME], [test "$ac_cv_func_clock_gettime" = "yes"])
|
||||||
LIBPNG_DEFINES=-DPNG_CONFIGURE_LIBPNG;;
|
|
||||||
esac
|
AC_ARG_WITH(zlib-prefix,
|
||||||
AC_MSG_CHECKING(
|
AS_HELP_STRING([[[--with-zlib-prefix]]],
|
||||||
[if assembler code in pnggccrd.c can be compiled without PNG_NO_MMX_CODE])
|
[prefix that may have been used in installed zlib]),
|
||||||
AC_TRY_COMPILE(
|
[ZPREFIX=${withval}],
|
||||||
[#include "$srcdir/pnggccrd.c"],
|
[ZPREFIX='z_'])
|
||||||
[return 0;],
|
AC_CHECK_LIB(z, zlibVersion, ,
|
||||||
AC_MSG_RESULT(yes)
|
AC_CHECK_LIB(z, ${ZPREFIX}zlibVersion, , AC_MSG_ERROR(zlib not installed)))
|
||||||
LIBPNG_NO_MMX="",
|
|
||||||
AC_MSG_RESULT(no)
|
# The following is for pngvalid, to ensure it catches FP errors even on
|
||||||
LIBPNG_NO_MMX=-DPNG_NO_MMX_CODE)
|
# platforms that don't enable FP exceptions, the function appears in the math
|
||||||
LIBPNG_DEFINES=$LIBPNG_DEFINES\ $LIBPNG_NO_MMX
|
# library (typically), it's not an error if it is not found.
|
||||||
AC_SUBST(LIBPNG_DEFINES)
|
AC_CHECK_LIB([m], [feenableexcept])
|
||||||
AC_SUBST(LIBPNG_NO_MMX)
|
AC_CHECK_FUNCS([feenableexcept])
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([if using Solaris linker])
|
||||||
|
SLD=`$LD --version 2>&1 | grep Solaris`
|
||||||
|
if test "$SLD"; then
|
||||||
|
have_solaris_ld=yes
|
||||||
|
AC_MSG_RESULT(yes)
|
||||||
|
else
|
||||||
|
have_solaris_ld=no
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
fi
|
||||||
|
AM_CONDITIONAL(HAVE_SOLARIS_LD, test "$have_solaris_ld" = "yes")
|
||||||
|
|
||||||
AC_MSG_CHECKING([if libraries can be versioned])
|
AC_MSG_CHECKING([if libraries can be versioned])
|
||||||
GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script`
|
# Special case for PE/COFF platforms: ld reports
|
||||||
|
# support for version-script, but doesn't actually
|
||||||
|
# DO anything with it.
|
||||||
|
case $host in
|
||||||
|
*cygwin* | *mingw32* | *interix* )
|
||||||
|
have_ld_version_script=no
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
;;
|
||||||
|
* )
|
||||||
|
|
||||||
|
if test "$have_solaris_ld" = "yes"; then
|
||||||
|
GLD=`$LD --help < /dev/null 2>&1 | grep 'M mapfile'`
|
||||||
|
else
|
||||||
|
GLD=`$LD --help < /dev/null 2>/dev/null | grep version-script`
|
||||||
|
fi
|
||||||
|
|
||||||
if test "$GLD"; then
|
if test "$GLD"; then
|
||||||
have_ld_version_script=yes
|
have_ld_version_script=yes
|
||||||
AC_MSG_RESULT(yes)
|
AC_MSG_RESULT(yes)
|
||||||
|
@ -88,14 +201,17 @@ else
|
||||||
AC_MSG_RESULT(no)
|
AC_MSG_RESULT(no)
|
||||||
AC_MSG_WARN(*** You have not enabled versioned symbols.)
|
AC_MSG_WARN(*** You have not enabled versioned symbols.)
|
||||||
fi
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
|
AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
|
||||||
|
|
||||||
if test "$have_ld_version_script" = "yes"; then
|
if test "$have_ld_version_script" = "yes"; then
|
||||||
AC_MSG_CHECKING([for symbol prefix])
|
AC_MSG_CHECKING([for symbol prefix])
|
||||||
SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \
|
SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \
|
||||||
| ${CPP-${CC-gcc} -E} - 2>&1 \
|
| ${CPP-${CC-gcc} -E} - 2>&1 \
|
||||||
| ${EGREP-grep} "^PREFIX=" \
|
| ${EGREP-grep} "^PREFIX=" \
|
||||||
| ${SED-sed} "s:^PREFIX=::"`
|
| ${SED-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"`
|
||||||
AC_SUBST(SYMBOL_PREFIX)
|
AC_SUBST(SYMBOL_PREFIX)
|
||||||
AC_MSG_RESULT($SYMBOL_PREFIX)
|
AC_MSG_RESULT($SYMBOL_PREFIX)
|
||||||
fi
|
fi
|
||||||
|
@ -109,45 +225,308 @@ AC_SUBST(PNGLIB_RELEASE)
|
||||||
# Additional arguments (and substitutions)
|
# Additional arguments (and substitutions)
|
||||||
# Allow the pkg-config directory to be set
|
# Allow the pkg-config directory to be set
|
||||||
AC_ARG_WITH(pkgconfigdir,
|
AC_ARG_WITH(pkgconfigdir,
|
||||||
AC_HELP_STRING([--with-pkgconfigdir],
|
AS_HELP_STRING([[[--with-pkgconfigdir]]],
|
||||||
[Use the specified pkgconfig dir (default is libdir/pkgconfig)]),
|
[Use the specified pkgconfig dir (default is libdir/pkgconfig)]),
|
||||||
[pkgconfigdir=${withval}],
|
[pkgconfigdir=${withval}],
|
||||||
[pkgconfigdir='${libdir}/pkgconfig'])
|
[pkgconfigdir='${libdir}/pkgconfig'])
|
||||||
|
|
||||||
AC_SUBST([pkgconfigdir])
|
AC_SUBST([pkgconfigdir])
|
||||||
AC_MSG_NOTICE([pkgconfig directory is ${pkgconfigdir}])
|
AC_MSG_NOTICE([[pkgconfig directory is ${pkgconfigdir}]])
|
||||||
|
|
||||||
# Make the *-config binary config scripts optional
|
# Make the *-config binary config scripts optional
|
||||||
AC_ARG_WITH(binconfigs,
|
AC_ARG_WITH(binconfigs,
|
||||||
AC_HELP_STRING([--with-binconfigs],
|
AS_HELP_STRING([[[--with-binconfigs]]],
|
||||||
[Generate shell libpng-config scripts as well as pkg-config data]
|
[Generate shell libpng-config scripts as well as pkg-config data]
|
||||||
[@<:@default=yes@:>@]),
|
[@<:@default=yes@:>@]),
|
||||||
[if test "${withval}" = no; then
|
[if test "${withval}" = no; then
|
||||||
binconfigs=
|
binconfigs=
|
||||||
AC_MSG_NOTICE([libpng-config scripts will not be built])
|
AC_MSG_NOTICE([[libpng-config scripts will not be built]])
|
||||||
else
|
else
|
||||||
binconfigs='${binconfigs}'
|
binconfigs='${binconfigs}'
|
||||||
fi],
|
fi],
|
||||||
[binconfigs='${binconfigs}'])
|
[binconfigs='${binconfigs}'])
|
||||||
AC_SUBST([binconfigs])
|
AC_SUBST([binconfigs])
|
||||||
|
|
||||||
# Allow the old version number library, libpng.so, to be removed from
|
# Support for prefixes to the API function names; this will generate defines
|
||||||
# the build
|
# at the start of the build to rename exported library functions
|
||||||
AC_ARG_WITH(libpng-compat,
|
AC_ARG_WITH(libpng-prefix,
|
||||||
AC_HELP_STRING([--with-libpng-compat],
|
AS_HELP_STRING([[[--with-libpng-prefix]]],
|
||||||
[Generate the obsolete libpng.so library @<:@default=yes@:>@]),
|
[prefix libpng exported function (API) names with the given value]),
|
||||||
[if test "${withval}" = no; then
|
[if test "${withval:-no}" != "no"; then
|
||||||
compatlib=
|
AC_SUBST([PNG_PREFIX], [${withval}])
|
||||||
AC_MSG_NOTICE([libpng.so will not be built])
|
fi])
|
||||||
else
|
AM_CONDITIONAL([DO_PNG_PREFIX], [test "${with_libpng_prefix:-no}" != "no"])
|
||||||
compatlib=libpng.la
|
|
||||||
fi],
|
# Control over what links are made for installed files. Versioned files are
|
||||||
[compatlib=libpng.la])
|
# always installed, when the following options are turned on corresponding
|
||||||
AC_SUBST([compatlib])
|
# unversioned links are also created (normally as symbolic links):
|
||||||
|
AC_ARG_ENABLE([unversioned-links],
|
||||||
|
AS_HELP_STRING([[[--enable-unversioned-links]]],
|
||||||
|
[Installed libpng header files are placed in a versioned subdirectory]
|
||||||
|
[and installed libpng library (including DLL) files are versioned.]
|
||||||
|
[If this option is enabled unversioned links will be created pointing to]
|
||||||
|
[the corresponding installed files. If you use libpng.pc or]
|
||||||
|
[libpng-config for all builds you do not need these links, but if you]
|
||||||
|
[compile programs directly they will typically #include <png.h> and]
|
||||||
|
[link with -lpng; in that case you need the links.]
|
||||||
|
[The links can be installed manually using 'make install-header-links']
|
||||||
|
[and 'make install-library-links' and can be removed using the]
|
||||||
|
[corresponding uninstall- targets. If you do enable this option every]
|
||||||
|
[libpng 'make install' will recreate the links to point to the just]
|
||||||
|
[installed version of libpng. The default is to create the links;]
|
||||||
|
[use --disable-unversioned-links to change this]))
|
||||||
|
|
||||||
|
# The AM_CONDITIONAL test is written so that the default is enabled;
|
||||||
|
# --disable-unversioned-links must be given to turn the option off.
|
||||||
|
AM_CONDITIONAL([DO_INSTALL_LINKS],[test "$enable_unversioned_links" != "no"])
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([unversioned-libpng-pc],
|
||||||
|
AS_HELP_STRING([[[--enable-unversioned-libpng-pc]]],
|
||||||
|
[Install the configuration file 'libpng.pc' as a link to the versioned]
|
||||||
|
[version. This is done by default - use --disable-unversioned-libpng-pc]
|
||||||
|
[to change this.]))
|
||||||
|
AM_CONDITIONAL([DO_INSTALL_LIBPNG_PC],
|
||||||
|
[test "$enable_unversioned_libpng_pc" != "no"])
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([unversioned-libpng-config],
|
||||||
|
AS_HELP_STRING([[[--enable-unversioned-libpng-config]]],
|
||||||
|
[Install the configuration file 'libpng-config' as a link to the]
|
||||||
|
[versioned version. This is done by default - use]
|
||||||
|
[--disable-unversioned-libpng-config to change this.]))
|
||||||
|
AM_CONDITIONAL([DO_INSTALL_LIBPNG_CONFIG],
|
||||||
|
[test "$enable_unversioned_libpng_config" != "no"])
|
||||||
|
|
||||||
|
# HOST SPECIFIC OPTIONS
|
||||||
|
# =====================
|
||||||
|
#
|
||||||
|
# DEFAULT
|
||||||
|
# =======
|
||||||
|
#
|
||||||
|
AC_ARG_ENABLE([hardware-optimizations],
|
||||||
|
AS_HELP_STRING([[[--enable-hardware-optimizations]]],
|
||||||
|
[Enable hardware optimizations: =no/off, yes/on:]),
|
||||||
|
[case "$enableval" in
|
||||||
|
no|off)
|
||||||
|
# disable hardware optimization on all systems:
|
||||||
|
enable_arm_neon=no
|
||||||
|
AC_DEFINE([PNG_ARM_NEON_OPT], [0],
|
||||||
|
[Disable ARM_NEON optimizations])
|
||||||
|
enable_mips_msa=no
|
||||||
|
AC_DEFINE([PNG_MIPS_MSA_OPT], [0],
|
||||||
|
[Disable MIPS_MSA optimizations])
|
||||||
|
enable_powerpc_vsx=no
|
||||||
|
AC_DEFINE([PNG_POWERPC_VSX_OPT], [0],
|
||||||
|
[Disable POWERPC VSX optimizations])
|
||||||
|
enable_intel_sse=no
|
||||||
|
AC_DEFINE([PNG_INTEL_SSE_OPT], [0],
|
||||||
|
[Disable INTEL_SSE optimizations])
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
# allow enabling hardware optimization on any system:
|
||||||
|
case "$host_cpu" in
|
||||||
|
arm*|aarch64*)
|
||||||
|
enable_arm_neon=yes
|
||||||
|
AC_DEFINE([PNG_ARM_NEON_OPT], [0],
|
||||||
|
[Enable ARM_NEON optimizations])
|
||||||
|
;;
|
||||||
|
mipsel*|mips64el*)
|
||||||
|
enable_mips_msa=yes
|
||||||
|
AC_DEFINE([PNG_MIPS_MSA_OPT], [0],
|
||||||
|
[Enable MIPS_MSA optimizations])
|
||||||
|
;;
|
||||||
|
i?86|x86_64)
|
||||||
|
enable_intel_sse=yes
|
||||||
|
AC_DEFINE([PNG_INTEL_SSE_OPT], [1],
|
||||||
|
[Enable Intel SSE optimizations])
|
||||||
|
;;
|
||||||
|
powerpc*|ppc64*)
|
||||||
|
enable_powerpc_vsx=yes
|
||||||
|
AC_DEFINE([PNG_POWERPC_VSX_OPT], [2],
|
||||||
|
[Enable POWERPC VSX optimizations])
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
esac])
|
||||||
|
|
||||||
|
# ARM
|
||||||
|
# ===
|
||||||
|
#
|
||||||
|
# ARM NEON (SIMD) support.
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([arm-neon],
|
||||||
|
AS_HELP_STRING([[[--enable-arm-neon]]],
|
||||||
|
[Enable ARM NEON optimizations: =no/off, check, api, yes/on:]
|
||||||
|
[no/off: disable the optimizations; check: use internal checking code]
|
||||||
|
[(deprecated and poorly supported); api: disable by default, enable by]
|
||||||
|
[a call to png_set_option; yes/on: turn on unconditionally.]
|
||||||
|
[If not specified: determined by the compiler.]),
|
||||||
|
[case "$enableval" in
|
||||||
|
no|off)
|
||||||
|
# disable the default enabling on __ARM_NEON__ systems:
|
||||||
|
AC_DEFINE([PNG_ARM_NEON_OPT], [0],
|
||||||
|
[Disable ARM Neon optimizations])
|
||||||
|
# Prevent inclusion of the assembler files below:
|
||||||
|
enable_arm_neon=no;;
|
||||||
|
check)
|
||||||
|
AC_DEFINE([PNG_ARM_NEON_CHECK_SUPPORTED], [],
|
||||||
|
[Check for ARM Neon support at run-time]);;
|
||||||
|
api)
|
||||||
|
AC_DEFINE([PNG_ARM_NEON_API_SUPPORTED], [],
|
||||||
|
[Turn on ARM Neon optimizations at run-time]);;
|
||||||
|
yes|on)
|
||||||
|
AC_DEFINE([PNG_ARM_NEON_OPT], [2],
|
||||||
|
[Enable ARM Neon optimizations])
|
||||||
|
AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api', if]
|
||||||
|
[you want the optimizations unconditionally pass -mfpu=neon]
|
||||||
|
[to the compiler.]);;
|
||||||
|
*)
|
||||||
|
AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}: invalid value])
|
||||||
|
esac])
|
||||||
|
|
||||||
|
# Add ARM specific files to all builds where the host_cpu is arm ('arm*') or
|
||||||
|
# where ARM optimizations were explicitly requested (this allows a fallback if a
|
||||||
|
# future host CPU does not match 'arm*')
|
||||||
|
|
||||||
|
AM_CONDITIONAL([PNG_ARM_NEON],
|
||||||
|
[test "$enable_arm_neon" != 'no' &&
|
||||||
|
case "$host_cpu" in
|
||||||
|
arm*|aarch64*) :;;
|
||||||
|
*) test "$enable_arm_neon" != '';;
|
||||||
|
esac])
|
||||||
|
|
||||||
|
# MIPS
|
||||||
|
# ===
|
||||||
|
#
|
||||||
|
# MIPS MSA (SIMD) support.
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([mips-msa],
|
||||||
|
AS_HELP_STRING([[[--enable-mips-msa]]],
|
||||||
|
[Enable MIPS MSA optimizations: =no/off, check, api, yes/on:]
|
||||||
|
[no/off: disable the optimizations; check: use internal checking code]
|
||||||
|
[(deprecated and poorly supported); api: disable by default, enable by]
|
||||||
|
[a call to png_set_option; yes/on: turn on unconditionally.]
|
||||||
|
[If not specified: determined by the compiler.]),
|
||||||
|
[case "$enableval" in
|
||||||
|
no|off)
|
||||||
|
# disable the default enabling on __mips_msa systems:
|
||||||
|
AC_DEFINE([PNG_MIPS_MSA_OPT], [0],
|
||||||
|
[Disable MIPS MSA optimizations])
|
||||||
|
# Prevent inclusion of the assembler files below:
|
||||||
|
enable_mips_msa=no;;
|
||||||
|
check)
|
||||||
|
AC_DEFINE([PNG_MIPS_MSA_CHECK_SUPPORTED], [],
|
||||||
|
[Check for MIPS MSA support at run-time]);;
|
||||||
|
api)
|
||||||
|
AC_DEFINE([PNG_MIPS_MSA_API_SUPPORTED], [],
|
||||||
|
[Turn on MIPS MSA optimizations at run-time]);;
|
||||||
|
yes|on)
|
||||||
|
AC_DEFINE([PNG_MIPS_MSA_OPT], [2],
|
||||||
|
[Enable MIPS MSA optimizations])
|
||||||
|
AC_MSG_WARN([--enable-mips-msa: please specify 'check' or 'api', if]
|
||||||
|
[you want the optimizations unconditionally pass '-mmsa -mfp64']
|
||||||
|
[to the compiler.]);;
|
||||||
|
*)
|
||||||
|
AC_MSG_ERROR([--enable-mips-msa=${enable_mips_msa}: invalid value])
|
||||||
|
esac])
|
||||||
|
|
||||||
|
# Add MIPS specific files to all builds where the host_cpu is mips ('mips*') or
|
||||||
|
# where MIPS optimizations were explicitly requested (this allows a fallback if a
|
||||||
|
# future host CPU does not match 'mips*')
|
||||||
|
|
||||||
|
AM_CONDITIONAL([PNG_MIPS_MSA],
|
||||||
|
[test "$enable_mips_msa" != 'no' &&
|
||||||
|
case "$host_cpu" in
|
||||||
|
mipsel*|mips64el*) :;;
|
||||||
|
esac])
|
||||||
|
|
||||||
|
# INTEL
|
||||||
|
# =====
|
||||||
|
#
|
||||||
|
# INTEL SSE (SIMD) support.
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([intel-sse],
|
||||||
|
AS_HELP_STRING([[[--enable-intel-sse]]],
|
||||||
|
[Enable Intel SSE optimizations: =no/off, yes/on:]
|
||||||
|
[no/off: disable the optimizations;]
|
||||||
|
[yes/on: enable the optimizations.]
|
||||||
|
[If not specified: determined by the compiler.]),
|
||||||
|
[case "$enableval" in
|
||||||
|
no|off)
|
||||||
|
# disable the default enabling:
|
||||||
|
AC_DEFINE([PNG_INTEL_SSE_OPT], [0],
|
||||||
|
[Disable Intel SSE optimizations])
|
||||||
|
# Prevent inclusion of the assembler files below:
|
||||||
|
enable_intel_sse=no;;
|
||||||
|
yes|on)
|
||||||
|
AC_DEFINE([PNG_INTEL_SSE_OPT], [1],
|
||||||
|
[Enable Intel SSE optimizations]);;
|
||||||
|
*)
|
||||||
|
AC_MSG_ERROR([--enable-intel-sse=${enable_intel_sse}: invalid value])
|
||||||
|
esac])
|
||||||
|
|
||||||
|
# Add Intel specific files to all builds where the host_cpu is Intel ('x86*')
|
||||||
|
# or where Intel optimizations were explicitly requested (this allows a
|
||||||
|
# fallback if a future host CPU does not match 'x86*')
|
||||||
|
AM_CONDITIONAL([PNG_INTEL_SSE],
|
||||||
|
[test "$enable_intel_sse" != 'no' &&
|
||||||
|
case "$host_cpu" in
|
||||||
|
i?86|x86_64) :;;
|
||||||
|
*) test "$enable_intel_sse" != '';;
|
||||||
|
esac])
|
||||||
|
|
||||||
|
# PowerPC
|
||||||
|
# ===
|
||||||
|
#
|
||||||
|
# PowerPC VSX (SIMD) support.
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([powerpc-vsx],
|
||||||
|
AS_HELP_STRING([[[--enable-powerpc-vsx]]],
|
||||||
|
[Enable POWERPC VSX optimizations: =no/off, check, api, yes/on:]
|
||||||
|
[no/off: disable the optimizations; check: use internal checking code]
|
||||||
|
[api: disable by default, enable by a call to png_set_option]
|
||||||
|
[yes/on: turn on unconditionally.]
|
||||||
|
[If not specified: determined by the compiler.]),
|
||||||
|
[case "$enableval" in
|
||||||
|
no|off)
|
||||||
|
# disable the default enabling on __ppc64__ systems:
|
||||||
|
AC_DEFINE([PNG_POWERPC_VSX_OPT], [0],
|
||||||
|
[Disable POWERPC VSX optimizations])
|
||||||
|
# Prevent inclusion of the platform specific files below:
|
||||||
|
enable_powerpc_vsx=no;;
|
||||||
|
check)
|
||||||
|
AC_DEFINE([PNG_POWERPC_VSX_CHECK_SUPPORTED], [],
|
||||||
|
[Check for POWERPC VSX support at run-time])
|
||||||
|
AC_MSG_WARN([--enable-powerpc-vsx Please check contrib/powerpc/README file]
|
||||||
|
[for the list of supported OSes.]);;
|
||||||
|
api)
|
||||||
|
AC_DEFINE([PNG_POWERPC_VSX_API_SUPPORTED], [],
|
||||||
|
[Turn on POWERPC VSX optimizations at run-time]);;
|
||||||
|
yes|on)
|
||||||
|
AC_DEFINE([PNG_POWERPC_VSX_OPT], [2],
|
||||||
|
[Enable POWERPC VSX optimizations])
|
||||||
|
AC_MSG_WARN([--enable-powerpc-vsx: please specify 'check' or 'api', if]
|
||||||
|
[you want the optimizations unconditionally pass '-maltivec -mvsx']
|
||||||
|
[or '-mcpu=power8'to the compiler.]);;
|
||||||
|
*)
|
||||||
|
AC_MSG_ERROR([--enable-powerpc-vsx=${enable_powerpc_vsx}: invalid value])
|
||||||
|
esac])
|
||||||
|
|
||||||
|
# Add PowerPC specific files to all builds where the host_cpu is powerpc('powerpc*') or
|
||||||
|
# where POWERPC optimizations were explicitly requested (this allows a fallback if a
|
||||||
|
# future host CPU does not match 'powerpc*')
|
||||||
|
|
||||||
|
AM_CONDITIONAL([PNG_POWERPC_VSX],
|
||||||
|
[test "$enable_powerpc_vsx" != 'no' &&
|
||||||
|
case "$host_cpu" in
|
||||||
|
powerpc*|ppc64*) :;;
|
||||||
|
esac])
|
||||||
|
|
||||||
|
|
||||||
|
AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
|
||||||
|
|
||||||
# Config files, substituting as above
|
# Config files, substituting as above
|
||||||
AC_CONFIG_FILES([Makefile libpng.pc:scripts/libpng.pc-configure.in])
|
AC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in])
|
||||||
AC_CONFIG_FILES([libpng-config:scripts/libpng-config.in],
|
AC_CONFIG_FILES([libpng-config:libpng-config.in],
|
||||||
[chmod +x libpng-config])
|
[chmod +x libpng-config])
|
||||||
|
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|
5
libs/libpng-src/contrib/README.txt
Normal file
5
libs/libpng-src/contrib/README.txt
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
This "contrib" directory contains contributions which are not necessarily under
|
||||||
|
the libpng license, although all are open source. They are not part of
|
||||||
|
libpng proper and are not used for building the library, although some are used
|
||||||
|
for testing the library via "make check".
|
83
libs/libpng-src/contrib/arm-neon/README
Normal file
83
libs/libpng-src/contrib/arm-neon/README
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
OPERATING SYSTEM SPECIFIC ARM NEON DETECTION
|
||||||
|
--------------------------------------------
|
||||||
|
|
||||||
|
Detection of the ability to execute ARM NEON on an ARM processor requires
|
||||||
|
operating system support. (The information is not available in user mode.)
|
||||||
|
|
||||||
|
HOW TO USE THIS
|
||||||
|
---------------
|
||||||
|
|
||||||
|
This directory contains C code fragments that can be included in arm/arm_init.c
|
||||||
|
by setting the macro PNG_ARM_NEON_FILE to the file name in "" or <> at build
|
||||||
|
time. This setting is not recorded in pnglibconf.h and can be changed simply by
|
||||||
|
rebuilding arm/arm_init.o with the required macro definition.
|
||||||
|
|
||||||
|
For any of this code to be used the ARM NEON code must be enabled and run time
|
||||||
|
checks must be supported. I.e.:
|
||||||
|
|
||||||
|
#if PNG_ARM_NEON_OPT > 0
|
||||||
|
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED
|
||||||
|
|
||||||
|
This is done in a 'configure' build by passing configure the argument:
|
||||||
|
|
||||||
|
--enable-arm-neon=check
|
||||||
|
|
||||||
|
Apart from the basic Linux implementation in contrib/arm-neon/linux.c this code
|
||||||
|
is unsupported. That means that it is not even compiled on a regular basis and
|
||||||
|
may be broken in any given minor release.
|
||||||
|
|
||||||
|
FILE FORMAT
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Each file documents its testing status as of the last time it was tested (which
|
||||||
|
may have been a long time ago):
|
||||||
|
|
||||||
|
STATUS: one of:
|
||||||
|
SUPPORTED: This indicates that the file is included in the regularly
|
||||||
|
performed test builds and bugs are fixed when discovered.
|
||||||
|
COMPILED: This indicates that the code did compile at least once. See the
|
||||||
|
more detailed description for the extent to which the result was
|
||||||
|
successful.
|
||||||
|
TESTED: This means the code was fully compiled into the libpng test programs
|
||||||
|
and these were run at least once.
|
||||||
|
|
||||||
|
BUG REPORTS: an email address to which to send reports of problems
|
||||||
|
|
||||||
|
The file is a fragment of C code. It should not define any 'extern' symbols;
|
||||||
|
everything should be static. It must define the function:
|
||||||
|
|
||||||
|
static int png_have_neon(png_structp png_ptr);
|
||||||
|
|
||||||
|
That function must return 1 if ARM NEON instructions are supported, 0 if not.
|
||||||
|
It must not execute png_error unless it detects a bug. A png_error will prevent
|
||||||
|
the reading of the PNG and in the future, writing too.
|
||||||
|
|
||||||
|
BUG REPORTS
|
||||||
|
-----------
|
||||||
|
|
||||||
|
If you mail a bug report for any file that is not SUPPORTED there may only be
|
||||||
|
limited response. Consider fixing it and sending a patch to fix the problem -
|
||||||
|
this is more likely to result in action.
|
||||||
|
|
||||||
|
CONTRIBUTIONS
|
||||||
|
-------------
|
||||||
|
|
||||||
|
You may send contributions of new implementations to
|
||||||
|
png-mng-implement@sourceforge.net. Please write code in strict C90 C where
|
||||||
|
possible. Obviously OS dependencies are to be expected. If you submit code you
|
||||||
|
must have the authors permission and it must have a license that is acceptable
|
||||||
|
to the current maintainer; in particular that license must permit modification
|
||||||
|
and redistribution.
|
||||||
|
|
||||||
|
Please try to make the contribution a single file and give the file a clear and
|
||||||
|
unambiguous name that identifies the target OS. If multiple files really are
|
||||||
|
required put them all in a sub-directory.
|
||||||
|
|
||||||
|
You must also be prepared to handle bug reports from users of the code, either
|
||||||
|
by joining the png-mng-implement mailing list or by providing an email for the
|
||||||
|
"BUG REPORTS" entry or both. Please make sure that the header of the file
|
||||||
|
contains the STATUS and BUG REPORTS fields as above.
|
||||||
|
|
||||||
|
Please list the OS requirements as precisely as possible. Ideally you should
|
||||||
|
also list the environment in which the code has been tested and certainly list
|
||||||
|
any environments where you suspect it might not work.
|
39
libs/libpng-src/contrib/arm-neon/android-ndk.c
Normal file
39
libs/libpng-src/contrib/arm-neon/android-ndk.c
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
/* contrib/arm-neon/android-ndk.c
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||||
|
* Written by John Bowler, 2014.
|
||||||
|
* Last changed in libpng 1.6.10 [March 6, 2014]
|
||||||
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*
|
||||||
|
* SEE contrib/arm-neon/README before reporting bugs
|
||||||
|
*
|
||||||
|
* STATUS: COMPILED, UNTESTED
|
||||||
|
* BUG REPORTS: png-mng-implement@sourceforge.net
|
||||||
|
*
|
||||||
|
* png_have_neon implemented for the Android NDK, see:
|
||||||
|
*
|
||||||
|
* Documentation:
|
||||||
|
* http://www.kandroid.org/ndk/docs/CPU-ARM-NEON.html
|
||||||
|
* https://code.google.com/p/android/issues/detail?id=49065
|
||||||
|
*
|
||||||
|
* NOTE: this requires that libpng is built against the Android NDK and linked
|
||||||
|
* with an implementation of the Android ARM 'cpu-features' library. The code
|
||||||
|
* has been compiled only, not linked: no version of the library has been found,
|
||||||
|
* only the header files exist in the NDK.
|
||||||
|
*/
|
||||||
|
#include <cpu-features.h>
|
||||||
|
|
||||||
|
static int
|
||||||
|
png_have_neon(png_structp png_ptr)
|
||||||
|
{
|
||||||
|
/* This is a whole lot easier than the linux code, however it is probably
|
||||||
|
* implemented as below, therefore it is better to cache the result (these
|
||||||
|
* function calls may be slow!)
|
||||||
|
*/
|
||||||
|
PNG_UNUSED(png_ptr)
|
||||||
|
return android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM &&
|
||||||
|
(android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
|
||||||
|
}
|
120
libs/libpng-src/contrib/arm-neon/linux-auxv.c
Normal file
120
libs/libpng-src/contrib/arm-neon/linux-auxv.c
Normal file
|
@ -0,0 +1,120 @@
|
||||||
|
/* contrib/arm-neon/linux-auxv.c
|
||||||
|
*
|
||||||
|
* Copyright (c) 2014 Glenn Randers-Pehrson
|
||||||
|
* Written by Mans Rullgard, 2011.
|
||||||
|
* Last changed in libpng 1.6.10 [March 6, 2014]
|
||||||
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*
|
||||||
|
* SEE contrib/arm-neon/README before reporting bugs
|
||||||
|
*
|
||||||
|
* STATUS: COMPILED, TESTED
|
||||||
|
* BUG REPORTS: png-mng-implement@sourceforge.net
|
||||||
|
*
|
||||||
|
* png_have_neon implemented for Linux versions which allow access to
|
||||||
|
* /proc/self/auxv. This is probably faster, cleaner and safer than the code to
|
||||||
|
* read /proc/cpuinfo in contrib/arm-neon/linux, however it is yet another piece
|
||||||
|
* of potentially untested code and has more complex dependencies than the code
|
||||||
|
* to read cpuinfo.
|
||||||
|
*
|
||||||
|
* This generic __linux__ implementation requires reading /proc/self/auxv and
|
||||||
|
* looking at each element for one that records NEON capabilities.
|
||||||
|
*/
|
||||||
|
#include <unistd.h> /* for POSIX 1003.1 */
|
||||||
|
#include <errno.h> /* for EINTR */
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/stat.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <elf.h>
|
||||||
|
#include <asm/hwcap.h>
|
||||||
|
|
||||||
|
/* A read call may be interrupted, in which case it returns -1 and sets errno to
|
||||||
|
* EINTR if nothing was done, otherwise (if something was done) a partial read
|
||||||
|
* may result.
|
||||||
|
*/
|
||||||
|
static size_t
|
||||||
|
safe_read(png_structp png_ptr, int fd, void *buffer_in, size_t nbytes)
|
||||||
|
{
|
||||||
|
size_t ntotal = 0;
|
||||||
|
char *buffer = png_voidcast(char*, buffer_in);
|
||||||
|
|
||||||
|
while (nbytes > 0)
|
||||||
|
{
|
||||||
|
unsigned int nread;
|
||||||
|
int iread;
|
||||||
|
|
||||||
|
/* Passing nread > INT_MAX to read is implementation defined in POSIX
|
||||||
|
* 1003.1, therefore despite the unsigned argument portable code must
|
||||||
|
* limit the value to INT_MAX!
|
||||||
|
*/
|
||||||
|
if (nbytes > INT_MAX)
|
||||||
|
nread = INT_MAX;
|
||||||
|
|
||||||
|
else
|
||||||
|
nread = (unsigned int)/*SAFE*/nbytes;
|
||||||
|
|
||||||
|
iread = read(fd, buffer, nread);
|
||||||
|
|
||||||
|
if (iread == -1)
|
||||||
|
{
|
||||||
|
/* This is the devil in the details, a read can terminate early with 0
|
||||||
|
* bytes read because of EINTR, yet it still returns -1 otherwise end
|
||||||
|
* of file cannot be distinguished.
|
||||||
|
*/
|
||||||
|
if (errno != EINTR)
|
||||||
|
{
|
||||||
|
png_warning(png_ptr, "/proc read failed");
|
||||||
|
return 0; /* I.e., a permanent failure */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (iread < 0)
|
||||||
|
{
|
||||||
|
/* Not a valid 'read' result: */
|
||||||
|
png_warning(png_ptr, "OS /proc read bug");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (iread > 0)
|
||||||
|
{
|
||||||
|
/* Continue reading until a permanent failure, or EOF */
|
||||||
|
buffer += iread;
|
||||||
|
nbytes -= (unsigned int)/*SAFE*/iread;
|
||||||
|
ntotal += (unsigned int)/*SAFE*/iread;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
return ntotal;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ntotal; /* nbytes == 0 */
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
png_have_neon(png_structp png_ptr)
|
||||||
|
{
|
||||||
|
int fd = open("/proc/self/auxv", O_RDONLY);
|
||||||
|
Elf32_auxv_t aux;
|
||||||
|
|
||||||
|
/* Failsafe: failure to open means no NEON */
|
||||||
|
if (fd == -1)
|
||||||
|
{
|
||||||
|
png_warning(png_ptr, "/proc/self/auxv open failed");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (safe_read(png_ptr, fd, &aux, sizeof aux) == sizeof aux)
|
||||||
|
{
|
||||||
|
if (aux.a_type == AT_HWCAP && (aux.a_un.a_val & HWCAP_NEON) != 0)
|
||||||
|
{
|
||||||
|
close(fd);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
return 0;
|
||||||
|
}
|
161
libs/libpng-src/contrib/arm-neon/linux.c
Normal file
161
libs/libpng-src/contrib/arm-neon/linux.c
Normal file
|
@ -0,0 +1,161 @@
|
||||||
|
/* contrib/arm-neon/linux.c
|
||||||
|
*
|
||||||
|
* Last changed in libpng 1.6.31 [July 27, 2017]
|
||||||
|
* Copyright (c) 2014, 2017 Glenn Randers-Pehrson
|
||||||
|
* Written by John Bowler, 2014, 2017.
|
||||||
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*
|
||||||
|
* SEE contrib/arm-neon/README before reporting bugs
|
||||||
|
*
|
||||||
|
* STATUS: SUPPORTED
|
||||||
|
* BUG REPORTS: png-mng-implement@sourceforge.net
|
||||||
|
*
|
||||||
|
* png_have_neon implemented for Linux by reading the widely available
|
||||||
|
* pseudo-file /proc/cpuinfo.
|
||||||
|
*
|
||||||
|
* This code is strict ANSI-C and is probably moderately portable; it does
|
||||||
|
* however use <stdio.h> and it assumes that /proc/cpuinfo is never localized.
|
||||||
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
static int
|
||||||
|
png_have_neon(png_structp png_ptr)
|
||||||
|
{
|
||||||
|
FILE *f = fopen("/proc/cpuinfo", "rb");
|
||||||
|
|
||||||
|
if (f != NULL)
|
||||||
|
{
|
||||||
|
/* This is a simple state machine which reads the input byte-by-byte until
|
||||||
|
* it gets a match on the 'neon' feature or reaches the end of the stream.
|
||||||
|
*/
|
||||||
|
static const char ch_feature[] = { 70, 69, 65, 84, 85, 82, 69, 83 };
|
||||||
|
static const char ch_neon[] = { 78, 69, 79, 78 };
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
StartLine, Feature, Colon, StartTag, Neon, HaveNeon, SkipTag, SkipLine
|
||||||
|
} state;
|
||||||
|
int counter;
|
||||||
|
|
||||||
|
for (state=StartLine, counter=0;;)
|
||||||
|
{
|
||||||
|
int ch = fgetc(f);
|
||||||
|
|
||||||
|
if (ch == EOF)
|
||||||
|
{
|
||||||
|
/* EOF means error or end-of-file, return false; neon at EOF is
|
||||||
|
* assumed to be a mistake.
|
||||||
|
*/
|
||||||
|
fclose(f);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case StartLine:
|
||||||
|
/* Match spaces at the start of line */
|
||||||
|
if (ch <= 32) /* skip control characters and space */
|
||||||
|
break;
|
||||||
|
|
||||||
|
counter=0;
|
||||||
|
state = Feature;
|
||||||
|
/* FALLTHROUGH */
|
||||||
|
|
||||||
|
case Feature:
|
||||||
|
/* Match 'FEATURE', ASCII case insensitive. */
|
||||||
|
if ((ch & ~0x20) == ch_feature[counter])
|
||||||
|
{
|
||||||
|
if (++counter == (sizeof ch_feature))
|
||||||
|
state = Colon;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* did not match 'feature' */
|
||||||
|
state = SkipLine;
|
||||||
|
/* FALLTHROUGH */
|
||||||
|
|
||||||
|
case SkipLine:
|
||||||
|
skipLine:
|
||||||
|
/* Skip everything until we see linefeed or carriage return */
|
||||||
|
if (ch != 10 && ch != 13)
|
||||||
|
break;
|
||||||
|
|
||||||
|
state = StartLine;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Colon:
|
||||||
|
/* Match any number of space or tab followed by ':' */
|
||||||
|
if (ch == 32 || ch == 9)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (ch == 58) /* i.e. ':' */
|
||||||
|
{
|
||||||
|
state = StartTag;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Either a bad line format or a 'feature' prefix followed by
|
||||||
|
* other characters.
|
||||||
|
*/
|
||||||
|
state = SkipLine;
|
||||||
|
goto skipLine;
|
||||||
|
|
||||||
|
case StartTag:
|
||||||
|
/* Skip space characters before a tag */
|
||||||
|
if (ch == 32 || ch == 9)
|
||||||
|
break;
|
||||||
|
|
||||||
|
state = Neon;
|
||||||
|
counter = 0;
|
||||||
|
/* FALLTHROUGH */
|
||||||
|
|
||||||
|
case Neon:
|
||||||
|
/* Look for 'neon' tag */
|
||||||
|
if ((ch & ~0x20) == ch_neon[counter])
|
||||||
|
{
|
||||||
|
if (++counter == (sizeof ch_neon))
|
||||||
|
state = HaveNeon;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
state = SkipTag;
|
||||||
|
/* FALLTHROUGH */
|
||||||
|
|
||||||
|
case SkipTag:
|
||||||
|
/* Skip non-space characters */
|
||||||
|
if (ch == 10 || ch == 13)
|
||||||
|
state = StartLine;
|
||||||
|
|
||||||
|
else if (ch == 32 || ch == 9)
|
||||||
|
state = StartTag;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HaveNeon:
|
||||||
|
/* Have seen a 'neon' prefix, but there must be a space or new
|
||||||
|
* line character to terminate it.
|
||||||
|
*/
|
||||||
|
if (ch == 10 || ch == 13 || ch == 32 || ch == 9)
|
||||||
|
{
|
||||||
|
fclose(f);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
state = SkipTag;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
png_error(png_ptr, "png_have_neon: internal error (bug)");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_WARNINGS_SUPPORTED
|
||||||
|
else
|
||||||
|
png_warning(png_ptr, "/proc/cpuinfo open failed");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
49
libs/libpng-src/contrib/conftest/README
Normal file
49
libs/libpng-src/contrib/conftest/README
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
This directory contains test configuration files, currently always '.dfa' files
|
||||||
|
intended to be used in the build by setting the make macro DFA_XTRA to the name
|
||||||
|
of the file.
|
||||||
|
|
||||||
|
These files are used in release validation of the 'configure' builds of libpng
|
||||||
|
by building 'make check', or 'make all-am' for cross-builds, with each .dfa
|
||||||
|
file.
|
||||||
|
|
||||||
|
The files in this directory may change between minor releases, however
|
||||||
|
contributions describing specific builds of libpng are welcomed. There is no
|
||||||
|
guarantee that libpng will continue to build with such configurations; support
|
||||||
|
for given configurations can be, and has been, dropped between successive minor
|
||||||
|
releases. However if a .dfa file describing a configuration is not in this
|
||||||
|
directory it is very unlikely that it will be tested before a minor release!
|
||||||
|
|
||||||
|
You can use these .dfa files as the basis of new configurations. Files in this
|
||||||
|
directory should not have any use restrictions or restrictive licenses.
|
||||||
|
|
||||||
|
This directory is not included in the .zip and .7z distributions, which do
|
||||||
|
not contain 'configure' scripts.
|
||||||
|
|
||||||
|
DOCUMENTATION
|
||||||
|
=============
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
${srcdir}/pngusr.dfa
|
||||||
|
${srcdir}/contrib/pngminim/*/pngusr.dfa
|
||||||
|
|
||||||
|
Documentation of the options:
|
||||||
|
${srcdir}/scripts/pnglibconf.dfa
|
||||||
|
|
||||||
|
Documentation of the file format:
|
||||||
|
${srcdir}/scripts/options.awk
|
||||||
|
|
||||||
|
FILE NAMING
|
||||||
|
===========
|
||||||
|
|
||||||
|
File names in this directory may NOT contain any of the five characters:
|
||||||
|
|
||||||
|
- , + * ?
|
||||||
|
|
||||||
|
Neither may they contain any space character.
|
||||||
|
|
||||||
|
While other characters may be used it is strongly suggested that file names be
|
||||||
|
limited to lower case Latiin alphabetic characters (a-z), digits (0-9) and, if
|
||||||
|
necessary the underscore (_) character. File names should be about 8 characters
|
||||||
|
long (excluding the .dfa extension). Submitted .dfa files should have names
|
||||||
|
between 7 and 16 characters long, shorter names (6 characters or less) are
|
||||||
|
reserved for standard tests.
|
57
libs/libpng-src/contrib/conftest/pngcp.dfa
Normal file
57
libs/libpng-src/contrib/conftest/pngcp.dfa
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
# pngcp.dfa
|
||||||
|
# Build time configuration of libpng
|
||||||
|
#
|
||||||
|
# Author: John Bowler
|
||||||
|
# Copyright: (c) John Bowler, 2016
|
||||||
|
# Usage rights:
|
||||||
|
# To the extent possible under law, the author has waived all copyright and
|
||||||
|
# related or neighboring rights to this work. This work is published from:
|
||||||
|
# United States.
|
||||||
|
#
|
||||||
|
# Build libpng with support for pngcp. This means just png_read_png,
|
||||||
|
# png_write_png and small number of configuration settings.
|
||||||
|
#
|
||||||
|
everything = off
|
||||||
|
|
||||||
|
# This option is specific to this configuration; it adds a #define to the
|
||||||
|
# generated pnglibconf.h which turns on the (not portable) timing option for
|
||||||
|
# pngcp. Note that any option is automatically preceded by PNG_; there is no
|
||||||
|
# way round this and this is deliberate.
|
||||||
|
option PNGCP_TIMING
|
||||||
|
|
||||||
|
# Because of the everything off above the option must also be turned on. This
|
||||||
|
# may not be done in one step because it is safer and avoids mis-spelled options
|
||||||
|
# in user .dfa files to error out if an unrecognized option is turned on.
|
||||||
|
option PNGCP_TIMING on
|
||||||
|
|
||||||
|
# Options to turn on png_read_png and png_write_png:
|
||||||
|
option INFO_IMAGE on
|
||||||
|
option SEQUENTIAL_READ on
|
||||||
|
option EASY_ACCESS on
|
||||||
|
option WRITE on
|
||||||
|
option WRITE_16BIT on
|
||||||
|
option WRITE_FILTER on
|
||||||
|
|
||||||
|
# pngcp needs this to preserve unknown chunks, switching all these on means that
|
||||||
|
# pngcp can work without explicit known chunk reading support
|
||||||
|
option UNKNOWN_CHUNKS on
|
||||||
|
option SET_UNKNOWN_CHUNKS on
|
||||||
|
option HANDLE_AS_UNKNOWN on
|
||||||
|
option SAVE_UNKNOWN_CHUNKS on
|
||||||
|
option WRITE_UNKNOWN_CHUNKS on
|
||||||
|
|
||||||
|
# pngcp needs this to handle palette files with invalid indices:
|
||||||
|
option CHECK_FOR_INVALID_INDEX on
|
||||||
|
option GET_PALETTE_MAX on
|
||||||
|
|
||||||
|
# Pre-libpng 1.7 pngcp has to stash text chunks manually, post 1.7 without this
|
||||||
|
# text chunks should be handled as unknown ok.
|
||||||
|
option TEXT on
|
||||||
|
|
||||||
|
# this is used to turn off limits:
|
||||||
|
option USER_LIMITS on
|
||||||
|
option SET_USER_LIMITS on
|
||||||
|
|
||||||
|
# these are just required for specific customizations
|
||||||
|
option WRITE_CUSTOMIZE_ZTXT_COMPRESSION on
|
||||||
|
option WRITE_CUSTOMIZE_COMPRESSION on
|
58
libs/libpng-src/contrib/conftest/read.dfa
Normal file
58
libs/libpng-src/contrib/conftest/read.dfa
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
# read.dfa
|
||||||
|
# Build time configuration of libpng
|
||||||
|
#
|
||||||
|
# Author: John Bowler
|
||||||
|
# Copyright: (c) John Bowler, 2013
|
||||||
|
# Usage rights:
|
||||||
|
# To the extent possible under law, the author has waived all copyright and
|
||||||
|
# related or neighboring rights to this work. This work is published from:
|
||||||
|
# United States.
|
||||||
|
#
|
||||||
|
# Build libpng with basic read support. This enables the lowest level libpng
|
||||||
|
# read API - the one where the calling code has to use a loop to read each row.
|
||||||
|
# At present this is the API used by most programs.
|
||||||
|
#
|
||||||
|
# Support is enabled only for those chunks and transformations that are
|
||||||
|
# typically required - others can be added easily.
|
||||||
|
#
|
||||||
|
|
||||||
|
everything = off
|
||||||
|
|
||||||
|
# The sequential read code is enabled here; the progressive code can be used
|
||||||
|
# instead but there is no point enabling both.
|
||||||
|
|
||||||
|
option SEQUENTIAL_READ on
|
||||||
|
|
||||||
|
# Likewise it is pointless enabling both fixed and floating point APIs. Choose
|
||||||
|
# one or the other for both the API and the internal math.
|
||||||
|
|
||||||
|
#Fixed point:
|
||||||
|
#option FIXED_POINT on
|
||||||
|
#option FLOATING_ARITHMETIC off
|
||||||
|
|
||||||
|
#Floating point:
|
||||||
|
option FLOATING_POINT on
|
||||||
|
option FLOATING_ARITHMETIC on
|
||||||
|
|
||||||
|
# Basic error handling, IO and user memory support. The latter allows the
|
||||||
|
# application program to provide its own implementations of 'malloc' and 'free'.
|
||||||
|
option SETJMP on
|
||||||
|
option STDIO on
|
||||||
|
option USER_MEM on
|
||||||
|
|
||||||
|
# To read the full set of PNG images correctly interlace, transparency and
|
||||||
|
# 16-bit support is required. The application can implement interlace itself,
|
||||||
|
# but very few do and it's no longer possible to disable it when READ is
|
||||||
|
# enabled.
|
||||||
|
option READ_tRNS on
|
||||||
|
option READ_16BIT on
|
||||||
|
|
||||||
|
# Everything else is application dependent. This file assumes the app handles
|
||||||
|
# all the native PNG bit layouts, so it doesn't need any of layout change
|
||||||
|
# transforms, but needs libpng to perform gamma correction. It doesn't do any
|
||||||
|
# colorspace stuff and ignores the 'significant bit' information.
|
||||||
|
#
|
||||||
|
# If your app always expands the image to a limited set of bit layouts you
|
||||||
|
# probably want to consider using the simplified API instead of the low level
|
||||||
|
# one - see png.h and s_read.dfa.
|
||||||
|
option READ_GAMMA on
|
35
libs/libpng-src/contrib/conftest/s_read.dfa
Normal file
35
libs/libpng-src/contrib/conftest/s_read.dfa
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
# s_read.dfa
|
||||||
|
# Build time configuration of libpng
|
||||||
|
#
|
||||||
|
# Author: John Bowler
|
||||||
|
# Copyright: (c) John Bowler, 2013
|
||||||
|
# Usage rights:
|
||||||
|
# To the extent possible under law, the author has waived all copyright and
|
||||||
|
# related or neighboring rights to this work. This work is published from:
|
||||||
|
# United States.
|
||||||
|
#
|
||||||
|
# Build libpng with simplified read support (only). This builds a minimal
|
||||||
|
# libpng able to read all PNG formats and convert them into a small number of
|
||||||
|
# well understood memory formats.
|
||||||
|
#
|
||||||
|
|
||||||
|
everything = off
|
||||||
|
|
||||||
|
option SIMPLIFIED_READ on
|
||||||
|
|
||||||
|
# It isn't necessary to chose fixed or floating point for the APIs because the
|
||||||
|
# simplified API doesn't need fixed or floating point numbers. It is necessary
|
||||||
|
# to chose an internal math implementation. The default (because of 'everything
|
||||||
|
# = off') is fixed point - turn the floating point implementation on if you have
|
||||||
|
# hardware floating point or prefer your software floating point implementation.
|
||||||
|
option FLOATING_ARITHMETIC on
|
||||||
|
|
||||||
|
# This is not strictly necessary, but without it the message strings in the API
|
||||||
|
# will not be filled in
|
||||||
|
option ERROR_TEXT on
|
||||||
|
|
||||||
|
# Switching these options on enables the 'AFIRST' and 'BGR' formats - you don't
|
||||||
|
# need this if you don't use them, they just allow the in-memory layout to be
|
||||||
|
# changed to match common hardware formats.
|
||||||
|
option SIMPLIFIED_READ_AFIRST on
|
||||||
|
option SIMPLIFIED_READ_BGR on
|
33
libs/libpng-src/contrib/conftest/s_write.dfa
Normal file
33
libs/libpng-src/contrib/conftest/s_write.dfa
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
# s_write.dfa
|
||||||
|
# Build time configuration of libpng
|
||||||
|
#
|
||||||
|
# Author: John Bowler
|
||||||
|
# Copyright: (c) John Bowler, 2013
|
||||||
|
# Usage rights:
|
||||||
|
# To the extent possible under law, the author has waived all copyright and
|
||||||
|
# related or neighboring rights to this work. This work is published from:
|
||||||
|
# United States.
|
||||||
|
#
|
||||||
|
# Build libpng with (just) simplified write support
|
||||||
|
#
|
||||||
|
|
||||||
|
everything = off
|
||||||
|
|
||||||
|
option SIMPLIFIED_WRITE on
|
||||||
|
|
||||||
|
# It isn't necessary to chose fixed or floating point for the APIs because the
|
||||||
|
# simplified API doesn't need fixed or floating point numbers. It is necessary
|
||||||
|
# to chose an internal math implementation. The default (because of 'everything
|
||||||
|
# = off') is fixed point - turn the floating point implementation on if you have
|
||||||
|
# hardware floating point or prefer your software floating point implementation.
|
||||||
|
option FLOATING_ARITHMETIC on
|
||||||
|
|
||||||
|
# This is not strictly necessary, but without it the message strings in the API
|
||||||
|
# will not be filled in
|
||||||
|
option ERROR_TEXT on
|
||||||
|
|
||||||
|
# Switching these options on enables the 'AFIRST' and 'BGR' formats - you don't
|
||||||
|
# need this if you don't use them, they just allow the in-memory layout to be
|
||||||
|
# changed to match common hardware formats.
|
||||||
|
option SIMPLIFIED_WRITE_AFIRST on
|
||||||
|
option SIMPLIFIED_WRITE_BGR on
|
36
libs/libpng-src/contrib/conftest/simple.dfa
Normal file
36
libs/libpng-src/contrib/conftest/simple.dfa
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
# simple.dfa
|
||||||
|
# Build time configuration of libpng
|
||||||
|
#
|
||||||
|
# Author: John Bowler
|
||||||
|
# Copyright: (c) John Bowler, 2013
|
||||||
|
# Usage rights:
|
||||||
|
# To the extent possible under law, the author has waived all copyright and
|
||||||
|
# related or neighboring rights to this work. This work is published from:
|
||||||
|
# United States.
|
||||||
|
#
|
||||||
|
# Build libpng with just the simplified APIs (read and write).
|
||||||
|
#
|
||||||
|
|
||||||
|
everything = off
|
||||||
|
|
||||||
|
option SIMPLIFIED_WRITE on
|
||||||
|
option SIMPLIFIED_READ on
|
||||||
|
|
||||||
|
# It isn't necessary to chose fixed or floating point for the APIs because the
|
||||||
|
# simplified API doesn't need fixed or floating point numbers. It is necessary
|
||||||
|
# to chose an internal math implementation. The default (because of 'everything
|
||||||
|
# = off') is fixed point - turn the floating point implementation on if you have
|
||||||
|
# hardware floating point or prefer your software floating point implementation.
|
||||||
|
option FLOATING_ARITHMETIC on
|
||||||
|
|
||||||
|
# This is not strictly necessary, but without it the message strings in the API
|
||||||
|
# will not be filled in
|
||||||
|
option ERROR_TEXT on
|
||||||
|
|
||||||
|
# Switching these options on enables the 'AFIRST' and 'BGR' formats - you don't
|
||||||
|
# need this if you don't use them, they just allow the in-memory layout to be
|
||||||
|
# changed to match common hardware formats.
|
||||||
|
option SIMPLIFIED_READ_AFIRST on
|
||||||
|
option SIMPLIFIED_READ_BGR on
|
||||||
|
option SIMPLIFIED_WRITE_AFIRST on
|
||||||
|
option SIMPLIFIED_WRITE_BGR on
|
45
libs/libpng-src/contrib/conftest/write.dfa
Normal file
45
libs/libpng-src/contrib/conftest/write.dfa
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
# write.dfa
|
||||||
|
# Build time configuration of libpng
|
||||||
|
#
|
||||||
|
# Author: John Bowler
|
||||||
|
# Copyright: (c) John Bowler, 2013
|
||||||
|
# Usage rights:
|
||||||
|
# To the extent possible under law, the author has waived all copyright and
|
||||||
|
# related or neighboring rights to this work. This work is published from:
|
||||||
|
# United States.
|
||||||
|
#
|
||||||
|
# Build libpng with no read support and minimal write support.
|
||||||
|
#
|
||||||
|
|
||||||
|
everything = off
|
||||||
|
|
||||||
|
# Switch on the write code - this makes a minimalist encoder
|
||||||
|
|
||||||
|
option WRITE on
|
||||||
|
|
||||||
|
# Choose fixed or floating point APIs and arithmetic. The choices are
|
||||||
|
# independent but normally they will match. It is typically better to use the
|
||||||
|
# floating point if you have floating point hardware. If you don't know, or
|
||||||
|
# (perhaps) to make libpng smaller used fixed point throughout.
|
||||||
|
|
||||||
|
#Fixed point:
|
||||||
|
#option FIXED_POINT on
|
||||||
|
#option FLOATING_ARITHMETIC off
|
||||||
|
|
||||||
|
#Floating point:
|
||||||
|
option FLOATING_POINT on
|
||||||
|
option FLOATING_ARITHMETIC on
|
||||||
|
|
||||||
|
# Basic error handling, IO and user memory support. The latter allows the
|
||||||
|
# application program to provide its own implementations of 'malloc' and 'free'.
|
||||||
|
option SETJMP on
|
||||||
|
option STDIO on
|
||||||
|
option USER_MEM on
|
||||||
|
|
||||||
|
# Everything else is optional. Unlike the read code in libpng the write code
|
||||||
|
# does not need to deal with arbitrary formats, so only add support for things
|
||||||
|
# you really do write! For example you might only write sRGB images, sometimes
|
||||||
|
# with transparency and never write 16 bit images, so:
|
||||||
|
option WRITE_sRGB on
|
||||||
|
option WRITE_tRNS on
|
||||||
|
#option WRITE_16BIT off (this is the default with 'everything = off')
|
24
libs/libpng-src/contrib/examples/README.txt
Normal file
24
libs/libpng-src/contrib/examples/README.txt
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
|
||||||
|
This directory (contrib/examples) contains examples of libpng usage.
|
||||||
|
|
||||||
|
NO COPYRIGHT RIGHTS ARE CLAIMED TO ANY OF THE FILES IN THIS DIRECTORY.
|
||||||
|
|
||||||
|
To the extent possible under law, the authors have waived all copyright and
|
||||||
|
related or neighboring rights to this work. This work is published from:
|
||||||
|
United States.
|
||||||
|
|
||||||
|
The files may be used freely in any way. The intention is that appropriate
|
||||||
|
parts of the files be used in other libpng-using programs without any need for
|
||||||
|
the authors of the using code to seek copyright or license from the original
|
||||||
|
authors.
|
||||||
|
|
||||||
|
The source code and comments in this directory are the original work of the
|
||||||
|
people named below. No other person or organization has made contributions to
|
||||||
|
the work in this directory.
|
||||||
|
|
||||||
|
ORIGINAL AUTHORS
|
||||||
|
The following people have contributed to the code in this directory. None
|
||||||
|
of the people below claim any rights with regard to the contents of this
|
||||||
|
directory.
|
||||||
|
|
||||||
|
John Bowler <jbowler at acm.org>
|
185
libs/libpng-src/contrib/examples/iccfrompng.c
Normal file
185
libs/libpng-src/contrib/examples/iccfrompng.c
Normal file
|
@ -0,0 +1,185 @@
|
||||||
|
/*- iccfrompng
|
||||||
|
*
|
||||||
|
* COPYRIGHT: Written by John Cunningham Bowler, 2011.
|
||||||
|
* To the extent possible under law, the author has waived all copyright and
|
||||||
|
* related or neighboring rights to this work. This work is published from:
|
||||||
|
* United States.
|
||||||
|
*
|
||||||
|
* Extract any icc profiles found in the given PNG files. This is a simple
|
||||||
|
* example of a program that extracts information from the header of a PNG file
|
||||||
|
* without processing the image. Notice that some header information may occur
|
||||||
|
* after the image data. Textual data and comments are an example; the approach
|
||||||
|
* in this file won't work reliably for such data because it only looks for the
|
||||||
|
* information in the section of the file that precedes the image data.
|
||||||
|
*
|
||||||
|
* Compile and link against libpng and zlib, plus anything else required on the
|
||||||
|
* system you use.
|
||||||
|
*
|
||||||
|
* To use supply a list of PNG files containing iCCP chunks, the chunks will be
|
||||||
|
* extracted to a similarly named file with the extension replaced by 'icc',
|
||||||
|
* which will be overwritten without warning.
|
||||||
|
*/
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <setjmp.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <png.h>
|
||||||
|
|
||||||
|
#if defined(PNG_READ_SUPPORTED) && defined(PNG_STDIO_SUPPORTED) && \
|
||||||
|
defined (PNG_iCCP_SUPPORTED)
|
||||||
|
|
||||||
|
|
||||||
|
static int verbose = 1;
|
||||||
|
static png_byte no_profile[] = "no profile";
|
||||||
|
|
||||||
|
static png_bytep
|
||||||
|
extract(FILE *fp, png_uint_32 *proflen)
|
||||||
|
{
|
||||||
|
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,0);
|
||||||
|
png_infop info_ptr = NULL;
|
||||||
|
png_bytep result = NULL;
|
||||||
|
|
||||||
|
/* Initialize for error or no profile: */
|
||||||
|
*proflen = 0;
|
||||||
|
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "iccfrompng: version library mismatch?\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setjmp(png_jmpbuf(png_ptr)))
|
||||||
|
{
|
||||||
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
png_init_io(png_ptr, fp);
|
||||||
|
|
||||||
|
info_ptr = png_create_info_struct(png_ptr);
|
||||||
|
if (info_ptr == NULL)
|
||||||
|
png_error(png_ptr, "OOM allocating info structure");
|
||||||
|
|
||||||
|
png_read_info(png_ptr, info_ptr);
|
||||||
|
|
||||||
|
{
|
||||||
|
png_charp name;
|
||||||
|
int compression_type;
|
||||||
|
png_bytep profile;
|
||||||
|
|
||||||
|
if (png_get_iCCP(png_ptr, info_ptr, &name, &compression_type, &profile,
|
||||||
|
proflen) & PNG_INFO_iCCP)
|
||||||
|
{
|
||||||
|
result = malloc(*proflen);
|
||||||
|
if (result != NULL)
|
||||||
|
memcpy(result, profile, *proflen);
|
||||||
|
|
||||||
|
else
|
||||||
|
png_error(png_ptr, "OOM allocating profile buffer");
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
result = no_profile;
|
||||||
|
}
|
||||||
|
|
||||||
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
extract_one_file(const char *filename)
|
||||||
|
{
|
||||||
|
int result = 0;
|
||||||
|
FILE *fp = fopen(filename, "rb");
|
||||||
|
|
||||||
|
if (fp != NULL)
|
||||||
|
{
|
||||||
|
png_uint_32 proflen = 0;
|
||||||
|
png_bytep profile = extract(fp, &proflen);
|
||||||
|
|
||||||
|
if (profile != NULL && profile != no_profile)
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
char *output;
|
||||||
|
|
||||||
|
{
|
||||||
|
const char *ep = strrchr(filename, '.');
|
||||||
|
|
||||||
|
if (ep != NULL)
|
||||||
|
len = ep-filename;
|
||||||
|
|
||||||
|
else
|
||||||
|
len = strlen(filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
output = malloc(len + 5);
|
||||||
|
if (output != NULL)
|
||||||
|
{
|
||||||
|
FILE *of;
|
||||||
|
|
||||||
|
memcpy(output, filename, len);
|
||||||
|
strcpy(output+len, ".icc");
|
||||||
|
|
||||||
|
of = fopen(output, "wb");
|
||||||
|
if (of != NULL)
|
||||||
|
{
|
||||||
|
if (fwrite(profile, proflen, 1, of) == 1 &&
|
||||||
|
fflush(of) == 0 &&
|
||||||
|
fclose(of) == 0)
|
||||||
|
{
|
||||||
|
if (verbose)
|
||||||
|
printf("%s -> %s\n", filename, output);
|
||||||
|
/* Success return */
|
||||||
|
result = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: error writing profile\n", output);
|
||||||
|
if (remove(output))
|
||||||
|
fprintf(stderr, "%s: could not remove file\n", output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
fprintf(stderr, "%s: failed to open output file\n", output);
|
||||||
|
|
||||||
|
free(output);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
fprintf(stderr, "%s: OOM allocating string!\n", filename);
|
||||||
|
|
||||||
|
free(profile);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (verbose && profile == no_profile)
|
||||||
|
printf("%s has no profile\n", filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
fprintf(stderr, "%s: could not open file\n", filename);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int extracted = 0;
|
||||||
|
|
||||||
|
for (i=1; i<argc; ++i)
|
||||||
|
{
|
||||||
|
if (strcmp(argv[i], "-q") == 0)
|
||||||
|
verbose = 0;
|
||||||
|
|
||||||
|
else if (extract_one_file(argv[i]))
|
||||||
|
extracted = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Exit code is true if any extract succeeds */
|
||||||
|
return extracted == 0;
|
||||||
|
}
|
||||||
|
#endif /* READ && STDIO && iCCP */
|
371
libs/libpng-src/contrib/examples/pngpixel.c
Normal file
371
libs/libpng-src/contrib/examples/pngpixel.c
Normal file
|
@ -0,0 +1,371 @@
|
||||||
|
/*- pngpixel
|
||||||
|
*
|
||||||
|
* COPYRIGHT: Written by John Cunningham Bowler, 2011.
|
||||||
|
* To the extent possible under law, the author has waived all copyright and
|
||||||
|
* related or neighboring rights to this work. This work is published from:
|
||||||
|
* United States.
|
||||||
|
*
|
||||||
|
* Read a single pixel value from a PNG file.
|
||||||
|
*
|
||||||
|
* This code illustrates basic 'by-row' reading of a PNG file using libpng.
|
||||||
|
* Rows are read until a particular pixel is found; the value of this pixel is
|
||||||
|
* then printed on stdout.
|
||||||
|
*
|
||||||
|
* The code illustrates how to do this on interlaced as well as non-interlaced
|
||||||
|
* images. Normally you would call png_set_interlace_handling() to have libpng
|
||||||
|
* deal with the interlace for you, but that obliges you to buffer half of the
|
||||||
|
* image to assemble the interlaced rows. In this code
|
||||||
|
* png_set_interlace_handling() is not called and, instead, the code handles the
|
||||||
|
* interlace passes directly looking for the required pixel.
|
||||||
|
*/
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <setjmp.h> /* required for error handling */
|
||||||
|
|
||||||
|
/* Normally use <png.h> here to get the installed libpng, but this is done to
|
||||||
|
* ensure the code picks up the local libpng implementation:
|
||||||
|
*/
|
||||||
|
#include "../../png.h"
|
||||||
|
|
||||||
|
#if defined(PNG_READ_SUPPORTED) && defined(PNG_SEQUENTIAL_READ_SUPPORTED)
|
||||||
|
|
||||||
|
/* Return component 'c' of pixel 'x' from the given row. */
|
||||||
|
static unsigned int
|
||||||
|
component(png_const_bytep row, png_uint_32 x, unsigned int c,
|
||||||
|
unsigned int bit_depth, unsigned int channels)
|
||||||
|
{
|
||||||
|
/* PNG images can be up to 2^31 pixels wide, but this means they can be up to
|
||||||
|
* 2^37 bits wide (for a 64-bit pixel - the largest possible) and hence 2^34
|
||||||
|
* bytes wide. Since the row fitted into memory, however, the following must
|
||||||
|
* work:
|
||||||
|
*/
|
||||||
|
png_uint_32 bit_offset_hi = bit_depth * ((x >> 6) * channels);
|
||||||
|
png_uint_32 bit_offset_lo = bit_depth * ((x & 0x3f) * channels + c);
|
||||||
|
|
||||||
|
row = (png_const_bytep)(((const png_byte (*)[8])row) + bit_offset_hi);
|
||||||
|
row += bit_offset_lo >> 3;
|
||||||
|
bit_offset_lo &= 0x07;
|
||||||
|
|
||||||
|
/* PNG pixels are packed into bytes to put the first pixel in the highest
|
||||||
|
* bits of the byte and into two bytes for 16-bit values with the high 8 bits
|
||||||
|
* first, so:
|
||||||
|
*/
|
||||||
|
switch (bit_depth)
|
||||||
|
{
|
||||||
|
case 1: return (row[0] >> (7-bit_offset_lo)) & 0x01;
|
||||||
|
case 2: return (row[0] >> (6-bit_offset_lo)) & 0x03;
|
||||||
|
case 4: return (row[0] >> (4-bit_offset_lo)) & 0x0f;
|
||||||
|
case 8: return row[0];
|
||||||
|
case 16: return (row[0] << 8) + row[1];
|
||||||
|
default:
|
||||||
|
/* This should never happen; it indicates a bug in this program or in
|
||||||
|
* libpng itself:
|
||||||
|
*/
|
||||||
|
fprintf(stderr, "pngpixel: invalid bit depth %u\n", bit_depth);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Print a pixel from a row returned by libpng; determine the row format, find
|
||||||
|
* the pixel, and print the relevant information to stdout.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
|
||||||
|
png_uint_32 x)
|
||||||
|
{
|
||||||
|
unsigned int bit_depth = png_get_bit_depth(png_ptr, info_ptr);
|
||||||
|
|
||||||
|
switch (png_get_color_type(png_ptr, info_ptr))
|
||||||
|
{
|
||||||
|
case PNG_COLOR_TYPE_GRAY:
|
||||||
|
printf("GRAY %u\n", component(row, x, 0, bit_depth, 1));
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* The palette case is slightly more difficult - the palette and, if
|
||||||
|
* present, the tRNS ('transparency', though the values are really
|
||||||
|
* opacity) data must be read to give the full picture:
|
||||||
|
*/
|
||||||
|
case PNG_COLOR_TYPE_PALETTE:
|
||||||
|
{
|
||||||
|
int index = component(row, x, 0, bit_depth, 1);
|
||||||
|
png_colorp palette = NULL;
|
||||||
|
int num_palette = 0;
|
||||||
|
|
||||||
|
if ((png_get_PLTE(png_ptr, info_ptr, &palette, &num_palette) &
|
||||||
|
PNG_INFO_PLTE) && num_palette > 0 && palette != NULL)
|
||||||
|
{
|
||||||
|
png_bytep trans_alpha = NULL;
|
||||||
|
int num_trans = 0;
|
||||||
|
if ((png_get_tRNS(png_ptr, info_ptr, &trans_alpha, &num_trans,
|
||||||
|
NULL) & PNG_INFO_tRNS) && num_trans > 0 &&
|
||||||
|
trans_alpha != NULL)
|
||||||
|
printf("INDEXED %u = %d %d %d %d\n", index,
|
||||||
|
palette[index].red, palette[index].green,
|
||||||
|
palette[index].blue,
|
||||||
|
index < num_trans ? trans_alpha[index] : 255);
|
||||||
|
|
||||||
|
else /* no transparency */
|
||||||
|
printf("INDEXED %u = %d %d %d\n", index,
|
||||||
|
palette[index].red, palette[index].green,
|
||||||
|
palette[index].blue);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
printf("INDEXED %u = invalid index\n", index);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
|
||||||
|
case PNG_COLOR_TYPE_RGB:
|
||||||
|
printf("RGB %u %u %u\n", component(row, x, 0, bit_depth, 3),
|
||||||
|
component(row, x, 1, bit_depth, 3),
|
||||||
|
component(row, x, 2, bit_depth, 3));
|
||||||
|
return;
|
||||||
|
|
||||||
|
case PNG_COLOR_TYPE_GRAY_ALPHA:
|
||||||
|
printf("GRAY+ALPHA %u %u\n", component(row, x, 0, bit_depth, 2),
|
||||||
|
component(row, x, 1, bit_depth, 2));
|
||||||
|
return;
|
||||||
|
|
||||||
|
case PNG_COLOR_TYPE_RGB_ALPHA:
|
||||||
|
printf("RGBA %u %u %u %u\n", component(row, x, 0, bit_depth, 4),
|
||||||
|
component(row, x, 1, bit_depth, 4),
|
||||||
|
component(row, x, 2, bit_depth, 4),
|
||||||
|
component(row, x, 3, bit_depth, 4));
|
||||||
|
return;
|
||||||
|
|
||||||
|
default:
|
||||||
|
png_error(png_ptr, "pngpixel: invalid color type");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, const char **argv)
|
||||||
|
{
|
||||||
|
/* This program uses the default, <setjmp.h> based, libpng error handling
|
||||||
|
* mechanism, therefore any local variable that exists before the call to
|
||||||
|
* setjmp and is changed after the call to setjmp returns successfully must
|
||||||
|
* be declared with 'volatile' to ensure that their values don't get
|
||||||
|
* destroyed by longjmp:
|
||||||
|
*/
|
||||||
|
volatile int result = 1/*fail*/;
|
||||||
|
|
||||||
|
if (argc == 4)
|
||||||
|
{
|
||||||
|
long x = atol(argv[1]);
|
||||||
|
long y = atol(argv[2]);
|
||||||
|
FILE *f = fopen(argv[3], "rb");
|
||||||
|
volatile png_bytep row = NULL;
|
||||||
|
|
||||||
|
if (f != NULL)
|
||||||
|
{
|
||||||
|
/* libpng requires a callback function for handling errors; this
|
||||||
|
* callback must not return. The default callback function uses a
|
||||||
|
* stored <setjmp.h> style jmp_buf which is held in a png_struct and
|
||||||
|
* writes error messages to stderr. Creating the png_struct is a
|
||||||
|
* little tricky; just copy the following code.
|
||||||
|
*/
|
||||||
|
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
|
||||||
|
NULL, NULL, NULL);
|
||||||
|
|
||||||
|
if (png_ptr != NULL)
|
||||||
|
{
|
||||||
|
png_infop info_ptr = png_create_info_struct(png_ptr);
|
||||||
|
|
||||||
|
if (info_ptr != NULL)
|
||||||
|
{
|
||||||
|
/* Declare stack variables to hold pointers to locally allocated
|
||||||
|
* data.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Initialize the error control buffer: */
|
||||||
|
if (setjmp(png_jmpbuf(png_ptr)) == 0)
|
||||||
|
{
|
||||||
|
png_uint_32 width, height;
|
||||||
|
int bit_depth, color_type, interlace_method,
|
||||||
|
compression_method, filter_method;
|
||||||
|
png_bytep row_tmp;
|
||||||
|
|
||||||
|
/* Now associate the recently opened (FILE*) with the default
|
||||||
|
* libpng initialization functions. Sometimes libpng is
|
||||||
|
* compiled without stdio support (it can be difficult to do
|
||||||
|
* in some environments); in that case you will have to write
|
||||||
|
* your own read callback to read data from the (FILE*).
|
||||||
|
*/
|
||||||
|
png_init_io(png_ptr, f);
|
||||||
|
|
||||||
|
/* And read the first part of the PNG file - the header and
|
||||||
|
* all the information up to the first pixel.
|
||||||
|
*/
|
||||||
|
png_read_info(png_ptr, info_ptr);
|
||||||
|
|
||||||
|
/* This fills in enough information to tell us the width of
|
||||||
|
* each row in bytes, allocate the appropriate amount of
|
||||||
|
* space. In this case png_malloc is used - it will not
|
||||||
|
* return if memory isn't available.
|
||||||
|
*/
|
||||||
|
row = png_malloc(png_ptr, png_get_rowbytes(png_ptr,
|
||||||
|
info_ptr));
|
||||||
|
|
||||||
|
/* To avoid the overhead of using a volatile auto copy row_tmp
|
||||||
|
* to a local here - just use row for the png_free below.
|
||||||
|
*/
|
||||||
|
row_tmp = row;
|
||||||
|
|
||||||
|
/* All the information we need is in the header is returned by
|
||||||
|
* png_get_IHDR, if this fails we can now use 'png_error' to
|
||||||
|
* signal the error and return control to the setjmp above.
|
||||||
|
*/
|
||||||
|
if (png_get_IHDR(png_ptr, info_ptr, &width, &height,
|
||||||
|
&bit_depth, &color_type, &interlace_method,
|
||||||
|
&compression_method, &filter_method))
|
||||||
|
{
|
||||||
|
int passes, pass;
|
||||||
|
|
||||||
|
/* png_set_interlace_handling returns the number of
|
||||||
|
* passes required as well as turning on libpng's
|
||||||
|
* handling, but since we do it ourselves this is
|
||||||
|
* necessary:
|
||||||
|
*/
|
||||||
|
switch (interlace_method)
|
||||||
|
{
|
||||||
|
case PNG_INTERLACE_NONE:
|
||||||
|
passes = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PNG_INTERLACE_ADAM7:
|
||||||
|
passes = PNG_INTERLACE_ADAM7_PASSES;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
png_error(png_ptr, "pngpixel: unknown interlace");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now read the pixels, pass-by-pass, row-by-row: */
|
||||||
|
png_start_read_image(png_ptr);
|
||||||
|
|
||||||
|
for (pass=0; pass<passes; ++pass)
|
||||||
|
{
|
||||||
|
png_uint_32 ystart, xstart, ystep, xstep;
|
||||||
|
png_uint_32 py;
|
||||||
|
|
||||||
|
if (interlace_method == PNG_INTERLACE_ADAM7)
|
||||||
|
{
|
||||||
|
/* Sometimes the whole pass is empty because the
|
||||||
|
* image is too narrow or too short. libpng
|
||||||
|
* expects to be called for each row that is
|
||||||
|
* present in the pass, so it may be necessary to
|
||||||
|
* skip the loop below (over py) if the image is
|
||||||
|
* too narrow.
|
||||||
|
*/
|
||||||
|
if (PNG_PASS_COLS(width, pass) == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
/* We need the starting pixel and the offset
|
||||||
|
* between each pixel in this pass; use the macros
|
||||||
|
* in png.h:
|
||||||
|
*/
|
||||||
|
xstart = PNG_PASS_START_COL(pass);
|
||||||
|
ystart = PNG_PASS_START_ROW(pass);
|
||||||
|
xstep = PNG_PASS_COL_OFFSET(pass);
|
||||||
|
ystep = PNG_PASS_ROW_OFFSET(pass);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ystart = xstart = 0;
|
||||||
|
ystep = xstep = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* To find the pixel, loop over 'py' for each pass
|
||||||
|
* reading a row and then checking to see if it
|
||||||
|
* contains the pixel.
|
||||||
|
*/
|
||||||
|
for (py = ystart; py < height; py += ystep)
|
||||||
|
{
|
||||||
|
png_uint_32 px, ppx;
|
||||||
|
|
||||||
|
/* png_read_row takes two pointers. When libpng
|
||||||
|
* handles the interlace the first is filled in
|
||||||
|
* pixel-by-pixel, and the second receives the same
|
||||||
|
* pixels but they are replicated across the
|
||||||
|
* unwritten pixels so far for each pass. When we
|
||||||
|
* do the interlace, however, they just contain
|
||||||
|
* the pixels from the interlace pass - giving
|
||||||
|
* both is wasteful and pointless, so we pass a
|
||||||
|
* NULL pointer.
|
||||||
|
*/
|
||||||
|
png_read_row(png_ptr, row_tmp, NULL);
|
||||||
|
|
||||||
|
/* Now find the pixel if it is in this row; there
|
||||||
|
* are, of course, much better ways of doing this
|
||||||
|
* than using a for loop:
|
||||||
|
*/
|
||||||
|
if (y == py) for (px = xstart, ppx = 0;
|
||||||
|
px < width; px += xstep, ++ppx) if (x == px)
|
||||||
|
{
|
||||||
|
/* 'ppx' is the index of the pixel in the row
|
||||||
|
* buffer.
|
||||||
|
*/
|
||||||
|
print_pixel(png_ptr, info_ptr, row_tmp, ppx);
|
||||||
|
|
||||||
|
/* Now terminate the loops early - we have
|
||||||
|
* found and handled the required data.
|
||||||
|
*/
|
||||||
|
goto pass_loop_end;
|
||||||
|
} /* x loop */
|
||||||
|
} /* y loop */
|
||||||
|
} /* pass loop */
|
||||||
|
|
||||||
|
/* Finally free the temporary buffer: */
|
||||||
|
pass_loop_end:
|
||||||
|
row = NULL;
|
||||||
|
png_free(png_ptr, row_tmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
png_error(png_ptr, "pngpixel: png_get_IHDR failed");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Else libpng has raised an error. An error message has
|
||||||
|
* already been output, so it is only necessary to clean up
|
||||||
|
* locally allocated data:
|
||||||
|
*/
|
||||||
|
if (row != NULL)
|
||||||
|
{
|
||||||
|
/* The default implementation of png_free never errors out
|
||||||
|
* (it just crashes if something goes wrong), but the safe
|
||||||
|
* way of using it is still to clear 'row' before calling
|
||||||
|
* png_free:
|
||||||
|
*/
|
||||||
|
png_bytep row_tmp = row;
|
||||||
|
row = NULL;
|
||||||
|
png_free(png_ptr, row_tmp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
png_destroy_info_struct(png_ptr, &info_ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
fprintf(stderr, "pngpixel: out of memory allocating png_info\n");
|
||||||
|
|
||||||
|
png_destroy_read_struct(&png_ptr, NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
fprintf(stderr, "pngpixel: out of memory allocating png_struct\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
fprintf(stderr, "pngpixel: %s: could not open file\n", argv[3]);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
/* Wrong number of arguments */
|
||||||
|
fprintf(stderr, "pngpixel: usage: pngpixel x y png-file\n");
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endif /* READ && SEQUENTIAL_READ */
|
98
libs/libpng-src/contrib/examples/pngtopng.c
Normal file
98
libs/libpng-src/contrib/examples/pngtopng.c
Normal file
|
@ -0,0 +1,98 @@
|
||||||
|
/*- pngtopng
|
||||||
|
*
|
||||||
|
* COPYRIGHT: Written by John Cunningham Bowler, 2011, 2017.
|
||||||
|
* To the extent possible under law, the author has waived all copyright and
|
||||||
|
* related or neighboring rights to this work. This work is published from:
|
||||||
|
* United States.
|
||||||
|
*
|
||||||
|
* Last changed in libpng 1.6.29 [March 16, 2017]
|
||||||
|
*
|
||||||
|
* Read a PNG and write it out in a fixed format, using the 'simplified API'
|
||||||
|
* that was introduced in libpng-1.6.0.
|
||||||
|
*
|
||||||
|
* This sample code is just the code from the top of 'example.c' with some error
|
||||||
|
* handling added. See example.c for more comments.
|
||||||
|
*/
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
/* Normally use <png.h> here to get the installed libpng, but this is done to
|
||||||
|
* ensure the code picks up the local libpng implementation:
|
||||||
|
*/
|
||||||
|
#include "../../png.h"
|
||||||
|
#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) && \
|
||||||
|
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
|
||||||
|
|
||||||
|
int main(int argc, const char **argv)
|
||||||
|
{
|
||||||
|
int result = 1;
|
||||||
|
|
||||||
|
if (argc == 3)
|
||||||
|
{
|
||||||
|
png_image image;
|
||||||
|
|
||||||
|
/* Only the image structure version number needs to be set. */
|
||||||
|
memset(&image, 0, sizeof image);
|
||||||
|
image.version = PNG_IMAGE_VERSION;
|
||||||
|
|
||||||
|
if (png_image_begin_read_from_file(&image, argv[1]))
|
||||||
|
{
|
||||||
|
png_bytep buffer;
|
||||||
|
|
||||||
|
/* Change this to try different formats! If you set a colormap format
|
||||||
|
* then you must also supply a colormap below.
|
||||||
|
*/
|
||||||
|
image.format = PNG_FORMAT_RGBA;
|
||||||
|
|
||||||
|
buffer = malloc(PNG_IMAGE_SIZE(image));
|
||||||
|
|
||||||
|
if (buffer != NULL)
|
||||||
|
{
|
||||||
|
if (png_image_finish_read(&image, NULL/*background*/, buffer,
|
||||||
|
0/*row_stride*/, NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP */))
|
||||||
|
{
|
||||||
|
if (png_image_write_to_file(&image, argv[2],
|
||||||
|
0/*convert_to_8bit*/, buffer, 0/*row_stride*/,
|
||||||
|
NULL/*colormap*/))
|
||||||
|
result = 0;
|
||||||
|
|
||||||
|
else
|
||||||
|
fprintf(stderr, "pngtopng: write %s: %s\n", argv[2],
|
||||||
|
image.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
fprintf(stderr, "pngtopng: read %s: %s\n", argv[1],
|
||||||
|
image.message);
|
||||||
|
|
||||||
|
free(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "pngtopng: out of memory: %lu bytes\n",
|
||||||
|
(unsigned long)PNG_IMAGE_SIZE(image));
|
||||||
|
|
||||||
|
/* This is the only place where a 'free' is required; libpng does
|
||||||
|
* the cleanup on error and success, but in this case we couldn't
|
||||||
|
* complete the read because of running out of memory and so libpng
|
||||||
|
* has not got to the point where it can do cleanup.
|
||||||
|
*/
|
||||||
|
png_image_free(&image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
/* Failed to read the first argument: */
|
||||||
|
fprintf(stderr, "pngtopng: %s: %s\n", argv[1], image.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
/* Wrong number of arguments */
|
||||||
|
fprintf(stderr, "pngtopng: usage: pngtopng input-file output-file\n");
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endif /* READ && WRITE */
|
648
libs/libpng-src/contrib/examples/simpleover.c
Normal file
648
libs/libpng-src/contrib/examples/simpleover.c
Normal file
|
@ -0,0 +1,648 @@
|
||||||
|
/*- simpleover
|
||||||
|
*
|
||||||
|
* COPYRIGHT: Written by John Cunningham Bowler, 2015.
|
||||||
|
* To the extent possible under law, the author has waived all copyright and
|
||||||
|
* related or neighboring rights to this work. This work is published from:
|
||||||
|
* United States.
|
||||||
|
*
|
||||||
|
* Read several PNG files, which should have an alpha channel or transparency
|
||||||
|
* information, and composite them together to produce one or more 16-bit linear
|
||||||
|
* RGBA intermediates. This involves doing the correct 'over' composition to
|
||||||
|
* combine the alpha channels and corresponding data.
|
||||||
|
*
|
||||||
|
* Finally read an output (background) PNG using the 24-bit RGB format (the
|
||||||
|
* PNG will be composited on green (#00ff00) by default if it has an alpha
|
||||||
|
* channel), and apply the intermediate image generated above to specified
|
||||||
|
* locations in the image.
|
||||||
|
*
|
||||||
|
* The command line has the general format:
|
||||||
|
*
|
||||||
|
* simpleover <background.png> [output.png]
|
||||||
|
* {--sprite=width,height,name {[--at=x,y] {sprite.png}}}
|
||||||
|
* {--add=name {x,y}}
|
||||||
|
*
|
||||||
|
* The --sprite and --add options may occur multiple times. They are executed
|
||||||
|
* in order. --add may refer to any sprite already read.
|
||||||
|
*
|
||||||
|
* This code is intended to show how to composite multiple images together
|
||||||
|
* correctly. Apart from the libpng Simplified API the only work done in here
|
||||||
|
* is to combine multiple input PNG images into a single sprite; this involves
|
||||||
|
* a Porter-Duff 'over' operation and the input PNG images may, as a result,
|
||||||
|
* be regarded as being layered one on top of the other with the first (leftmost
|
||||||
|
* on the command line) being at the bottom and the last on the top.
|
||||||
|
*/
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
/* Normally use <png.h> here to get the installed libpng, but this is done to
|
||||||
|
* ensure the code picks up the local libpng implementation, so long as this
|
||||||
|
* file is linked against a sufficiently recent libpng (1.6+) it is ok to
|
||||||
|
* change this to <png.h>:
|
||||||
|
*/
|
||||||
|
#include "../../png.h"
|
||||||
|
|
||||||
|
#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
|
||||||
|
|
||||||
|
#define sprite_name_chars 15
|
||||||
|
struct sprite {
|
||||||
|
FILE *file;
|
||||||
|
png_uint_16p buffer;
|
||||||
|
unsigned int width;
|
||||||
|
unsigned int height;
|
||||||
|
char name[sprite_name_chars+1];
|
||||||
|
};
|
||||||
|
|
||||||
|
#if 0 /* div by 65535 test program */
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
double err = 0;
|
||||||
|
unsigned int xerr = 0;
|
||||||
|
unsigned int r = 32769;
|
||||||
|
{
|
||||||
|
unsigned int x = 0;
|
||||||
|
|
||||||
|
do {
|
||||||
|
unsigned int t = x + (x >> 16) /*+ (x >> 31)*/ + r;
|
||||||
|
double v = x, errtest;
|
||||||
|
|
||||||
|
if (t < x) {
|
||||||
|
fprintf(stderr, "overflow: %u+%u -> %u\n", x, r, t);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
v /= 65535;
|
||||||
|
errtest = v;
|
||||||
|
t >>= 16;
|
||||||
|
errtest -= t;
|
||||||
|
|
||||||
|
if (errtest > err) {
|
||||||
|
err = errtest;
|
||||||
|
xerr = x;
|
||||||
|
|
||||||
|
if (errtest >= .5) {
|
||||||
|
fprintf(stderr, "error: %u/65535 = %f, not %u, error %f\n",
|
||||||
|
x, v, t, errtest);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} while (++x <= 65535U*65535U);
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("error %f @ %u\n", err, xerr);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif /* div by 65535 test program */
|
||||||
|
|
||||||
|
static void
|
||||||
|
sprite_op(const struct sprite *sprite, int x_offset, int y_offset,
|
||||||
|
png_imagep image, const png_uint_16 *buffer)
|
||||||
|
{
|
||||||
|
/* This is where the Porter-Duff 'Over' operator is evaluated; change this
|
||||||
|
* code to change the operator (this could be parameterized). Any other
|
||||||
|
* image processing operation could be used here.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/* Check for an x or y offset that pushes any part of the image beyond the
|
||||||
|
* right or bottom of the sprite:
|
||||||
|
*/
|
||||||
|
if ((y_offset < 0 || (unsigned)/*SAFE*/y_offset < sprite->height) &&
|
||||||
|
(x_offset < 0 || (unsigned)/*SAFE*/x_offset < sprite->width))
|
||||||
|
{
|
||||||
|
unsigned int y = 0;
|
||||||
|
|
||||||
|
if (y_offset < 0)
|
||||||
|
y = -y_offset; /* Skip to first visible row */
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
unsigned int x = 0;
|
||||||
|
|
||||||
|
if (x_offset < 0)
|
||||||
|
x = -x_offset;
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
/* In and out are RGBA values, so: */
|
||||||
|
const png_uint_16 *in_pixel = buffer + (y * image->width + x)*4;
|
||||||
|
png_uint_32 in_alpha = in_pixel[3];
|
||||||
|
|
||||||
|
/* This is the optimized Porter-Duff 'Over' operation, when the
|
||||||
|
* input alpha is 0 the output is not changed.
|
||||||
|
*/
|
||||||
|
if (in_alpha > 0)
|
||||||
|
{
|
||||||
|
png_uint_16 *out_pixel = sprite->buffer +
|
||||||
|
((y+y_offset) * sprite->width + (x+x_offset))*4;
|
||||||
|
|
||||||
|
/* This is the weight to apply to the output: */
|
||||||
|
in_alpha = 65535-in_alpha;
|
||||||
|
|
||||||
|
if (in_alpha > 0)
|
||||||
|
{
|
||||||
|
/* The input must be composed onto the output. This means
|
||||||
|
* multiplying the current output pixel value by the inverse
|
||||||
|
* of the input alpha (1-alpha). A division is required but
|
||||||
|
* it is by the constant 65535. Approximate this as:
|
||||||
|
*
|
||||||
|
* (x + (x >> 16) + 32769) >> 16;
|
||||||
|
*
|
||||||
|
* This is exact (and does not overflow) for all values of
|
||||||
|
* x in the range 0..65535*65535. (Note that the calculation
|
||||||
|
* produces the closest integer; the maximum error is <0.5).
|
||||||
|
*/
|
||||||
|
png_uint_32 tmp;
|
||||||
|
|
||||||
|
# define compose(c)\
|
||||||
|
tmp = out_pixel[c] * in_alpha;\
|
||||||
|
tmp = (tmp + (tmp >> 16) + 32769) >> 16;\
|
||||||
|
out_pixel[c] = tmp + in_pixel[c]
|
||||||
|
|
||||||
|
/* The following is very vectorizable... */
|
||||||
|
compose(0);
|
||||||
|
compose(1);
|
||||||
|
compose(2);
|
||||||
|
compose(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
out_pixel[0] = in_pixel[0],
|
||||||
|
out_pixel[1] = in_pixel[1],
|
||||||
|
out_pixel[2] = in_pixel[2],
|
||||||
|
out_pixel[3] = in_pixel[3];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
while (++x < image->width);
|
||||||
|
}
|
||||||
|
while (++y < image->height);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
create_sprite(struct sprite *sprite, int *argc, const char ***argv)
|
||||||
|
{
|
||||||
|
/* Read the arguments and create this sprite. The sprite buffer has already
|
||||||
|
* been allocated. This reads the input PNGs one by one in linear format,
|
||||||
|
* composes them onto the sprite buffer (the code in the function above)
|
||||||
|
* then saves the result, converting it on the fly to PNG RGBA 8-bit format.
|
||||||
|
*/
|
||||||
|
while (*argc > 0)
|
||||||
|
{
|
||||||
|
char tombstone;
|
||||||
|
int x = 0, y = 0;
|
||||||
|
|
||||||
|
if ((*argv)[0][0] == '-' && (*argv)[0][1] == '-')
|
||||||
|
{
|
||||||
|
/* The only supported option is --at. */
|
||||||
|
if (sscanf((*argv)[0], "--at=%d,%d%c", &x, &y, &tombstone) != 2)
|
||||||
|
break; /* success; caller will parse this option */
|
||||||
|
|
||||||
|
++*argv, --*argc;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* The argument has to be a file name */
|
||||||
|
png_image image;
|
||||||
|
|
||||||
|
image.version = PNG_IMAGE_VERSION;
|
||||||
|
image.opaque = NULL;
|
||||||
|
|
||||||
|
if (png_image_begin_read_from_file(&image, (*argv)[0]))
|
||||||
|
{
|
||||||
|
png_uint_16p buffer;
|
||||||
|
|
||||||
|
image.format = PNG_FORMAT_LINEAR_RGB_ALPHA;
|
||||||
|
|
||||||
|
buffer = malloc(PNG_IMAGE_SIZE(image));
|
||||||
|
|
||||||
|
if (buffer != NULL)
|
||||||
|
{
|
||||||
|
if (png_image_finish_read(&image, NULL/*background*/, buffer,
|
||||||
|
0/*row_stride*/,
|
||||||
|
NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP*/))
|
||||||
|
{
|
||||||
|
/* This is the place where the Porter-Duff 'Over' operator
|
||||||
|
* needs to be done by this code. In fact, any image
|
||||||
|
* processing required can be done here; the data is in
|
||||||
|
* the correct format (linear, 16-bit) and source and
|
||||||
|
* destination are in memory.
|
||||||
|
*/
|
||||||
|
sprite_op(sprite, x, y, &image, buffer);
|
||||||
|
free(buffer);
|
||||||
|
++*argv, --*argc;
|
||||||
|
/* And continue to the next argument */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
free(buffer);
|
||||||
|
fprintf(stderr, "simpleover: read %s: %s\n", (*argv)[0],
|
||||||
|
image.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "simpleover: out of memory: %lu bytes\n",
|
||||||
|
(unsigned long)PNG_IMAGE_SIZE(image));
|
||||||
|
|
||||||
|
/* png_image_free must be called if we abort the Simplified API
|
||||||
|
* read because of a problem detected in this code. If problems
|
||||||
|
* are detected in the Simplified API it cleans up itself.
|
||||||
|
*/
|
||||||
|
png_image_free(&image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Failed to read the first argument: */
|
||||||
|
fprintf(stderr, "simpleover: %s: %s\n", (*argv)[0], image.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0; /* failure */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* All the sprite operations have completed successfully. Save the RGBA
|
||||||
|
* buffer as a PNG using the simplified write API.
|
||||||
|
*/
|
||||||
|
sprite->file = tmpfile();
|
||||||
|
|
||||||
|
if (sprite->file != NULL)
|
||||||
|
{
|
||||||
|
png_image save;
|
||||||
|
|
||||||
|
memset(&save, 0, sizeof save);
|
||||||
|
save.version = PNG_IMAGE_VERSION;
|
||||||
|
save.opaque = NULL;
|
||||||
|
save.width = sprite->width;
|
||||||
|
save.height = sprite->height;
|
||||||
|
save.format = PNG_FORMAT_LINEAR_RGB_ALPHA;
|
||||||
|
save.flags = PNG_IMAGE_FLAG_FAST;
|
||||||
|
save.colormap_entries = 0;
|
||||||
|
|
||||||
|
if (png_image_write_to_stdio(&save, sprite->file, 1/*convert_to_8_bit*/,
|
||||||
|
sprite->buffer, 0/*row_stride*/, NULL/*colormap*/))
|
||||||
|
{
|
||||||
|
/* Success; the buffer is no longer needed: */
|
||||||
|
free(sprite->buffer);
|
||||||
|
sprite->buffer = NULL;
|
||||||
|
return 1; /* ok */
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
fprintf(stderr, "simpleover: write sprite %s: %s\n", sprite->name,
|
||||||
|
save.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
fprintf(stderr, "simpleover: sprite %s: could not allocate tmpfile: %s\n",
|
||||||
|
sprite->name, strerror(errno));
|
||||||
|
|
||||||
|
return 0; /* fail */
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
add_sprite(png_imagep output, png_bytep out_buf, struct sprite *sprite,
|
||||||
|
int *argc, const char ***argv)
|
||||||
|
{
|
||||||
|
/* Given a --add argument naming this sprite, perform the operations listed
|
||||||
|
* in the following arguments. The arguments are expected to have the form
|
||||||
|
* (x,y), which is just an offset at which to add the sprite to the
|
||||||
|
* output.
|
||||||
|
*/
|
||||||
|
while (*argc > 0)
|
||||||
|
{
|
||||||
|
char tombstone;
|
||||||
|
int x, y;
|
||||||
|
|
||||||
|
if ((*argv)[0][0] == '-' && (*argv)[0][1] == '-')
|
||||||
|
return 1; /* success */
|
||||||
|
|
||||||
|
if (sscanf((*argv)[0], "%d,%d%c", &x, &y, &tombstone) == 2)
|
||||||
|
{
|
||||||
|
/* Now add the new image into the sprite data, but only if it
|
||||||
|
* will fit.
|
||||||
|
*/
|
||||||
|
if (x < 0 || y < 0 ||
|
||||||
|
(unsigned)/*SAFE*/x >= output->width ||
|
||||||
|
(unsigned)/*SAFE*/y >= output->height ||
|
||||||
|
sprite->width > output->width-x ||
|
||||||
|
sprite->height > output->height-y)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "simpleover: sprite %s @ (%d,%d) outside image\n",
|
||||||
|
sprite->name, x, y);
|
||||||
|
/* Could just skip this, but for the moment it is an error */
|
||||||
|
return 0; /* error */
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Since we know the sprite fits we can just read it into the
|
||||||
|
* output using the simplified API.
|
||||||
|
*/
|
||||||
|
png_image in;
|
||||||
|
|
||||||
|
in.version = PNG_IMAGE_VERSION;
|
||||||
|
rewind(sprite->file);
|
||||||
|
|
||||||
|
if (png_image_begin_read_from_stdio(&in, sprite->file))
|
||||||
|
{
|
||||||
|
in.format = PNG_FORMAT_RGB; /* force compose */
|
||||||
|
|
||||||
|
if (png_image_finish_read(&in, NULL/*background*/,
|
||||||
|
out_buf + (y*output->width + x)*3/*RGB*/,
|
||||||
|
output->width*3/*row_stride*/,
|
||||||
|
NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP*/))
|
||||||
|
{
|
||||||
|
++*argv, --*argc;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The read failed: */
|
||||||
|
fprintf(stderr, "simpleover: add sprite %s: %s\n", sprite->name,
|
||||||
|
in.message);
|
||||||
|
return 0; /* error */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "simpleover: --add='%s': invalid position %s\n",
|
||||||
|
sprite->name, (*argv)[0]);
|
||||||
|
return 0; /* error */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1; /* ok */
|
||||||
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
simpleover_process(png_imagep output, png_bytep out_buf, int argc,
|
||||||
|
const char **argv)
|
||||||
|
{
|
||||||
|
int result = 1; /* success */
|
||||||
|
# define csprites 10/*limit*/
|
||||||
|
# define str(a) #a
|
||||||
|
int nsprites = 0;
|
||||||
|
struct sprite sprites[csprites];
|
||||||
|
|
||||||
|
while (argc > 0)
|
||||||
|
{
|
||||||
|
result = 0; /* fail */
|
||||||
|
|
||||||
|
if (strncmp(argv[0], "--sprite=", 9) == 0)
|
||||||
|
{
|
||||||
|
char tombstone;
|
||||||
|
|
||||||
|
if (nsprites < csprites)
|
||||||
|
{
|
||||||
|
int n;
|
||||||
|
|
||||||
|
sprites[nsprites].width = sprites[nsprites].height = 0;
|
||||||
|
sprites[nsprites].name[0] = 0;
|
||||||
|
|
||||||
|
n = sscanf(argv[0], "--sprite=%u,%u,%" str(sprite_name_chars) "s%c",
|
||||||
|
&sprites[nsprites].width, &sprites[nsprites].height,
|
||||||
|
sprites[nsprites].name, &tombstone);
|
||||||
|
|
||||||
|
if ((n == 2 || n == 3) &&
|
||||||
|
sprites[nsprites].width > 0 && sprites[nsprites].height > 0)
|
||||||
|
{
|
||||||
|
size_t buf_size, tmp;
|
||||||
|
|
||||||
|
/* Default a name if not given. */
|
||||||
|
if (sprites[nsprites].name[0] == 0)
|
||||||
|
sprintf(sprites[nsprites].name, "sprite-%d", nsprites+1);
|
||||||
|
|
||||||
|
/* Allocate a buffer for the sprite and calculate the buffer
|
||||||
|
* size:
|
||||||
|
*/
|
||||||
|
buf_size = sizeof (png_uint_16 [4]);
|
||||||
|
buf_size *= sprites[nsprites].width;
|
||||||
|
buf_size *= sprites[nsprites].height;
|
||||||
|
|
||||||
|
/* This can overflow a (size_t); check for this: */
|
||||||
|
tmp = buf_size;
|
||||||
|
tmp /= sprites[nsprites].width;
|
||||||
|
tmp /= sprites[nsprites].height;
|
||||||
|
|
||||||
|
if (tmp == sizeof (png_uint_16 [4]))
|
||||||
|
{
|
||||||
|
sprites[nsprites].buffer = malloc(buf_size);
|
||||||
|
/* This buffer must be initialized to transparent: */
|
||||||
|
memset(sprites[nsprites].buffer, 0, buf_size);
|
||||||
|
|
||||||
|
if (sprites[nsprites].buffer != NULL)
|
||||||
|
{
|
||||||
|
sprites[nsprites].file = NULL;
|
||||||
|
++argv, --argc;
|
||||||
|
|
||||||
|
if (create_sprite(sprites+nsprites++, &argc, &argv))
|
||||||
|
{
|
||||||
|
result = 1; /* still ok */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
break; /* error */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Overflow, or OOM */
|
||||||
|
fprintf(stderr, "simpleover: %s: sprite too large\n", argv[0]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "simpleover: %s: invalid sprite (%u,%u)\n",
|
||||||
|
argv[0], sprites[nsprites].width, sprites[nsprites].height);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "simpleover: %s: too many sprites\n", argv[0]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (strncmp(argv[0], "--add=", 6) == 0)
|
||||||
|
{
|
||||||
|
const char *name = argv[0]+6;
|
||||||
|
int isprite = nsprites;
|
||||||
|
|
||||||
|
++argv, --argc;
|
||||||
|
|
||||||
|
while (--isprite >= 0)
|
||||||
|
{
|
||||||
|
if (strcmp(sprites[isprite].name, name) == 0)
|
||||||
|
{
|
||||||
|
if (!add_sprite(output, out_buf, sprites+isprite, &argc, &argv))
|
||||||
|
goto out; /* error in add_sprite */
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isprite < 0) /* sprite not found */
|
||||||
|
{
|
||||||
|
fprintf(stderr, "simpleover: --add='%s': sprite not found\n", name);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "simpleover: %s: unrecognized operation\n", argv[0]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
result = 1; /* ok */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clean up the cache of sprites: */
|
||||||
|
out:
|
||||||
|
while (--nsprites >= 0)
|
||||||
|
{
|
||||||
|
if (sprites[nsprites].buffer != NULL)
|
||||||
|
free(sprites[nsprites].buffer);
|
||||||
|
|
||||||
|
if (sprites[nsprites].file != NULL)
|
||||||
|
(void)fclose(sprites[nsprites].file);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, const char **argv)
|
||||||
|
{
|
||||||
|
int result = 1; /* default to fail */
|
||||||
|
|
||||||
|
if (argc >= 2)
|
||||||
|
{
|
||||||
|
int argi = 2;
|
||||||
|
const char *output = NULL;
|
||||||
|
png_image image;
|
||||||
|
|
||||||
|
if (argc > 2 && argv[2][0] != '-'/*an operation*/)
|
||||||
|
{
|
||||||
|
output = argv[2];
|
||||||
|
argi = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
image.version = PNG_IMAGE_VERSION;
|
||||||
|
image.opaque = NULL;
|
||||||
|
|
||||||
|
if (png_image_begin_read_from_file(&image, argv[1]))
|
||||||
|
{
|
||||||
|
png_bytep buffer;
|
||||||
|
|
||||||
|
image.format = PNG_FORMAT_RGB; /* 24-bit RGB */
|
||||||
|
|
||||||
|
buffer = malloc(PNG_IMAGE_SIZE(image));
|
||||||
|
|
||||||
|
if (buffer != NULL)
|
||||||
|
{
|
||||||
|
png_color background = {0, 0xff, 0}; /* fully saturated green */
|
||||||
|
|
||||||
|
if (png_image_finish_read(&image, &background, buffer,
|
||||||
|
0/*row_stride*/, NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP */))
|
||||||
|
{
|
||||||
|
/* At this point png_image_finish_read has cleaned up the
|
||||||
|
* allocated data in png_image, and only the buffer needs to be
|
||||||
|
* freed.
|
||||||
|
*
|
||||||
|
* Perform the remaining operations:
|
||||||
|
*/
|
||||||
|
if (simpleover_process(&image, buffer, argc-argi, argv+argi))
|
||||||
|
{
|
||||||
|
/* Write the output: */
|
||||||
|
if ((output != NULL &&
|
||||||
|
png_image_write_to_file(&image, output,
|
||||||
|
0/*convert_to_8bit*/, buffer, 0/*row_stride*/,
|
||||||
|
NULL/*colormap*/)) ||
|
||||||
|
(output == NULL &&
|
||||||
|
png_image_write_to_stdio(&image, stdout,
|
||||||
|
0/*convert_to_8bit*/, buffer, 0/*row_stride*/,
|
||||||
|
NULL/*colormap*/)))
|
||||||
|
result = 0;
|
||||||
|
|
||||||
|
else
|
||||||
|
fprintf(stderr, "simpleover: write %s: %s\n",
|
||||||
|
output == NULL ? "stdout" : output, image.message);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* else simpleover_process writes an error message */
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
fprintf(stderr, "simpleover: read %s: %s\n", argv[1],
|
||||||
|
image.message);
|
||||||
|
|
||||||
|
free(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "simpleover: out of memory: %lu bytes\n",
|
||||||
|
(unsigned long)PNG_IMAGE_SIZE(image));
|
||||||
|
|
||||||
|
/* This is the only place where a 'free' is required; libpng does
|
||||||
|
* the cleanup on error and success, but in this case we couldn't
|
||||||
|
* complete the read because of running out of memory.
|
||||||
|
*/
|
||||||
|
png_image_free(&image);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Failed to read the first argument: */
|
||||||
|
fprintf(stderr, "simpleover: %s: %s\n", argv[1], image.message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Usage message */
|
||||||
|
fprintf(stderr,
|
||||||
|
"simpleover: usage: simpleover background.png [output.png]\n"
|
||||||
|
" Output 'background.png' as a 24-bit RGB PNG file in 'output.png'\n"
|
||||||
|
" or, if not given, stdout. 'background.png' will be composited\n"
|
||||||
|
" on fully saturated green.\n"
|
||||||
|
"\n"
|
||||||
|
" Optionally, before output, process additional PNG files:\n"
|
||||||
|
"\n"
|
||||||
|
" --sprite=width,height,name {[--at=x,y] {sprite.png}}\n"
|
||||||
|
" Produce a transparent sprite of size (width,height) and with\n"
|
||||||
|
" name 'name'.\n"
|
||||||
|
" For each sprite.png composite it using a Porter-Duff 'Over'\n"
|
||||||
|
" operation at offset (x,y) in the sprite (defaulting to (0,0)).\n"
|
||||||
|
" Input PNGs will be truncated to the area of the sprite.\n"
|
||||||
|
"\n"
|
||||||
|
" --add='name' {x,y}\n"
|
||||||
|
" Optionally, before output, composite a sprite, 'name', which\n"
|
||||||
|
" must have been previously produced using --sprite, at each\n"
|
||||||
|
" offset (x,y) in the output image. Each sprite must fit\n"
|
||||||
|
" completely within the output image.\n"
|
||||||
|
"\n"
|
||||||
|
" PNG files are processed in the order they occur on the command\n"
|
||||||
|
" line and thus the first PNG processed appears as the bottommost\n"
|
||||||
|
" in the output image.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
#endif /* SIMPLIFIED_READ */
|
|
@ -1,12 +1,12 @@
|
||||||
GNU GENERAL PUBLIC LICENSE
|
GNU GENERAL PUBLIC LICENSE
|
||||||
Version 2, June 1991
|
Version 2, June 1991
|
||||||
|
|
||||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
|
||||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
Everyone is permitted to copy and distribute verbatim copies
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
of this license document, but changing it is not allowed.
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
Preamble
|
Preamble
|
||||||
|
|
||||||
The licenses for most software are designed to take away your
|
The licenses for most software are designed to take away your
|
||||||
freedom to share and change it. By contrast, the GNU General Public
|
freedom to share and change it. By contrast, the GNU General Public
|
||||||
|
@ -56,7 +56,7 @@ patent must be licensed for everyone's free use or not licensed at all.
|
||||||
The precise terms and conditions for copying, distribution and
|
The precise terms and conditions for copying, distribution and
|
||||||
modification follow.
|
modification follow.
|
||||||
|
|
||||||
GNU GENERAL PUBLIC LICENSE
|
GNU GENERAL PUBLIC LICENSE
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||||
|
|
||||||
0. This License applies to any program or other work which contains
|
0. This License applies to any program or other work which contains
|
||||||
|
@ -255,7 +255,7 @@ make exceptions for this. Our decision will be guided by the two goals
|
||||||
of preserving the free status of all derivatives of our free software and
|
of preserving the free status of all derivatives of our free software and
|
||||||
of promoting the sharing and reuse of software generally.
|
of promoting the sharing and reuse of software generally.
|
||||||
|
|
||||||
NO WARRANTY
|
NO WARRANTY
|
||||||
|
|
||||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
||||||
|
@ -277,9 +277,9 @@ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
||||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
||||||
POSSIBILITY OF SUCH DAMAGES.
|
POSSIBILITY OF SUCH DAMAGES.
|
||||||
|
|
||||||
END OF TERMS AND CONDITIONS
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
How to Apply These Terms to Your New Programs
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
If you develop a new program, and you want it to be of the greatest
|
If you develop a new program, and you want it to be of the greatest
|
||||||
possible use to the public, the best way to achieve this is to make it
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
|
|
@ -47,7 +47,8 @@ CC = gcc
|
||||||
#CC = i386-mingw32msvc-gcc # e.g., Linux -> Win32 cross-compilation
|
#CC = i386-mingw32msvc-gcc # e.g., Linux -> Win32 cross-compilation
|
||||||
LD = $(CC)
|
LD = $(CC)
|
||||||
RM = rm -f
|
RM = rm -f
|
||||||
CFLAGS = -O -Wall $(INCS) $(MINGW_CCFLAGS)
|
CPPFLAGS = $(INCS)
|
||||||
|
CFLAGS = -O -Wall $(MINGW_CCFLAGS)
|
||||||
# [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
|
# [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
|
||||||
# [-ansi, -pedantic and -W can also be used]
|
# [-ansi, -pedantic and -W can also be used]
|
||||||
LDFLAGS = $(MINGW_LDFLAGS)
|
LDFLAGS = $(MINGW_LDFLAGS)
|
||||||
|
@ -85,10 +86,10 @@ EXES = $(STATIC_EXES) $(DYNAMIC_EXES)
|
||||||
# implicit make rules -------------------------------------------------------
|
# implicit make rules -------------------------------------------------------
|
||||||
|
|
||||||
.c$(O):
|
.c$(O):
|
||||||
$(CC) -c $(CFLAGS) $<
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||||
|
|
||||||
%.pic$(O): %.c
|
%.pic$(O): %.c
|
||||||
$(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $<
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) -DPNG_BUILD_DLL -o $@ $<
|
||||||
|
|
||||||
|
|
||||||
# dependencies --------------------------------------------------------------
|
# dependencies --------------------------------------------------------------
|
||||||
|
|
|
@ -23,9 +23,9 @@
|
||||||
|
|
||||||
# macros --------------------------------------------------------------------
|
# macros --------------------------------------------------------------------
|
||||||
|
|
||||||
PNGINC = -I/usr/local/include/libpng12
|
PNGINC = -I/usr/local/include/libpng16
|
||||||
PNGLIB = -L/usr/local/lib -lpng12 # dynamically linked against libpng
|
PNGLIB = -L/usr/local/lib -lpng16 # dynamically linked against libpng
|
||||||
#PNGLIB = /usr/local/lib/libpng12.a # statically linked against libpng
|
#PNGLIB = /usr/local/lib/libpng16.a # statically linked against libpng
|
||||||
# or:
|
# or:
|
||||||
#PNGINC = -I../..
|
#PNGINC = -I../..
|
||||||
#PNGLIB = -L../.. -lpng
|
#PNGLIB = -L../.. -lpng
|
||||||
|
@ -53,7 +53,8 @@ CC = cc
|
||||||
LD = cc
|
LD = cc
|
||||||
RM = rm -f
|
RM = rm -f
|
||||||
# ABI must be the same as that used to build libpng.
|
# ABI must be the same as that used to build libpng.
|
||||||
ABI=
|
ABI =
|
||||||
|
CPPFLAGS =
|
||||||
CFLAGS = $(ABI) -O -fullwarn $(INCS)
|
CFLAGS = $(ABI) -O -fullwarn $(INCS)
|
||||||
LDFLAGS = $(ABI)
|
LDFLAGS = $(ABI)
|
||||||
O = .o
|
O = .o
|
||||||
|
@ -73,7 +74,7 @@ EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)
|
||||||
# implicit make rules -------------------------------------------------------
|
# implicit make rules -------------------------------------------------------
|
||||||
|
|
||||||
.c$(O):
|
.c$(O):
|
||||||
$(CC) -c $(CFLAGS) $<
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||||
|
|
||||||
|
|
||||||
# dependencies --------------------------------------------------------------
|
# dependencies --------------------------------------------------------------
|
||||||
|
|
|
@ -26,14 +26,14 @@
|
||||||
# macros --------------------------------------------------------------------
|
# macros --------------------------------------------------------------------
|
||||||
|
|
||||||
#PNGDIR = /usr/local/lib
|
#PNGDIR = /usr/local/lib
|
||||||
#PNGINC = -I/usr/local/include/libpng12
|
#PNGINC = -I/usr/local/include/libpng16
|
||||||
#PNGLIBd = -L$(PNGDIR) -lpng12 # dynamically linked, installed libpng
|
#PNGLIBd = -L$(PNGDIR) -lpng16 # dynamically linked, installed libpng
|
||||||
#PNGLIBs = $(PNGDIR)/libpng12.a # statically linked, installed libpng
|
#PNGLIBs = $(PNGDIR)/libpng16.a # statically linked, installed libpng
|
||||||
# or:
|
# or:
|
||||||
PNGDIR = ../..# this one is for libpng-x.y.z/contrib/gregbook builds
|
PNGDIR = ../..# this one is for libpng-x.y.z/contrib/gregbook builds
|
||||||
#PNGDIR = ../libpng
|
#PNGDIR = ../libpng
|
||||||
PNGINC = -I$(PNGDIR)
|
PNGINC = -I$(PNGDIR)
|
||||||
PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng12 # dynamically linked
|
PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng16 # dynamically linked
|
||||||
PNGLIBs = $(PNGDIR)/libpng.a # statically linked, local libpng
|
PNGLIBs = $(PNGDIR)/libpng.a # statically linked, local libpng
|
||||||
|
|
||||||
ZDIR = /usr/local/lib
|
ZDIR = /usr/local/lib
|
||||||
|
@ -59,14 +59,16 @@ INCS = $(PNGINC) $(ZINC) $(XINC)
|
||||||
RLIBSd = $(PNGLIBd) $(ZLIBd) $(XLIB) -lm
|
RLIBSd = $(PNGLIBd) $(ZLIBd) $(XLIB) -lm
|
||||||
RLIBSs = $(PNGLIBs) $(ZLIBs) $(XLIB) -lm
|
RLIBSs = $(PNGLIBs) $(ZLIBs) $(XLIB) -lm
|
||||||
WLIBSd = $(PNGLIBd) $(ZLIBd) -lm
|
WLIBSd = $(PNGLIBd) $(ZLIBd) -lm
|
||||||
WLIBSs = $(PNGLIBs) $(ZLIBs)
|
WLIBSs = $(PNGLIBs) $(ZLIBs) -lm
|
||||||
|
|
||||||
CC = gcc
|
CC = gcc
|
||||||
LD = gcc
|
LD = gcc
|
||||||
RM = rm -f
|
RM = rm -f
|
||||||
CFLAGS = -O -Wall $(INCS) -DFEATURE_LOOP
|
CPPFLAGS = $(INCS) -DFEATURE_LOOP
|
||||||
|
CFLAGS = -O -Wall
|
||||||
|
#CFLAGS = -O -W -Wall -Wextra -pedantic -ansi
|
||||||
# [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
|
# [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
|
||||||
# [-ansi, -pedantic and -W can also be used]
|
# [-ansi, -pedantic, -Wextra, and -W can also be used]
|
||||||
LDFLAGS =
|
LDFLAGS =
|
||||||
O = .o
|
O = .o
|
||||||
E =
|
E =
|
||||||
|
@ -92,7 +94,7 @@ EXES = $(STATIC_EXES) $(DYNAMIC_EXES)
|
||||||
# implicit make rules -------------------------------------------------------
|
# implicit make rules -------------------------------------------------------
|
||||||
|
|
||||||
.c$(O):
|
.c$(O):
|
||||||
$(CC) -c $(CFLAGS) $<
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||||
|
|
||||||
|
|
||||||
# dependencies --------------------------------------------------------------
|
# dependencies --------------------------------------------------------------
|
||||||
|
|
|
@ -53,7 +53,8 @@ WLIBS = $(PNGLIB) $(ZLIB)
|
||||||
CC = cl
|
CC = cl
|
||||||
LD = link
|
LD = link
|
||||||
RM = del
|
RM = del
|
||||||
CFLAGS = -nologo -O -W3 $(INCS) $(cvars)
|
CPPFLAGS = $(INCS)
|
||||||
|
CFLAGS = -nologo -O -W3 $(cvars)
|
||||||
# [note that -W3 is an MSVC-specific compilation flag ("all warnings on")]
|
# [note that -W3 is an MSVC-specific compilation flag ("all warnings on")]
|
||||||
# [see %devstudio%\vc\include\win32.mak for cvars macro definition]
|
# [see %devstudio%\vc\include\win32.mak for cvars macro definition]
|
||||||
O = .obj
|
O = .obj
|
||||||
|
@ -76,7 +77,7 @@ EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)
|
||||||
# implicit make rules -------------------------------------------------------
|
# implicit make rules -------------------------------------------------------
|
||||||
|
|
||||||
.c$(O):
|
.c$(O):
|
||||||
$(CC) -c $(CFLAGS) $<
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||||
|
|
||||||
|
|
||||||
# dependencies --------------------------------------------------------------
|
# dependencies --------------------------------------------------------------
|
||||||
|
|
|
@ -15,7 +15,7 @@ of PBMPLUS/NetPBM) and converts them to PNG.
|
||||||
|
|
||||||
The source code for all three demo programs currently compiles under
|
The source code for all three demo programs currently compiles under
|
||||||
Unix, OpenVMS, and 32-bit Windows. (Special thanks to Martin Zinser,
|
Unix, OpenVMS, and 32-bit Windows. (Special thanks to Martin Zinser,
|
||||||
zinser@decus.de, for making the necessary changes for OpenVMS and for
|
zinser at decus.de, for making the necessary changes for OpenVMS and for
|
||||||
providing an appropriate build script.) Build instructions can be found
|
providing an appropriate build script.) Build instructions can be found
|
||||||
below.
|
below.
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ mation and links to the latest version of the source code, and Chapters
|
||||||
13-15 of the book for detailed discussion of the three programs.
|
13-15 of the book for detailed discussion of the three programs.
|
||||||
|
|
||||||
Greg Roelofs
|
Greg Roelofs
|
||||||
http://pobox.com/~newt/greg_contact.html
|
https://pobox.com/~newt/greg_contact.html
|
||||||
16 March 2008
|
16 March 2008
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,9 +63,9 @@ BUILD INSTRUCTIONS
|
||||||
|
|
||||||
- Prerequisites (in order of compilation):
|
- Prerequisites (in order of compilation):
|
||||||
|
|
||||||
- zlib http://zlib.net/
|
- zlib https://zlib.net/
|
||||||
- libpng http://www.libpng.org/pub/png/libpng.html
|
- libpng http://www.libpng.org/pub/png/libpng.html
|
||||||
- pngbook http://www.libpng.org/pub/png/book/sources.html
|
- pngbook http://www.libpng.org/pub/png/book/sources.html
|
||||||
|
|
||||||
The pngbook demo programs are explicitly designed to demonstrate proper
|
The pngbook demo programs are explicitly designed to demonstrate proper
|
||||||
coding techniques for using the libpng reference library. As a result,
|
coding techniques for using the libpng reference library. As a result,
|
||||||
|
@ -165,19 +165,19 @@ RUNNING THE PROGRAMS: (VERY) BRIEF INTRO
|
||||||
rpng is a simple PNG viewer that can display transparent PNGs with a
|
rpng is a simple PNG viewer that can display transparent PNGs with a
|
||||||
specified background color; for example,
|
specified background color; for example,
|
||||||
|
|
||||||
rpng -bgcolor #ff0000 toucan.png
|
rpng -bgcolor \#ff0000 toucan.png
|
||||||
|
|
||||||
would display the image with a red background. rpng2 is a progressive
|
would display the image with a red background. rpng2 is a progressive
|
||||||
viewer that simulates a web browser in some respects; it can display
|
viewer that simulates a web browser in some respects; it can display
|
||||||
images against either a background color or a dynamically generated
|
images against either a background color or a dynamically generated
|
||||||
background image. For example:
|
background image. For example:
|
||||||
|
|
||||||
rpng2 -bgpat 16 toucan.png
|
rpng2 -bgpat 16 toucan.png
|
||||||
|
|
||||||
wpng is a purely command-line image converter from binary PBMPLUS/NetPBM
|
wpng is a purely command-line image converter from binary PBMPLUS/NetPBM
|
||||||
format (.pgm or .ppm) to PNG; for example,
|
format (.pgm or .ppm) to PNG; for example,
|
||||||
|
|
||||||
wpng -time < toucan-notrans.ppm > toucan-notrans.png
|
wpng -time < toucan-notrans.ppm > toucan-notrans.png
|
||||||
|
|
||||||
would convert the specified PPM file (using redirection) to PNG, auto-
|
would convert the specified PPM file (using redirection) to PNG, auto-
|
||||||
matically setting the PNG modification-time chunk.
|
matically setting the PNG modification-time chunk.
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 1998-2007 Greg Roelofs. All rights reserved.
|
Copyright (c) 1998-2007,2017 Greg Roelofs. All rights reserved.
|
||||||
|
|
||||||
This software is provided "as is," without warranty of any kind,
|
This software is provided "as is," without warranty of any kind,
|
||||||
express or implied. In no event shall the author or contributors
|
express or implied. In no event shall the author or contributors
|
||||||
|
@ -55,8 +55,9 @@
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <zlib.h>
|
||||||
|
|
||||||
#include "png.h" /* libpng header; includes zlib.h */
|
#include "png.h" /* libpng header */
|
||||||
#include "readpng.h" /* typedefs, common macros, public prototypes */
|
#include "readpng.h" /* typedefs, common macros, public prototypes */
|
||||||
|
|
||||||
/* future versions of libpng will provide this macro: */
|
/* future versions of libpng will provide this macro: */
|
||||||
|
@ -99,7 +100,8 @@ int readpng_init(FILE *infile, ulg *pWidth, ulg *pHeight)
|
||||||
|
|
||||||
/* could pass pointers to user-defined error handlers instead of NULLs: */
|
/* could pass pointers to user-defined error handlers instead of NULLs: */
|
||||||
|
|
||||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
|
png_ptr = png_create_read_struct(png_get_libpng_ver(NULL), NULL, NULL,
|
||||||
|
NULL);
|
||||||
if (!png_ptr)
|
if (!png_ptr)
|
||||||
return 4; /* out of memory */
|
return 4; /* out of memory */
|
||||||
|
|
||||||
|
@ -214,6 +216,10 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
|
||||||
* libpng function */
|
* libpng function */
|
||||||
|
|
||||||
if (setjmp(png_jmpbuf(png_ptr))) {
|
if (setjmp(png_jmpbuf(png_ptr))) {
|
||||||
|
free(image_data);
|
||||||
|
image_data = NULL;
|
||||||
|
free(row_pointers);
|
||||||
|
row_pointers = NULL;
|
||||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -229,8 +235,14 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
|
||||||
png_set_expand(png_ptr);
|
png_set_expand(png_ptr);
|
||||||
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
|
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
|
||||||
png_set_expand(png_ptr);
|
png_set_expand(png_ptr);
|
||||||
|
#ifdef PNG_READ_16_TO_8_SUPPORTED
|
||||||
if (bit_depth == 16)
|
if (bit_depth == 16)
|
||||||
|
# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||||
|
png_set_scale_16(png_ptr);
|
||||||
|
# else
|
||||||
png_set_strip_16(png_ptr);
|
png_set_strip_16(png_ptr);
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
if (color_type == PNG_COLOR_TYPE_GRAY ||
|
if (color_type == PNG_COLOR_TYPE_GRAY ||
|
||||||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||||
png_set_gray_to_rgb(png_ptr);
|
png_set_gray_to_rgb(png_ptr);
|
||||||
|
@ -252,6 +264,12 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
|
||||||
*pRowbytes = rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
*pRowbytes = rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||||
*pChannels = (int)png_get_channels(png_ptr, info_ptr);
|
*pChannels = (int)png_get_channels(png_ptr, info_ptr);
|
||||||
|
|
||||||
|
/* Guard against integer overflow */
|
||||||
|
if (height > ((size_t)(-1))/rowbytes) {
|
||||||
|
fprintf(stderr, "readpng: image_data buffer would be too large\n",
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if ((image_data = (uch *)malloc(rowbytes*height)) == NULL) {
|
if ((image_data = (uch *)malloc(rowbytes*height)) == NULL) {
|
||||||
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -263,7 +281,8 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Trace((stderr, "readpng_get_image: channels = %d, rowbytes = %ld, height = %ld\n", *pChannels, rowbytes, height));
|
Trace((stderr, "readpng_get_image: channels = %d, rowbytes = %ld, height = %ld\n",
|
||||||
|
*pChannels, rowbytes, height));
|
||||||
|
|
||||||
|
|
||||||
/* set the individual row_pointers to point at the correct offsets */
|
/* set the individual row_pointers to point at the correct offsets */
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 1998-2007 Greg Roelofs. All rights reserved.
|
Copyright (c) 1998-2015 Greg Roelofs. All rights reserved.
|
||||||
|
|
||||||
This software is provided "as is," without warranty of any kind,
|
This software is provided "as is," without warranty of any kind,
|
||||||
express or implied. In no event shall the author or contributors
|
express or implied. In no event shall the author or contributors
|
||||||
|
@ -51,12 +51,20 @@
|
||||||
along with this program; if not, write to the Free Software Foundation,
|
along with this program; if not, write to the Free Software Foundation,
|
||||||
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||||
|
|
||||||
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Changelog:
|
||||||
|
2015-11-12 - Check return value of png_get_bKGD() (Glenn R-P)
|
||||||
|
2017-04-22 - Guard against integer overflow (Glenn R-P)
|
||||||
|
|
||||||
---------------------------------------------------------------------------*/
|
---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
#include <stdlib.h> /* for exit() prototype */
|
#include <stdlib.h> /* for exit() prototype */
|
||||||
|
#include <setjmp.h>
|
||||||
|
|
||||||
#include "png.h" /* libpng header; includes zlib.h and setjmp.h */
|
#include <zlib.h>
|
||||||
|
#include "png.h" /* libpng header from the local directory */
|
||||||
#include "readpng2.h" /* typedefs, common macros, public prototypes */
|
#include "readpng2.h" /* typedefs, common macros, public prototypes */
|
||||||
|
|
||||||
|
|
||||||
|
@ -67,90 +75,17 @@ static void readpng2_row_callback(png_structp png_ptr, png_bytep new_row,
|
||||||
png_uint_32 row_num, int pass);
|
png_uint_32 row_num, int pass);
|
||||||
static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr);
|
static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr);
|
||||||
static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg);
|
static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg);
|
||||||
|
static void readpng2_warning_handler(png_structp png_ptr, png_const_charp msg);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void readpng2_version_info(void)
|
void readpng2_version_info(void)
|
||||||
{
|
{
|
||||||
#if defined(PNG_ASSEMBLER_CODE_SUPPORTED) && \
|
fprintf(stderr, " Compiled with libpng %s; using libpng %s\n",
|
||||||
(defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) && \
|
PNG_LIBPNG_VER_STRING, png_libpng_ver);
|
||||||
defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
|
|
||||||
/*
|
|
||||||
* WARNING: This preprocessor approach means that the following code
|
|
||||||
* cannot be used with a libpng DLL older than 1.2.0--the
|
|
||||||
* compiled-in symbols for the new functions will not exist.
|
|
||||||
* (Could use dlopen() and dlsym() on Unix and corresponding
|
|
||||||
* calls for Windows, but not portable...)
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
int mmxsupport = png_mmx_support();
|
|
||||||
if (mmxsupport < 0)
|
|
||||||
fprintf(stderr, " Compiled with libpng %s; using libpng %s "
|
|
||||||
"without MMX support.\n", PNG_LIBPNG_VER_STRING, png_libpng_ver);
|
|
||||||
else {
|
|
||||||
int compilerID;
|
|
||||||
png_uint_32 mmx_mask = png_get_mmx_flagmask(
|
|
||||||
PNG_SELECT_READ | PNG_SELECT_WRITE, &compilerID);
|
|
||||||
|
|
||||||
fprintf(stderr, " Compiled with libpng %s; using libpng %s "
|
fprintf(stderr, " and with zlib %s; using zlib %s.\n",
|
||||||
"with MMX support\n (%s version).", PNG_LIBPNG_VER_STRING,
|
|
||||||
png_libpng_ver, compilerID == 1? "MSVC++" :
|
|
||||||
(compilerID == 2? "GNU C" : "unknown"));
|
|
||||||
fprintf(stderr, " Processor (x86%s) %s MMX instructions.\n",
|
|
||||||
#if defined(__x86_64__)
|
|
||||||
"_64",
|
|
||||||
#else
|
|
||||||
"",
|
|
||||||
#endif
|
|
||||||
mmxsupport? "supports" : "does not support");
|
|
||||||
if (mmxsupport > 0) {
|
|
||||||
int num_optims = 0;
|
|
||||||
|
|
||||||
fprintf(stderr,
|
|
||||||
" Potential MMX optimizations supported by libpng:\n");
|
|
||||||
if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)
|
|
||||||
++num_optims;
|
|
||||||
if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_UP)
|
|
||||||
++num_optims;
|
|
||||||
if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)
|
|
||||||
++num_optims;
|
|
||||||
if (mmx_mask & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)
|
|
||||||
++num_optims;
|
|
||||||
if (num_optims)
|
|
||||||
fprintf(stderr,
|
|
||||||
" decoding %s row filters (reading)\n",
|
|
||||||
(num_optims == 4)? "all non-trivial" : "some");
|
|
||||||
if (mmx_mask & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW) {
|
|
||||||
fprintf(stderr, " combining rows (reading)\n");
|
|
||||||
++num_optims;
|
|
||||||
}
|
|
||||||
if (mmx_mask & PNG_ASM_FLAG_MMX_READ_INTERLACE) {
|
|
||||||
fprintf(stderr,
|
|
||||||
" expanding interlacing (reading)\n");
|
|
||||||
++num_optims;
|
|
||||||
}
|
|
||||||
mmx_mask &= ~( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_INTERLACE \
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_FILTER_SUB \
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_FILTER_UP \
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_FILTER_AVG \
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_FILTER_PAETH );
|
|
||||||
if (mmx_mask) {
|
|
||||||
fprintf(stderr, " other (unknown)\n");
|
|
||||||
++num_optims;
|
|
||||||
}
|
|
||||||
if (num_optims == 0)
|
|
||||||
fprintf(stderr, " (none)\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
fprintf(stderr, " Compiled with libpng %s; using libpng %s "
|
|
||||||
"without MMX support.\n", PNG_LIBPNG_VER_STRING, png_libpng_ver);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n",
|
|
||||||
ZLIB_VERSION, zlib_version);
|
ZLIB_VERSION, zlib_version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -175,8 +110,8 @@ int readpng2_init(mainprog_info *mainprog_ptr)
|
||||||
|
|
||||||
/* could also replace libpng warning-handler (final NULL), but no need: */
|
/* could also replace libpng warning-handler (final NULL), but no need: */
|
||||||
|
|
||||||
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, mainprog_ptr,
|
png_ptr = png_create_read_struct(png_get_libpng_ver(NULL), mainprog_ptr,
|
||||||
readpng2_error_handler, NULL);
|
readpng2_error_handler, readpng2_warning_handler);
|
||||||
if (!png_ptr)
|
if (!png_ptr)
|
||||||
return 4; /* out of memory */
|
return 4; /* out of memory */
|
||||||
|
|
||||||
|
@ -203,36 +138,30 @@ int readpng2_init(mainprog_info *mainprog_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
|
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||||
/* prepare the reader to ignore all recognized chunks whose data won't be
|
/* prepare the reader to ignore all recognized chunks whose data won't be
|
||||||
* used, i.e., all chunks recognized by libpng except for IHDR, PLTE, IDAT,
|
* used, i.e., all chunks recognized by libpng except for IHDR, PLTE, IDAT,
|
||||||
* IEND, tRNS, bKGD, gAMA, and sRGB (small performance improvement) */
|
* IEND, tRNS, bKGD, gAMA, and sRGB (small performance improvement) */
|
||||||
{
|
{
|
||||||
/* These byte strings were copied from png.h. If a future libpng
|
/* These byte strings were copied from png.h. If a future version
|
||||||
* version recognizes more chunks, add them to this list. If a
|
* of readpng2.c recognizes more chunks, add them to this list.
|
||||||
* future version of readpng2.c recognizes more chunks, delete them
|
*/
|
||||||
* from this list. */
|
static const png_byte chunks_to_process[] = {
|
||||||
static const png_byte chunks_to_ignore[] = {
|
98, 75, 71, 68, '\0', /* bKGD */
|
||||||
99, 72, 82, 77, '\0', /* cHRM */
|
103, 65, 77, 65, '\0', /* gAMA */
|
||||||
104, 73, 83, 84, '\0', /* hIST */
|
115, 82, 71, 66, '\0', /* sRGB */
|
||||||
105, 67, 67, 80, '\0', /* iCCP */
|
};
|
||||||
105, 84, 88, 116, '\0', /* iTXt */
|
|
||||||
111, 70, 70, 115, '\0', /* oFFs */
|
|
||||||
112, 67, 65, 76, '\0', /* pCAL */
|
|
||||||
112, 72, 89, 115, '\0', /* pHYs */
|
|
||||||
115, 66, 73, 84, '\0', /* sBIT */
|
|
||||||
115, 67, 65, 76, '\0', /* sCAL */
|
|
||||||
115, 80, 76, 84, '\0', /* sPLT */
|
|
||||||
115, 84, 69, 82, '\0', /* sTER */
|
|
||||||
116, 69, 88, 116, '\0', /* tEXt */
|
|
||||||
116, 73, 77, 69, '\0', /* tIME */
|
|
||||||
122, 84, 88, 116, '\0' /* zTXt */
|
|
||||||
};
|
|
||||||
|
|
||||||
png_set_keep_unknown_chunks(png_ptr, 1 /* PNG_HANDLE_CHUNK_NEVER */,
|
/* Ignore all chunks except for IHDR, PLTE, tRNS, IDAT, and IEND */
|
||||||
chunks_to_ignore, sizeof(chunks_to_ignore)/5);
|
png_set_keep_unknown_chunks(png_ptr, -1 /* PNG_HANDLE_CHUNK_NEVER */,
|
||||||
|
NULL, -1);
|
||||||
|
|
||||||
|
/* But do not ignore chunks in the "chunks_to_process" list */
|
||||||
|
png_set_keep_unknown_chunks(png_ptr,
|
||||||
|
0 /* PNG_HANDLE_CHUNK_AS_DEFAULT */, chunks_to_process,
|
||||||
|
sizeof(chunks_to_process)/5);
|
||||||
}
|
}
|
||||||
#endif /* PNG_UNKNOWN_CHUNKS_SUPPORTED */
|
#endif /* PNG_HANDLE_AS_UNKNOWN_SUPPORTED */
|
||||||
|
|
||||||
|
|
||||||
/* instead of doing png_init_io() here, now we set up our callback
|
/* instead of doing png_init_io() here, now we set up our callback
|
||||||
|
@ -242,96 +171,6 @@ int readpng2_init(mainprog_info *mainprog_ptr)
|
||||||
readpng2_info_callback, readpng2_row_callback, readpng2_end_callback);
|
readpng2_info_callback, readpng2_row_callback, readpng2_end_callback);
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* may as well enable or disable MMX routines here, if supported;
|
|
||||||
*
|
|
||||||
* to enable all: mask = png_get_mmx_flagmask (
|
|
||||||
* PNG_SELECT_READ | PNG_SELECT_WRITE, &compilerID);
|
|
||||||
* flags = png_get_asm_flags (png_ptr);
|
|
||||||
* flags |= mask;
|
|
||||||
* png_set_asm_flags (png_ptr, flags);
|
|
||||||
*
|
|
||||||
* to disable all: mask = png_get_mmx_flagmask (
|
|
||||||
* PNG_SELECT_READ | PNG_SELECT_WRITE, &compilerID);
|
|
||||||
* flags = png_get_asm_flags (png_ptr);
|
|
||||||
* flags &= ~mask;
|
|
||||||
* png_set_asm_flags (png_ptr, flags);
|
|
||||||
*/
|
|
||||||
|
|
||||||
#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) && \
|
|
||||||
defined(PNG_LIBPNG_VER) && (PNG_LIBPNG_VER >= 10200)
|
|
||||||
/*
|
|
||||||
* WARNING: This preprocessor approach means that the following code
|
|
||||||
* cannot be used with a libpng DLL older than 1.2.0--the
|
|
||||||
* compiled-in symbols for the new functions will not exist.
|
|
||||||
* (Could use dlopen() and dlsym() on Unix and corresponding
|
|
||||||
* calls for Windows, but not portable...)
|
|
||||||
*/
|
|
||||||
{
|
|
||||||
#ifdef PNG_ASSEMBLER_CODE_SUPPORTED
|
|
||||||
png_uint_32 mmx_disable_mask = 0;
|
|
||||||
png_uint_32 asm_flags, mmx_mask;
|
|
||||||
int compilerID;
|
|
||||||
|
|
||||||
if (mainprog_ptr->nommxfilters)
|
|
||||||
mmx_disable_mask |= ( PNG_ASM_FLAG_MMX_READ_FILTER_SUB \
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_FILTER_UP \
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_FILTER_AVG \
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_FILTER_PAETH );
|
|
||||||
if (mainprog_ptr->nommxcombine)
|
|
||||||
mmx_disable_mask |= PNG_ASM_FLAG_MMX_READ_COMBINE_ROW;
|
|
||||||
if (mainprog_ptr->nommxinterlace)
|
|
||||||
mmx_disable_mask |= PNG_ASM_FLAG_MMX_READ_INTERLACE;
|
|
||||||
asm_flags = png_get_asm_flags(png_ptr);
|
|
||||||
png_set_asm_flags(png_ptr, asm_flags & ~mmx_disable_mask);
|
|
||||||
|
|
||||||
|
|
||||||
/* Now query libpng's asm settings, just for yuks. Note that this
|
|
||||||
* differs from the querying of its *potential* MMX capabilities
|
|
||||||
* in readpng2_version_info(); this is true runtime verification. */
|
|
||||||
|
|
||||||
asm_flags = png_get_asm_flags(png_ptr);
|
|
||||||
mmx_mask = png_get_mmx_flagmask(PNG_SELECT_READ | PNG_SELECT_WRITE,
|
|
||||||
&compilerID);
|
|
||||||
if (asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_COMPILED)
|
|
||||||
fprintf(stderr,
|
|
||||||
" MMX support (%s version) is compiled into libpng\n",
|
|
||||||
compilerID == 1? "MSVC++" :
|
|
||||||
(compilerID == 2? "GNU C" : "unknown"));
|
|
||||||
else
|
|
||||||
fprintf(stderr, " MMX support is not compiled into libpng\n");
|
|
||||||
fprintf(stderr, " MMX instructions are %ssupported by CPU\n",
|
|
||||||
(asm_flags & PNG_ASM_FLAG_MMX_SUPPORT_IN_CPU)? "" : "not ");
|
|
||||||
fprintf(stderr, " MMX read support for combining rows is %sabled\n",
|
|
||||||
(asm_flags & PNG_ASM_FLAG_MMX_READ_COMBINE_ROW)? "en" : "dis");
|
|
||||||
fprintf(stderr,
|
|
||||||
" MMX read support for expanding interlacing is %sabled\n",
|
|
||||||
(asm_flags & PNG_ASM_FLAG_MMX_READ_INTERLACE)? "en" : "dis");
|
|
||||||
fprintf(stderr, " MMX read support for \"sub\" filter is %sabled\n",
|
|
||||||
(asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_SUB)? "en" : "dis");
|
|
||||||
fprintf(stderr, " MMX read support for \"up\" filter is %sabled\n",
|
|
||||||
(asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_UP)? "en" : "dis");
|
|
||||||
fprintf(stderr, " MMX read support for \"avg\" filter is %sabled\n",
|
|
||||||
(asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_AVG)? "en" : "dis");
|
|
||||||
fprintf(stderr, " MMX read support for \"Paeth\" filter is %sabled\n",
|
|
||||||
(asm_flags & PNG_ASM_FLAG_MMX_READ_FILTER_PAETH)? "en" : "dis");
|
|
||||||
asm_flags &= (mmx_mask & ~( PNG_ASM_FLAG_MMX_READ_COMBINE_ROW \
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_INTERLACE \
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_FILTER_SUB \
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_FILTER_UP \
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_FILTER_AVG \
|
|
||||||
| PNG_ASM_FLAG_MMX_READ_FILTER_PAETH ));
|
|
||||||
if (asm_flags)
|
|
||||||
fprintf(stderr,
|
|
||||||
" additional MMX support is also enabled (0x%02lx)\n",
|
|
||||||
asm_flags);
|
|
||||||
#else /* !PNG_ASSEMBLER_CODE_SUPPORTED */
|
|
||||||
fprintf(stderr, " MMX querying is disabled in libpng.\n");
|
|
||||||
#endif /* ?PNG_ASSEMBLER_CODE_SUPPORTED */
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
/* make sure we save our pointers for use in readpng2_decode_data() */
|
/* make sure we save our pointers for use in readpng2_decode_data() */
|
||||||
|
|
||||||
mainprog_ptr->png_ptr = png_ptr;
|
mainprog_ptr->png_ptr = png_ptr;
|
||||||
|
@ -380,7 +219,11 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
|
||||||
mainprog_info *mainprog_ptr;
|
mainprog_info *mainprog_ptr;
|
||||||
int color_type, bit_depth;
|
int color_type, bit_depth;
|
||||||
png_uint_32 width, height;
|
png_uint_32 width, height;
|
||||||
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
double gamma;
|
double gamma;
|
||||||
|
#else
|
||||||
|
png_fixed_point gamma;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* setjmp() doesn't make sense here, because we'd either have to exit(),
|
/* setjmp() doesn't make sense here, because we'd either have to exit(),
|
||||||
|
@ -424,36 +267,38 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
|
||||||
/* since we know we've read all of the PNG file's "header" (i.e., up
|
/* since we know we've read all of the PNG file's "header" (i.e., up
|
||||||
* to IDAT), we can check for a background color here */
|
* to IDAT), we can check for a background color here */
|
||||||
|
|
||||||
if (mainprog_ptr->need_bgcolor &&
|
if (mainprog_ptr->need_bgcolor)
|
||||||
png_get_valid(png_ptr, info_ptr, PNG_INFO_bKGD))
|
|
||||||
{
|
{
|
||||||
png_color_16p pBackground;
|
png_color_16p pBackground;
|
||||||
|
|
||||||
/* it is not obvious from the libpng documentation, but this function
|
/* it is not obvious from the libpng documentation, but this function
|
||||||
* takes a pointer to a pointer, and it always returns valid red,
|
* takes a pointer to a pointer, and it always returns valid red,
|
||||||
* green and blue values, regardless of color_type: */
|
* green and blue values, regardless of color_type: */
|
||||||
png_get_bKGD(png_ptr, info_ptr, &pBackground);
|
if (png_get_bKGD(png_ptr, info_ptr, &pBackground))
|
||||||
|
{
|
||||||
|
|
||||||
/* however, it always returns the raw bKGD data, regardless of any
|
/* however, it always returns the raw bKGD data, regardless of any
|
||||||
* bit-depth transformations, so check depth and adjust if necessary */
|
* bit-depth transformations, so check depth and adjust if necessary
|
||||||
if (bit_depth == 16) {
|
*/
|
||||||
mainprog_ptr->bg_red = pBackground->red >> 8;
|
if (bit_depth == 16) {
|
||||||
mainprog_ptr->bg_green = pBackground->green >> 8;
|
mainprog_ptr->bg_red = pBackground->red >> 8;
|
||||||
mainprog_ptr->bg_blue = pBackground->blue >> 8;
|
mainprog_ptr->bg_green = pBackground->green >> 8;
|
||||||
} else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) {
|
mainprog_ptr->bg_blue = pBackground->blue >> 8;
|
||||||
if (bit_depth == 1)
|
} else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) {
|
||||||
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
|
if (bit_depth == 1)
|
||||||
mainprog_ptr->bg_blue = pBackground->gray? 255 : 0;
|
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
|
||||||
else if (bit_depth == 2)
|
mainprog_ptr->bg_blue = pBackground->gray? 255 : 0;
|
||||||
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
|
else if (bit_depth == 2)
|
||||||
mainprog_ptr->bg_blue = (255/3) * pBackground->gray;
|
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
|
||||||
else /* bit_depth == 4 */
|
mainprog_ptr->bg_blue = (255/3) * pBackground->gray;
|
||||||
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
|
else /* bit_depth == 4 */
|
||||||
mainprog_ptr->bg_blue = (255/15) * pBackground->gray;
|
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
|
||||||
} else {
|
mainprog_ptr->bg_blue = (255/15) * pBackground->gray;
|
||||||
mainprog_ptr->bg_red = (uch)pBackground->red;
|
} else {
|
||||||
mainprog_ptr->bg_green = (uch)pBackground->green;
|
mainprog_ptr->bg_red = (uch)pBackground->red;
|
||||||
mainprog_ptr->bg_blue = (uch)pBackground->blue;
|
mainprog_ptr->bg_green = (uch)pBackground->green;
|
||||||
|
mainprog_ptr->bg_blue = (uch)pBackground->blue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -469,8 +314,14 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
|
||||||
png_set_expand(png_ptr);
|
png_set_expand(png_ptr);
|
||||||
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
|
if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
|
||||||
png_set_expand(png_ptr);
|
png_set_expand(png_ptr);
|
||||||
|
#ifdef PNG_READ_16_TO_8_SUPPORTED
|
||||||
if (bit_depth == 16)
|
if (bit_depth == 16)
|
||||||
|
# ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
|
||||||
|
png_set_scale_16(png_ptr);
|
||||||
|
# else
|
||||||
png_set_strip_16(png_ptr);
|
png_set_strip_16(png_ptr);
|
||||||
|
# endif
|
||||||
|
#endif
|
||||||
if (color_type == PNG_COLOR_TYPE_GRAY ||
|
if (color_type == PNG_COLOR_TYPE_GRAY ||
|
||||||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
|
||||||
png_set_gray_to_rgb(png_ptr);
|
png_set_gray_to_rgb(png_ptr);
|
||||||
|
@ -491,11 +342,19 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
|
||||||
* "gamma" value for the entire display system, i.e., the product of
|
* "gamma" value for the entire display system, i.e., the product of
|
||||||
* LUT_exponent and CRT_exponent. */
|
* LUT_exponent and CRT_exponent. */
|
||||||
|
|
||||||
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
if (png_get_gAMA(png_ptr, info_ptr, &gamma))
|
if (png_get_gAMA(png_ptr, info_ptr, &gamma))
|
||||||
png_set_gamma(png_ptr, mainprog_ptr->display_exponent, gamma);
|
png_set_gamma(png_ptr, mainprog_ptr->display_exponent, gamma);
|
||||||
else
|
else
|
||||||
png_set_gamma(png_ptr, mainprog_ptr->display_exponent, 0.45455);
|
png_set_gamma(png_ptr, mainprog_ptr->display_exponent, 0.45455);
|
||||||
|
#else
|
||||||
|
if (png_get_gAMA_fixed(png_ptr, info_ptr, &gamma))
|
||||||
|
png_set_gamma_fixed(png_ptr,
|
||||||
|
(png_fixed_point)(100000*mainprog_ptr->display_exponent+.5), gamma);
|
||||||
|
else
|
||||||
|
png_set_gamma_fixed(png_ptr,
|
||||||
|
(png_fixed_point)(100000*mainprog_ptr->display_exponent+.5), 45455);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* we'll let libpng expand interlaced images, too */
|
/* we'll let libpng expand interlaced images, too */
|
||||||
|
|
||||||
|
@ -597,6 +456,8 @@ static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr)
|
||||||
|
|
||||||
/* all done */
|
/* all done */
|
||||||
|
|
||||||
|
(void)info_ptr; /* Unused */
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -617,7 +478,12 @@ void readpng2_cleanup(mainprog_info *mainprog_ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void readpng2_warning_handler(png_structp png_ptr, png_const_charp msg)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "readpng2 libpng warning: %s\n", msg);
|
||||||
|
fflush(stderr);
|
||||||
|
(void)png_ptr; /* Unused */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg)
|
static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg)
|
||||||
|
@ -644,5 +510,12 @@ static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg)
|
||||||
exit(99);
|
exit(99);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Now we have our data structure we can use the information in it
|
||||||
|
* to return control to our own higher level code (all the points
|
||||||
|
* where 'setjmp' is called in this file.) This will work with other
|
||||||
|
* error handling mechanisms as well - libpng always calls png_error
|
||||||
|
* when it can proceed no further, thus, so long as the error handler
|
||||||
|
* is intercepted, application code can do its own error recovery.
|
||||||
|
*/
|
||||||
longjmp(mainprog_ptr->jmpbuf, 1);
|
longjmp(mainprog_ptr->jmpbuf, 1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -96,11 +96,6 @@ typedef struct _mainprog_info {
|
||||||
int rowbytes;
|
int rowbytes;
|
||||||
int channels;
|
int channels;
|
||||||
int need_bgcolor;
|
int need_bgcolor;
|
||||||
#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__))
|
|
||||||
int nommxfilters;
|
|
||||||
int nommxcombine;
|
|
||||||
int nommxinterlace;
|
|
||||||
#endif
|
|
||||||
int state;
|
int state;
|
||||||
uch bg_red;
|
uch bg_red;
|
||||||
uch bg_green;
|
uch bg_green;
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 1998-2007 Greg Roelofs. All rights reserved.
|
Copyright (c) 1998-2007,2017 Greg Roelofs. All rights reserved.
|
||||||
|
|
||||||
This software is provided "as is," without warranty of any kind,
|
This software is provided "as is," without warranty of any kind,
|
||||||
express or implied. In no event shall the author or contributors
|
express or implied. In no event shall the author or contributors
|
||||||
|
@ -154,17 +154,26 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
|
||||||
*pRowbytes = rowbytes = channels*width;
|
*pRowbytes = rowbytes = channels*width;
|
||||||
*pChannels = channels;
|
*pChannels = channels;
|
||||||
|
|
||||||
|
Trace((stderr, "readpng_get_image: rowbytes = %ld, height = %ld\n", rowbytes, height));
|
||||||
|
|
||||||
|
/* Guard against integer overflow */
|
||||||
|
if (height > ((size_t)(-1))/rowbytes) {
|
||||||
|
fprintf(stderr, PROGNAME ": image_data buffer would be too large\n",
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if ((image_data = (uch *)malloc(rowbytes*height)) == NULL) {
|
if ((image_data = (uch *)malloc(rowbytes*height)) == NULL) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Trace((stderr, "readpng_get_image: rowbytes = %ld, height = %ld\n", rowbytes, height));
|
|
||||||
|
|
||||||
|
|
||||||
/* now we can go ahead and just read the whole image */
|
/* now we can go ahead and just read the whole image */
|
||||||
|
|
||||||
fread(image_data, 1L, rowbytes*height, saved_infile);
|
if (fread(image_data, 1L, rowbytes*height, saved_infile) <
|
||||||
|
rowbytes*height) {
|
||||||
|
free (image_data);
|
||||||
|
image_data = NULL;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return image_data;
|
return image_data;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,10 +24,11 @@
|
||||||
- 1.10: enabled "message window"/console (thanks to David Geldreich)
|
- 1.10: enabled "message window"/console (thanks to David Geldreich)
|
||||||
- 2.00: dual-licensed (added GNU GPL)
|
- 2.00: dual-licensed (added GNU GPL)
|
||||||
- 2.01: fixed improper display of usage screen on PNG error(s)
|
- 2.01: fixed improper display of usage screen on PNG error(s)
|
||||||
|
- 2.02: check for integer overflow (Glenn R-P)
|
||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 1998-2008 Greg Roelofs. All rights reserved.
|
Copyright (c) 1998-2008, 2017 Greg Roelofs. All rights reserved.
|
||||||
|
|
||||||
This software is provided "as is," without warranty of any kind,
|
This software is provided "as is," without warranty of any kind,
|
||||||
express or implied. In no event shall the author or contributors
|
express or implied. In no event shall the author or contributors
|
||||||
|
@ -85,7 +86,33 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
/* getch replacement. Turns out, we don't really need this,
|
||||||
|
* but leave it here if we ever enable any of the uses of
|
||||||
|
* _getch in the main code
|
||||||
|
*/
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <termio.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
int repl_getch( void )
|
||||||
|
{
|
||||||
|
char ch;
|
||||||
|
int fd = fileno(stdin);
|
||||||
|
struct termio old_tty, new_tty;
|
||||||
|
|
||||||
|
ioctl(fd, TCGETA, &old_tty);
|
||||||
|
new_tty = old_tty;
|
||||||
|
new_tty.c_lflag &= ~(ICANON | ECHO | ISIG);
|
||||||
|
ioctl(fd, TCSETA, &new_tty);
|
||||||
|
fread(&ch, 1, sizeof(ch), stdin);
|
||||||
|
ioctl(fd, TCSETA, &old_tty);
|
||||||
|
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
#define _getch repl_getch
|
||||||
|
#else
|
||||||
#include <conio.h> /* only for _getch() */
|
#include <conio.h> /* only for _getch() */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* #define DEBUG : this enables the Trace() macros */
|
/* #define DEBUG : this enables the Trace() macros */
|
||||||
|
|
||||||
|
@ -153,15 +180,16 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||||
|
|
||||||
filename = (char *)NULL;
|
filename = (char *)NULL;
|
||||||
|
|
||||||
|
#ifndef __CYGWIN__
|
||||||
/* First reenable console output, which normally goes to the bit bucket
|
/* First reenable console output, which normally goes to the bit bucket
|
||||||
* for windowed apps. Closing the console window will terminate the
|
* for windowed apps. Closing the console window will terminate the
|
||||||
* app. Thanks to David.Geldreich@realviz.com for supplying the magical
|
* app. Thanks to David.Geldreich at realviz.com for supplying the magical
|
||||||
* incantation. */
|
* incantation. */
|
||||||
|
|
||||||
AllocConsole();
|
AllocConsole();
|
||||||
freopen("CONOUT$", "a", stderr);
|
freopen("CONOUT$", "a", stderr);
|
||||||
freopen("CONOUT$", "a", stdout);
|
freopen("CONOUT$", "a", stdout);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Next set the default value for our display-system exponent, i.e.,
|
/* Next set the default value for our display-system exponent, i.e.,
|
||||||
|
@ -279,7 +307,9 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||||
/* print usage screen if any errors up to this point */
|
/* print usage screen if any errors up to this point */
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
#ifndef __CYGWIN__
|
||||||
int ch;
|
int ch;
|
||||||
|
#endif
|
||||||
|
|
||||||
fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname);
|
fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname);
|
||||||
readpng_version_info();
|
readpng_version_info();
|
||||||
|
@ -293,11 +323,15 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||||
"\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n"
|
"\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n"
|
||||||
"\t\t used with transparent images\n"
|
"\t\t used with transparent images\n"
|
||||||
"\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n"
|
"\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n"
|
||||||
|
#ifndef __CYGWIN__
|
||||||
"Press Q or Esc to quit this usage screen.\n"
|
"Press Q or Esc to quit this usage screen.\n"
|
||||||
|
#endif
|
||||||
"\n", PROGNAME, default_display_exponent);
|
"\n", PROGNAME, default_display_exponent);
|
||||||
|
#ifndef __CYGWIN__
|
||||||
do
|
do
|
||||||
ch = _getch();
|
ch = _getch();
|
||||||
while (ch != 'q' && ch != 'Q' && ch != 0x1B);
|
while (ch != 'q' && ch != 'Q' && ch != 0x1B);
|
||||||
|
#endif
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,18 +367,24 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||||
|
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
#ifndef __CYGWIN__
|
||||||
int ch;
|
int ch;
|
||||||
|
#endif
|
||||||
|
|
||||||
fprintf(stderr, PROGNAME ": aborting.\n");
|
fprintf(stderr, PROGNAME ": aborting.\n");
|
||||||
|
#ifndef __CYGWIN__
|
||||||
do
|
do
|
||||||
ch = _getch();
|
ch = _getch();
|
||||||
while (ch != 'q' && ch != 'Q' && ch != 0x1B);
|
while (ch != 'q' && ch != 'Q' && ch != 0x1B);
|
||||||
|
#endif
|
||||||
exit(2);
|
exit(2);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
|
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
|
||||||
|
#ifndef __CYGWIN__
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"\n [console window: closing this window will terminate %s]\n\n",
|
"\n [console window: closing this window will terminate %s]\n\n",
|
||||||
PROGNAME);
|
PROGNAME);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -417,7 +457,12 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||||
/* wait for the user to tell us when to quit */
|
/* wait for the user to tell us when to quit */
|
||||||
|
|
||||||
printf(
|
printf(
|
||||||
"Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n");
|
#ifndef __CYGWIN__
|
||||||
|
"Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n"
|
||||||
|
#else
|
||||||
|
"Done. Press mouse button 1 (within image window) to quit.\n"
|
||||||
|
#endif
|
||||||
|
);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
while (GetMessage(&msg, NULL, 0, 0)) {
|
while (GetMessage(&msg, NULL, 0, 0)) {
|
||||||
|
@ -452,6 +497,12 @@ static int rpng_win_create_window(HINSTANCE hInst, int showmode)
|
||||||
|
|
||||||
wimage_rowbytes = ((3*image_width + 3L) >> 2) << 2;
|
wimage_rowbytes = ((3*image_width + 3L) >> 2) << 2;
|
||||||
|
|
||||||
|
/* Guard against integer overflow */
|
||||||
|
if (image_height > ((size_t)(-1))/wimage_rowbytes) {
|
||||||
|
fprintf(stderr, PROGNAME ": image_data buffer would be too large\n");
|
||||||
|
return 4; /* fail */
|
||||||
|
}
|
||||||
|
|
||||||
if (!(dib = (uch *)malloc(sizeof(BITMAPINFOHEADER) +
|
if (!(dib = (uch *)malloc(sizeof(BITMAPINFOHEADER) +
|
||||||
wimage_rowbytes*image_height)))
|
wimage_rowbytes*image_height)))
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,10 +26,13 @@
|
||||||
- 1.14: added support for X resources (thanks to Gerhard Niklasch)
|
- 1.14: added support for X resources (thanks to Gerhard Niklasch)
|
||||||
- 2.00: dual-licensed (added GNU GPL)
|
- 2.00: dual-licensed (added GNU GPL)
|
||||||
- 2.01: fixed improper display of usage screen on PNG error(s)
|
- 2.01: fixed improper display of usage screen on PNG error(s)
|
||||||
|
- 2.02: Added "void(argc);" statement to quiet pedantic compiler warnings
|
||||||
|
about unused variable (GR-P)
|
||||||
|
- 2.03: check for integer overflow (Glenn R-P)
|
||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 1998-2008 Greg Roelofs. All rights reserved.
|
Copyright (c) 1998-2008, 2017 Greg Roelofs. All rights reserved.
|
||||||
|
|
||||||
This software is provided "as is," without warranty of any kind,
|
This software is provided "as is," without warranty of any kind,
|
||||||
express or implied. In no event shall the author or contributors
|
express or implied. In no event shall the author or contributors
|
||||||
|
@ -80,9 +83,9 @@
|
||||||
|
|
||||||
#define PROGNAME "rpng-x"
|
#define PROGNAME "rpng-x"
|
||||||
#define LONGNAME "Simple PNG Viewer for X"
|
#define LONGNAME "Simple PNG Viewer for X"
|
||||||
#define VERSION "2.01 of 16 March 2008"
|
#define VERSION "2.02 of 15 June 2014"
|
||||||
#define RESNAME "rpng" /* our X resource application name */
|
#define RESNAME "rpng" /* our X resource application name */
|
||||||
#define RESCLASS "Rpng" /* our X resource class name */
|
#define RESCLASS "Rpng" /* our X resource class name */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -279,15 +282,17 @@ int main(int argc, char **argv)
|
||||||
"Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg] file.png\n"
|
"Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg] file.png\n"
|
||||||
" xdpy\tname of the target X display (e.g., ``hostname:0'')\n"
|
" xdpy\tname of the target X display (e.g., ``hostname:0'')\n"
|
||||||
" exp \ttransfer-function exponent (``gamma'') of the display\n"
|
" exp \ttransfer-function exponent (``gamma'') of the display\n"
|
||||||
"\t\t system in floating-point format (e.g., ``%.1f''); equal\n"
|
"\t\t system in floating-point format (e.g., ``%.1f''); equal\n",
|
||||||
|
PROGNAME, default_display_exponent);
|
||||||
|
|
||||||
|
fprintf(stderr, "\n"
|
||||||
"\t\t to the product of the lookup-table exponent (varies)\n"
|
"\t\t to the product of the lookup-table exponent (varies)\n"
|
||||||
"\t\t and the CRT exponent (usually 2.2); must be positive\n"
|
"\t\t and the CRT exponent (usually 2.2); must be positive\n"
|
||||||
" bg \tdesired background color in 7-character hex RGB format\n"
|
" bg \tdesired background color in 7-character hex RGB format\n"
|
||||||
"\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n"
|
"\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n"
|
||||||
"\t\t used with transparent images\n"
|
"\t\t used with transparent images\n"
|
||||||
"\nPress Q, Esc or mouse button 1 (within image window, after image\n"
|
"\nPress Q, Esc or mouse button 1 (within image window, after image\n"
|
||||||
"is displayed) to quit.\n"
|
"is displayed) to quit.\n");
|
||||||
"\n", PROGNAME, default_display_exponent);
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -419,6 +424,8 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
rpng_x_cleanup();
|
rpng_x_cleanup();
|
||||||
|
|
||||||
|
(void)argc; /* Unused */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,10 +32,12 @@
|
||||||
- 2.01: fixed 64-bit typo in readpng2.c
|
- 2.01: fixed 64-bit typo in readpng2.c
|
||||||
- 2.02: fixed improper display of usage screen on PNG error(s); fixed
|
- 2.02: fixed improper display of usage screen on PNG error(s); fixed
|
||||||
unexpected-EOF and file-read-error cases
|
unexpected-EOF and file-read-error cases
|
||||||
|
- 2.03: removed runtime MMX-enabling/disabling and obsolete -mmx* options
|
||||||
|
- 2.04: check for integer overflow (Glenn R-P)
|
||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 1998-2008 Greg Roelofs. All rights reserved.
|
Copyright (c) 1998-2008, 2017 Greg Roelofs. All rights reserved.
|
||||||
|
|
||||||
This software is provided "as is," without warranty of any kind,
|
This software is provided "as is," without warranty of any kind,
|
||||||
express or implied. In no event shall the author or contributors
|
express or implied. In no event shall the author or contributors
|
||||||
|
@ -95,7 +97,33 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <math.h> /* only for PvdM background code */
|
#include <math.h> /* only for PvdM background code */
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#ifdef __CYGWIN__
|
||||||
|
/* getch replacement. Turns out, we don't really need this,
|
||||||
|
* but leave it here if we ever enable any of the uses of
|
||||||
|
* _getch in the main code
|
||||||
|
*/
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <termio.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
int repl_getch( void )
|
||||||
|
{
|
||||||
|
char ch;
|
||||||
|
int fd = fileno(stdin);
|
||||||
|
struct termio old_tty, new_tty;
|
||||||
|
|
||||||
|
ioctl(fd, TCGETA, &old_tty);
|
||||||
|
new_tty = old_tty;
|
||||||
|
new_tty.c_lflag &= ~(ICANON | ECHO | ISIG);
|
||||||
|
ioctl(fd, TCSETA, &new_tty);
|
||||||
|
fread(&ch, 1, sizeof(ch), stdin);
|
||||||
|
ioctl(fd, TCSETA, &old_tty);
|
||||||
|
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
#define _getch repl_getch
|
||||||
|
#else
|
||||||
#include <conio.h> /* only for _getch() */
|
#include <conio.h> /* only for _getch() */
|
||||||
|
#endif
|
||||||
|
|
||||||
/* all for PvdM background code: */
|
/* all for PvdM background code: */
|
||||||
#ifndef PI
|
#ifndef PI
|
||||||
|
@ -269,16 +297,16 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||||
filename = (char *)NULL;
|
filename = (char *)NULL;
|
||||||
memset(&rpng2_info, 0, sizeof(mainprog_info));
|
memset(&rpng2_info, 0, sizeof(mainprog_info));
|
||||||
|
|
||||||
|
#ifndef __CYGWIN__
|
||||||
/* Next reenable console output, which normally goes to the bit bucket
|
/* Next reenable console output, which normally goes to the bit bucket
|
||||||
* for windowed apps. Closing the console window will terminate the
|
* for windowed apps. Closing the console window will terminate the
|
||||||
* app. Thanks to David.Geldreich@realviz.com for supplying the magical
|
* app. Thanks to David.Geldreich at realviz.com for supplying the magical
|
||||||
* incantation. */
|
* incantation. */
|
||||||
|
|
||||||
AllocConsole();
|
AllocConsole();
|
||||||
freopen("CONOUT$", "a", stderr);
|
freopen("CONOUT$", "a", stderr);
|
||||||
freopen("CONOUT$", "a", stdout);
|
freopen("CONOUT$", "a", stdout);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Set the default value for our display-system exponent, i.e., the
|
/* Set the default value for our display-system exponent, i.e., the
|
||||||
* product of the CRT exponent and the exponent corresponding to
|
* product of the CRT exponent and the exponent corresponding to
|
||||||
|
@ -395,18 +423,6 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||||
}
|
}
|
||||||
} else if (!strncmp(*argv, "-timing", 2)) {
|
} else if (!strncmp(*argv, "-timing", 2)) {
|
||||||
timing = TRUE;
|
timing = TRUE;
|
||||||
#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__))
|
|
||||||
} else if (!strncmp(*argv, "-nommxfilters", 7)) {
|
|
||||||
rpng2_info.nommxfilters = TRUE;
|
|
||||||
} else if (!strncmp(*argv, "-nommxcombine", 7)) {
|
|
||||||
rpng2_info.nommxcombine = TRUE;
|
|
||||||
} else if (!strncmp(*argv, "-nommxinterlace", 7)) {
|
|
||||||
rpng2_info.nommxinterlace = TRUE;
|
|
||||||
} else if (!strcmp(*argv, "-nommx")) {
|
|
||||||
rpng2_info.nommxfilters = TRUE;
|
|
||||||
rpng2_info.nommxcombine = TRUE;
|
|
||||||
rpng2_info.nommxinterlace = TRUE;
|
|
||||||
#endif
|
|
||||||
} else {
|
} else {
|
||||||
if (**argv != '-') {
|
if (**argv != '-') {
|
||||||
filename = *argv;
|
filename = *argv;
|
||||||
|
@ -424,15 +440,14 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||||
/* print usage screen if any errors up to this point */
|
/* print usage screen if any errors up to this point */
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
#ifndef __CYGWIN__
|
||||||
int ch;
|
int ch;
|
||||||
|
#endif
|
||||||
|
|
||||||
fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname);
|
fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname);
|
||||||
readpng2_version_info();
|
readpng2_version_info();
|
||||||
fprintf(stderr, "\n"
|
fprintf(stderr, "\n"
|
||||||
"Usage: %s [-gamma exp] [-bgcolor bg | -bgpat pat] [-timing]\n"
|
"Usage: %s [-gamma exp] [-bgcolor bg | -bgpat pat] [-timing]\n"
|
||||||
#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__))
|
|
||||||
" %*s [[-nommxfilters] [-nommxcombine] [-nommxinterlace] | -nommx]\n"
|
|
||||||
#endif
|
|
||||||
" %*s file.png\n\n"
|
" %*s file.png\n\n"
|
||||||
" exp \ttransfer-function exponent (``gamma'') of the display\n"
|
" exp \ttransfer-function exponent (``gamma'') of the display\n"
|
||||||
"\t\t system in floating-point format (e.g., ``%.1f''); equal\n"
|
"\t\t system in floating-point format (e.g., ``%.1f''); equal\n"
|
||||||
|
@ -445,21 +460,24 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||||
"\t\t transparent images; overrides -bgcolor option\n"
|
"\t\t transparent images; overrides -bgcolor option\n"
|
||||||
" -timing\tenables delay for every block read, to simulate modem\n"
|
" -timing\tenables delay for every block read, to simulate modem\n"
|
||||||
"\t\t download of image (~36 Kbps)\n"
|
"\t\t download of image (~36 Kbps)\n"
|
||||||
#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__))
|
|
||||||
" -nommx*\tdisable optimized MMX routines for decoding row filters,\n"
|
|
||||||
"\t\t combining rows, and expanding interlacing, respectively\n"
|
|
||||||
#endif
|
|
||||||
"\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n"
|
"\nPress Q, Esc or mouse button 1 after image is displayed to quit.\n"
|
||||||
|
#ifndef __CYGWIN__
|
||||||
"Press Q or Esc to quit this usage screen. ",
|
"Press Q or Esc to quit this usage screen. ",
|
||||||
|
#else
|
||||||
|
,
|
||||||
|
#endif
|
||||||
PROGNAME,
|
PROGNAME,
|
||||||
#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__))
|
#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__)) && \
|
||||||
|
!(defined(__CYGWIN__) || defined(__MINGW32__))
|
||||||
(int)strlen(PROGNAME), " ",
|
(int)strlen(PROGNAME), " ",
|
||||||
#endif
|
#endif
|
||||||
(int)strlen(PROGNAME), " ", default_display_exponent, num_bgpat);
|
(int)strlen(PROGNAME), " ", default_display_exponent, num_bgpat);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
|
#ifndef __CYGWIN__
|
||||||
do
|
do
|
||||||
ch = _getch();
|
ch = _getch();
|
||||||
while (ch != 'q' && ch != 'Q' && ch != 0x1B);
|
while (ch != 'q' && ch != 'Q' && ch != 0x1B);
|
||||||
|
#endif
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -496,18 +514,24 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||||
|
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
#ifndef __CYGWIN__
|
||||||
int ch;
|
int ch;
|
||||||
|
#endif
|
||||||
|
|
||||||
fprintf(stderr, PROGNAME ": aborting.\n");
|
fprintf(stderr, PROGNAME ": aborting.\n");
|
||||||
|
#ifndef __CYGWIN__
|
||||||
do
|
do
|
||||||
ch = _getch();
|
ch = _getch();
|
||||||
while (ch != 'q' && ch != 'Q' && ch != 0x1B);
|
while (ch != 'q' && ch != 'Q' && ch != 0x1B);
|
||||||
|
#endif
|
||||||
exit(2);
|
exit(2);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
|
fprintf(stderr, "\n%s %s: %s\n", PROGNAME, VERSION, appname);
|
||||||
|
#ifndef __CYGWIN__
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"\n [console window: closing this window will terminate %s]\n\n",
|
"\n [console window: closing this window will terminate %s]\n\n",
|
||||||
PROGNAME);
|
PROGNAME);
|
||||||
|
#endif
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -567,7 +591,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmd, int showmode)
|
||||||
"(unexpectedly) while reading PNG image file\n");
|
"(unexpectedly) while reading PNG image file\n");
|
||||||
exit(3);
|
exit(3);
|
||||||
} else /* if (error) */ {
|
} else /* if (error) */ {
|
||||||
// will print error message below
|
/* will print error message below */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -625,6 +649,13 @@ static void rpng2_win_init()
|
||||||
Trace((stderr, " width = %ld\n", rpng2_info.width))
|
Trace((stderr, " width = %ld\n", rpng2_info.width))
|
||||||
Trace((stderr, " height = %ld\n", rpng2_info.height))
|
Trace((stderr, " height = %ld\n", rpng2_info.height))
|
||||||
|
|
||||||
|
/* Guard against integer overflow */
|
||||||
|
if (rpng2_info.height > ((size_t)(-1))/rowbytes) {
|
||||||
|
fprintf(stderr, PROGNAME ": image_data buffer would be too large\n",
|
||||||
|
readpng2_cleanup(&rpng2_info);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
rpng2_info.image_data = (uch *)malloc(rowbytes * rpng2_info.height);
|
rpng2_info.image_data = (uch *)malloc(rowbytes * rpng2_info.height);
|
||||||
if (!rpng2_info.image_data) {
|
if (!rpng2_info.image_data) {
|
||||||
readpng2_cleanup(&rpng2_info);
|
readpng2_cleanup(&rpng2_info);
|
||||||
|
@ -1150,7 +1181,12 @@ static void rpng2_win_finish_display()
|
||||||
|
|
||||||
rpng2_info.state = kDone;
|
rpng2_info.state = kDone;
|
||||||
printf(
|
printf(
|
||||||
"Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n");
|
#ifndef __CYGWIN__
|
||||||
|
"Done. Press Q, Esc or mouse button 1 (within image window) to quit.\n"
|
||||||
|
#else
|
||||||
|
"Done. Press mouse button 1 (within image window) to quit.\n"
|
||||||
|
#endif
|
||||||
|
);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,10 +40,15 @@
|
||||||
- 2.02: fixed improper display of usage screen on PNG error(s); fixed
|
- 2.02: fixed improper display of usage screen on PNG error(s); fixed
|
||||||
unexpected-EOF and file-read-error cases; fixed Trace() cut-and-
|
unexpected-EOF and file-read-error cases; fixed Trace() cut-and-
|
||||||
paste bugs
|
paste bugs
|
||||||
|
- 2.03: deleted runtime MMX-enabling/disabling and obsolete -mmx* options
|
||||||
|
- 2.04: Added "void(foo);" statements to quiet pedantic compiler warnings
|
||||||
|
about unused variables (GR-P)
|
||||||
|
- 2.05: Use nanosleep() instead of usleep(), which is deprecated (GR-P).
|
||||||
|
- 2.06: check for integer overflow (Glenn R-P)
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 1998-2008 Greg Roelofs. All rights reserved.
|
Copyright (c) 1998-2010, 2014-2015, 2017 Greg Roelofs. All rights
|
||||||
|
reserved.
|
||||||
|
|
||||||
This software is provided "as is," without warranty of any kind,
|
This software is provided "as is," without warranty of any kind,
|
||||||
express or implied. In no event shall the author or contributors
|
express or implied. In no event shall the author or contributors
|
||||||
|
@ -94,9 +99,9 @@
|
||||||
|
|
||||||
#define PROGNAME "rpng2-x"
|
#define PROGNAME "rpng2-x"
|
||||||
#define LONGNAME "Progressive PNG Viewer for X"
|
#define LONGNAME "Progressive PNG Viewer for X"
|
||||||
#define VERSION "2.02 of 16 March 2008"
|
#define VERSION "2.04 of 15 June 2014"
|
||||||
#define RESNAME "rpng2" /* our X resource application name */
|
#define RESNAME "rpng2" /* our X resource application name */
|
||||||
#define RESCLASS "Rpng" /* our X resource class name */
|
#define RESCLASS "Rpng" /* our X resource class name */
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -110,6 +115,19 @@
|
||||||
#include <X11/Xos.h>
|
#include <X11/Xos.h>
|
||||||
#include <X11/keysym.h> /* defines XK_* macros */
|
#include <X11/keysym.h> /* defines XK_* macros */
|
||||||
|
|
||||||
|
#if _POSIX_C_SOURCE >= 199309L /* have nanosleep() */
|
||||||
|
# undef usleep
|
||||||
|
# define usleep(usec) { \
|
||||||
|
struct timespec ts; \
|
||||||
|
ts.tv_sec = 0; \
|
||||||
|
ts.tv_nsec = (usec) * 1000; \
|
||||||
|
nanosleep(&ts, NULL); }
|
||||||
|
# endif
|
||||||
|
|
||||||
|
#ifndef usleep /* have neither nanosleep() nor usleep() */
|
||||||
|
# define usleep(x) sleep(((x)+499999)/1000000)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef VMS
|
#ifdef VMS
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif
|
#endif
|
||||||
|
@ -131,7 +149,7 @@
|
||||||
(e.type == KeyPress && /* v--- or 1 for shifted keys */ \
|
(e.type == KeyPress && /* v--- or 1 for shifted keys */ \
|
||||||
((k = XLookupKeysym(&e.xkey, 0)) == XK_q || k == XK_Escape)))
|
((k = XLookupKeysym(&e.xkey, 0)) == XK_q || k == XK_Escape)))
|
||||||
|
|
||||||
#define NO_24BIT_MASKS /* undef case not fully written--only for redisplay() */
|
#define NO_24BIT_MASKS /* undef case not fully written--only for redisplay() */
|
||||||
|
|
||||||
#define rgb1_max bg_freq
|
#define rgb1_max bg_freq
|
||||||
#define rgb1_min bg_gray
|
#define rgb1_min bg_gray
|
||||||
|
@ -301,7 +319,7 @@ int main(int argc, char **argv)
|
||||||
int have_bg = FALSE;
|
int have_bg = FALSE;
|
||||||
#ifdef FEATURE_LOOP
|
#ifdef FEATURE_LOOP
|
||||||
int loop = FALSE;
|
int loop = FALSE;
|
||||||
long loop_interval = -1; /* seconds (100,000 max) */
|
long loop_interval = -1; /* seconds (100,000 max) */
|
||||||
#endif
|
#endif
|
||||||
double LUT_exponent; /* just the lookup table */
|
double LUT_exponent; /* just the lookup table */
|
||||||
double CRT_exponent = 2.2; /* just the monitor */
|
double CRT_exponent = 2.2; /* just the monitor */
|
||||||
|
@ -434,18 +452,6 @@ int main(int argc, char **argv)
|
||||||
else if (loop_interval > 100000) /* bit more than one day */
|
else if (loop_interval > 100000) /* bit more than one day */
|
||||||
loop_interval = 100000;
|
loop_interval = 100000;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__))
|
|
||||||
} else if (!strncmp(*argv, "-nommxfilters", 7)) {
|
|
||||||
rpng2_info.nommxfilters = TRUE;
|
|
||||||
} else if (!strncmp(*argv, "-nommxcombine", 7)) {
|
|
||||||
rpng2_info.nommxcombine = TRUE;
|
|
||||||
} else if (!strncmp(*argv, "-nommxinterlace", 7)) {
|
|
||||||
rpng2_info.nommxinterlace = TRUE;
|
|
||||||
} else if (!strcmp(*argv, "-nommx")) {
|
|
||||||
rpng2_info.nommxfilters = TRUE;
|
|
||||||
rpng2_info.nommxcombine = TRUE;
|
|
||||||
rpng2_info.nommxinterlace = TRUE;
|
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
if (**argv != '-') {
|
if (**argv != '-') {
|
||||||
|
@ -467,50 +473,47 @@ int main(int argc, char **argv)
|
||||||
fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname);
|
fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname);
|
||||||
readpng2_version_info();
|
readpng2_version_info();
|
||||||
fprintf(stderr, "\n"
|
fprintf(stderr, "\n"
|
||||||
"Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg | -bgpat pat]\n"
|
"Usage: ");
|
||||||
#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__))
|
fprintf(stderr,
|
||||||
" %*s [[-nommxfilters] [-nommxcombine] [-nommxinterlace] | -nommx]\n"
|
"%s [-display xdpy] [-gamma exp] [-bgcolor bg | -bgpat pat]\n"
|
||||||
#endif
|
" %*s [-usleep dur | -timing] [-pause]\n",
|
||||||
|
PROGNAME, (int)strlen(PROGNAME), " ");
|
||||||
|
fprintf(stderr,
|
||||||
#ifdef FEATURE_LOOP
|
#ifdef FEATURE_LOOP
|
||||||
" %*s [-usleep dur | -timing] [-pause] [-loop [sec]] file.png\n\n"
|
" [-loop [sec]]"
|
||||||
#else
|
|
||||||
" %*s [-usleep dur | -timing] [-pause] file.png\n\n"
|
|
||||||
#endif
|
#endif
|
||||||
|
" file.png\n\n");
|
||||||
|
fprintf(stderr,
|
||||||
" xdpy\tname of the target X display (e.g., ``hostname:0'')\n"
|
" xdpy\tname of the target X display (e.g., ``hostname:0'')\n"
|
||||||
" exp \ttransfer-function exponent (``gamma'') of the display\n"
|
" exp \ttransfer-function exponent (``gamma'') of the display\n"
|
||||||
"\t\t system in floating-point format (e.g., ``%.1f''); equal\n"
|
"\t\t system in floating-point format (e.g., ``%.1f''); equal\n"
|
||||||
"\t\t to the product of the lookup-table exponent (varies)\n"
|
"\t\t to the product of the lookup-table exponent (varies)\n",
|
||||||
|
default_display_exponent);
|
||||||
|
fprintf(stderr,
|
||||||
"\t\t and the CRT exponent (usually 2.2); must be positive\n"
|
"\t\t and the CRT exponent (usually 2.2); must be positive\n"
|
||||||
" bg \tdesired background color in 7-character hex RGB format\n"
|
" bg \tdesired background color in 7-character hex RGB format\n"
|
||||||
"\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n"
|
"\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n"
|
||||||
"\t\t used with transparent images; overrides -bgpat\n"
|
"\t\t used with transparent images; overrides -bgpat\n"
|
||||||
" pat \tdesired background pattern number (0-%d); used with\n"
|
" pat \tdesired background pattern number (0-%d); used with\n"
|
||||||
"\t\t transparent images; overrides -bgcolor\n"
|
"\t\t transparent images; overrides -bgcolor\n",
|
||||||
|
num_bgpat-1);
|
||||||
#ifdef FEATURE_LOOP
|
#ifdef FEATURE_LOOP
|
||||||
|
fprintf(stderr,
|
||||||
" -loop\tloops through background images after initial display\n"
|
" -loop\tloops through background images after initial display\n"
|
||||||
"\t\t is complete (depends on -bgpat)\n"
|
"\t\t is complete (depends on -bgpat)\n"
|
||||||
" sec \tseconds to display each background image (default = 2)\n"
|
" sec \tseconds to display each background image (default = 2)\n");
|
||||||
#endif
|
|
||||||
#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__))
|
|
||||||
" -nommx*\tdisable optimized MMX routines for decoding row filters,\n"
|
|
||||||
"\t\t combining rows, and expanding interlacing, respectively\n"
|
|
||||||
#endif
|
#endif
|
||||||
|
fprintf(stderr,
|
||||||
" dur \tduration in microseconds to wait after displaying each\n"
|
" dur \tduration in microseconds to wait after displaying each\n"
|
||||||
"\t\t row (for demo purposes)\n"
|
"\t\t row (for demo purposes)\n"
|
||||||
" -timing\tenables delay for every block read, to simulate modem\n"
|
" -timing\tenables delay for every block read, to simulate modem\n"
|
||||||
"\t\t download of image (~36 Kbps)\n"
|
"\t\t download of image (~36 Kbps)\n"
|
||||||
" -pause\tpauses after displaying each pass until mouse clicked\n"
|
" -pause\tpauses after displaying each pass until mouse clicked\n"
|
||||||
"\nPress Q, Esc or mouse button 1 (within image window, after image\n"
|
"\nPress Q, Esc or mouse button 1 (within image window, after image\n"
|
||||||
"is displayed) to quit.\n"
|
"is displayed) to quit.\n");
|
||||||
"\n", PROGNAME,
|
|
||||||
#if (defined(__i386__) || defined(_M_IX86) || defined(__x86_64__))
|
|
||||||
(int)strlen(PROGNAME), " ",
|
|
||||||
#endif
|
|
||||||
(int)strlen(PROGNAME), " ", default_display_exponent, num_bgpat-1);
|
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!(infile = fopen(filename, "rb"))) {
|
if (!(infile = fopen(filename, "rb"))) {
|
||||||
fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename);
|
fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename);
|
||||||
++error;
|
++error;
|
||||||
|
@ -612,7 +615,7 @@ int main(int argc, char **argv)
|
||||||
"(unexpectedly) while reading PNG image file\n");
|
"(unexpectedly) while reading PNG image file\n");
|
||||||
exit(3);
|
exit(3);
|
||||||
} else /* if (error) */ {
|
} else /* if (error) */ {
|
||||||
// will print error message below
|
/* will print error message below */
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -756,6 +759,8 @@ int main(int argc, char **argv)
|
||||||
Trace((stderr, "about to call rpng2_x_cleanup()\n"))
|
Trace((stderr, "about to call rpng2_x_cleanup()\n"))
|
||||||
rpng2_x_cleanup();
|
rpng2_x_cleanup();
|
||||||
|
|
||||||
|
(void)argc; /* Unused */
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -777,6 +782,13 @@ static void rpng2_x_init(void)
|
||||||
Trace((stderr, " width = %ld\n", rpng2_info.width))
|
Trace((stderr, " width = %ld\n", rpng2_info.width))
|
||||||
Trace((stderr, " height = %ld\n", rpng2_info.height))
|
Trace((stderr, " height = %ld\n", rpng2_info.height))
|
||||||
|
|
||||||
|
/* Guard against integer overflow */
|
||||||
|
if (rpng2_info.height > ((size_t)(-1))/rpng2_info.rowbytes) {
|
||||||
|
fprintf(stderr, PROGNAME ": image_data buffer would be too large\n");
|
||||||
|
readpng2_cleanup(&rpng2_info);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
rpng2_info.image_data = (uch *)malloc(rowbytes * rpng2_info.height);
|
rpng2_info.image_data = (uch *)malloc(rowbytes * rpng2_info.height);
|
||||||
if (!rpng2_info.image_data) {
|
if (!rpng2_info.image_data) {
|
||||||
readpng2_cleanup(&rpng2_info);
|
readpng2_cleanup(&rpng2_info);
|
||||||
|
@ -802,8 +814,9 @@ static void rpng2_x_init(void)
|
||||||
if (rpng2_x_create_window()) {
|
if (rpng2_x_create_window()) {
|
||||||
|
|
||||||
/* GRR TEMPORARY HACK: this is fundamentally no different from cases
|
/* GRR TEMPORARY HACK: this is fundamentally no different from cases
|
||||||
* above; libpng should longjmp() back to us when png_ptr goes away.
|
* above; libpng should call our error handler to longjmp() back to us
|
||||||
* If we/it segfault instead, seems like a libpng bug... */
|
* when png_ptr goes away. If we/it segfault instead, seems like a
|
||||||
|
* libpng bug... */
|
||||||
|
|
||||||
/* we're here via libpng callback, so if window fails, clean and bail */
|
/* we're here via libpng callback, so if window fails, clean and bail */
|
||||||
readpng2_cleanup(&rpng2_info);
|
readpng2_cleanup(&rpng2_info);
|
||||||
|
@ -1297,7 +1310,7 @@ static int rpng2_x_load_bg_image(void)
|
||||||
for (row = 0; row < rpng2_info.height; ++row) {
|
for (row = 0; row < rpng2_info.height; ++row) {
|
||||||
src = bg_data + row*bg_rowbytes;
|
src = bg_data + row*bg_rowbytes;
|
||||||
dest = ximage->data + row*ximage_rowbytes;
|
dest = ximage->data + row*ximage_rowbytes;
|
||||||
if (bpp == 32) { /* slightly optimized version */
|
if (bpp == 32) { /* slightly optimized version */
|
||||||
for (i = rpng2_info.width; i > 0; --i) {
|
for (i = rpng2_info.width; i > 0; --i) {
|
||||||
red = *src++;
|
red = *src++;
|
||||||
green = *src++;
|
green = *src++;
|
||||||
|
@ -1846,6 +1859,9 @@ static void rpng2_x_redisplay_image(ulg startcol, ulg startrow,
|
||||||
XFlush(display);
|
XFlush(display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
(void)startcol;
|
||||||
|
(void)width;
|
||||||
|
|
||||||
} /* end function rpng2_x_redisplay_image() */
|
} /* end function rpng2_x_redisplay_image() */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
- 1.04: fixed DOS/OS2/Win32 detection, including partial Cygwin fix
|
- 1.04: fixed DOS/OS2/Win32 detection, including partial Cygwin fix
|
||||||
(see http://home.att.net/~perlspinr/diffs/GregBook_cygwin.diff)
|
(see http://home.att.net/~perlspinr/diffs/GregBook_cygwin.diff)
|
||||||
- 2.00: dual-licensed (added GNU GPL)
|
- 2.00: dual-licensed (added GNU GPL)
|
||||||
|
- 2.01: check for integer overflow (Glenn R-P)
|
||||||
|
|
||||||
[REPORTED BUG (win32 only): "contrib/gregbook/wpng.c - cmd line
|
[REPORTED BUG (win32 only): "contrib/gregbook/wpng.c - cmd line
|
||||||
dose not work! In order to do something useful I needed to redirect
|
dose not work! In order to do something useful I needed to redirect
|
||||||
|
@ -38,7 +39,7 @@
|
||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 1998-2007 Greg Roelofs. All rights reserved.
|
Copyright (c) 1998-2007, 2017 Greg Roelofs. All rights reserved.
|
||||||
|
|
||||||
This software is provided "as is," without warranty of any kind,
|
This software is provided "as is," without warranty of any kind,
|
||||||
express or implied. In no event shall the author or contributors
|
express or implied. In no event shall the author or contributors
|
||||||
|
@ -702,7 +703,18 @@ int main(int argc, char **argv)
|
||||||
if (wpng_info.interlaced) {
|
if (wpng_info.interlaced) {
|
||||||
long i;
|
long i;
|
||||||
ulg bytes;
|
ulg bytes;
|
||||||
ulg image_bytes = rowbytes * wpng_info.height; /* overflow? */
|
ulg image_bytes;
|
||||||
|
|
||||||
|
/* Guard against integer overflow */
|
||||||
|
if (wpng_info_height > ((size_t)(-1)/rowbytes ||
|
||||||
|
wpng_info_height > ((ulg)(-1)/rowbytes) {
|
||||||
|
fprintf(stderr, PROGNAME ": image_data buffer too large\n");
|
||||||
|
writepng_cleanup(&wpng_info);
|
||||||
|
wpng_cleanup();
|
||||||
|
exit(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
image_bytes = rowbytes * wpng_info.height;
|
||||||
|
|
||||||
wpng_info.image_data = (uch *)malloc(image_bytes);
|
wpng_info.image_data = (uch *)malloc(image_bytes);
|
||||||
wpng_info.row_pointers = (uch **)malloc(wpng_info.height*sizeof(uch *));
|
wpng_info.row_pointers = (uch **)malloc(wpng_info.height*sizeof(uch *));
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
Copyright (c) 1998-2007 Greg Roelofs. All rights reserved.
|
Copyright (c) 1998-2007, 2017 Greg Roelofs. All rights reserved.
|
||||||
|
|
||||||
This software is provided "as is," without warranty of any kind,
|
This software is provided "as is," without warranty of any kind,
|
||||||
express or implied. In no event shall the author or contributors
|
express or implied. In no event shall the author or contributors
|
||||||
|
@ -55,8 +55,9 @@
|
||||||
|
|
||||||
|
|
||||||
#include <stdlib.h> /* for exit() prototype */
|
#include <stdlib.h> /* for exit() prototype */
|
||||||
|
#include <zlib.h>
|
||||||
|
|
||||||
#include "png.h" /* libpng header; includes zlib.h and setjmp.h */
|
#include "png.h" /* libpng header, includes setjmp.h */
|
||||||
#include "writepng.h" /* typedefs, common macros, public prototypes */
|
#include "writepng.h" /* typedefs, common macros, public prototypes */
|
||||||
|
|
||||||
|
|
||||||
|
@ -89,7 +90,7 @@ int writepng_init(mainprog_info *mainprog_ptr)
|
||||||
|
|
||||||
/* could also replace libpng warning-handler (final NULL), but no need: */
|
/* could also replace libpng warning-handler (final NULL), but no need: */
|
||||||
|
|
||||||
png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, mainprog_ptr,
|
png_ptr = png_create_write_struct(png_get_libpng_ver(NULL), mainprog_ptr,
|
||||||
writepng_error_handler, NULL);
|
writepng_error_handler, NULL);
|
||||||
if (!png_ptr)
|
if (!png_ptr)
|
||||||
return 4; /* out of memory */
|
return 4; /* out of memory */
|
||||||
|
@ -104,7 +105,8 @@ int writepng_init(mainprog_info *mainprog_ptr)
|
||||||
/* setjmp() must be called in every function that calls a PNG-writing
|
/* setjmp() must be called in every function that calls a PNG-writing
|
||||||
* libpng function, unless an alternate error handler was installed--
|
* libpng function, unless an alternate error handler was installed--
|
||||||
* but compatible error handlers must either use longjmp() themselves
|
* but compatible error handlers must either use longjmp() themselves
|
||||||
* (as in this program) or exit immediately, so here we go: */
|
* (as in this program) or some other method to return control to
|
||||||
|
* application code, so here we go: */
|
||||||
|
|
||||||
if (setjmp(mainprog_ptr->jmpbuf)) {
|
if (setjmp(mainprog_ptr->jmpbuf)) {
|
||||||
png_destroy_write_struct(&png_ptr, &info_ptr);
|
png_destroy_write_struct(&png_ptr, &info_ptr);
|
||||||
|
@ -388,5 +390,12 @@ static void writepng_error_handler(png_structp png_ptr, png_const_charp msg)
|
||||||
exit(99);
|
exit(99);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Now we have our data structure we can use the information in it
|
||||||
|
* to return control to our own higher level code (all the points
|
||||||
|
* where 'setjmp' is called in this file.) This will work with other
|
||||||
|
* error handling mechanisms as well - libpng always calls png_error
|
||||||
|
* when it can proceed no further, thus, so long as the error handler
|
||||||
|
* is intercepted, application code can do its own error recovery.
|
||||||
|
*/
|
||||||
longjmp(mainprog_ptr->jmpbuf, 1);
|
longjmp(mainprog_ptr->jmpbuf, 1);
|
||||||
}
|
}
|
||||||
|
|
0
libs/libpng-src/contrib/libtests/.deps/.dirstamp
Normal file
0
libs/libpng-src/contrib/libtests/.deps/.dirstamp
Normal file
112
libs/libpng-src/contrib/libtests/.deps/pngimage.Po
Normal file
112
libs/libpng-src/contrib/libtests/.deps/pngimage.Po
Normal file
|
@ -0,0 +1,112 @@
|
||||||
|
contrib/libtests/pngimage.o: contrib/libtests/pngimage.c \
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include/stdarg.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdarg.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_stdarg.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/vadefs.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_mac.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_secapi.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sdks/_mingw_directx.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sdks/_mingw_ddk.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdlib.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt_wstdlib.h \
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include-fixed/limits.h \
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include-fixed/syslimits.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/limits.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/crtdefs.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/stdlib_s.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/malloc.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/string.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/string_s.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/errno.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdio.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_off_t.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/swprintf.inl \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/stdio_s.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/assert.h config.h \
|
||||||
|
F:/lpng1637/png.h F:/lpng1637/pnglibconf.h F:/lpng1637/pngconf.h \
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include/stddef.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stddef.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/setjmp.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/time.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_timeval.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sys/timeb.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/sys/timeb_s.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/pthread_time.h
|
||||||
|
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include/stdarg.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdarg.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_stdarg.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/vadefs.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_mac.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_secapi.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sdks/_mingw_directx.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sdks/_mingw_ddk.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdlib.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt_wstdlib.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include-fixed/limits.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include-fixed/syslimits.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/limits.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/crtdefs.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/stdlib_s.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/malloc.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/string.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/string_s.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/errno.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdio.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_off_t.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/swprintf.inl:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/stdio_s.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/assert.h:
|
||||||
|
|
||||||
|
config.h:
|
||||||
|
|
||||||
|
F:/lpng1637/png.h:
|
||||||
|
|
||||||
|
F:/lpng1637/pnglibconf.h:
|
||||||
|
|
||||||
|
F:/lpng1637/pngconf.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include/stddef.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stddef.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/setjmp.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/time.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_timeval.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sys/timeb.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/sys/timeb_s.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/pthread_time.h:
|
111
libs/libpng-src/contrib/libtests/.deps/pngstest.Po
Normal file
111
libs/libpng-src/contrib/libtests/.deps/pngstest.Po
Normal file
|
@ -0,0 +1,111 @@
|
||||||
|
contrib/libtests/pngstest.o: contrib/libtests/pngstest.c \
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include/stddef.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stddef.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/crtdefs.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_mac.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_secapi.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/vadefs.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sdks/_mingw_directx.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sdks/_mingw_ddk.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdlib.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt_wstdlib.h \
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include-fixed/limits.h \
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include-fixed/syslimits.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/limits.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/stdlib_s.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/malloc.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/string.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/string_s.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdio.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_off_t.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/swprintf.inl \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/stdio_s.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/errno.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/ctype.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/math.h config.h \
|
||||||
|
F:/lpng1637/png.h F:/lpng1637/pnglibconf.h F:/lpng1637/pngconf.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/setjmp.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/time.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_timeval.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sys/timeb.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/sys/timeb_s.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/pthread_time.h \
|
||||||
|
contrib/libtests/../tools/sRGB.h contrib/libtests/pngstest-errors.h
|
||||||
|
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include/stddef.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stddef.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/crtdefs.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_mac.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_secapi.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/vadefs.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sdks/_mingw_directx.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sdks/_mingw_ddk.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdlib.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt_wstdlib.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include-fixed/limits.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include-fixed/syslimits.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/limits.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/stdlib_s.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/malloc.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/string.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/string_s.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdio.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_off_t.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/swprintf.inl:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/stdio_s.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/errno.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/ctype.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/math.h:
|
||||||
|
|
||||||
|
config.h:
|
||||||
|
|
||||||
|
F:/lpng1637/png.h:
|
||||||
|
|
||||||
|
F:/lpng1637/pnglibconf.h:
|
||||||
|
|
||||||
|
F:/lpng1637/pngconf.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/setjmp.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/time.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_timeval.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sys/timeb.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/sys/timeb_s.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/pthread_time.h:
|
||||||
|
|
||||||
|
contrib/libtests/../tools/sRGB.h:
|
||||||
|
|
||||||
|
contrib/libtests/pngstest-errors.h:
|
95
libs/libpng-src/contrib/libtests/.deps/pngunknown.Po
Normal file
95
libs/libpng-src/contrib/libtests/.deps/pngunknown.Po
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
contrib/libtests/pngunknown.o: contrib/libtests/pngunknown.c \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdlib.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_mac.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_secapi.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/vadefs.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sdks/_mingw_directx.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sdks/_mingw_ddk.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt_wstdlib.h \
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include-fixed/limits.h \
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include-fixed/syslimits.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/limits.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/crtdefs.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/stdlib_s.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/malloc.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/string.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/string_s.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdio.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_off_t.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/swprintf.inl \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/stdio_s.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/setjmp.h F:/lpng1637/png.h \
|
||||||
|
F:/lpng1637/pnglibconf.h F:/lpng1637/pngconf.h \
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include/stddef.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stddef.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/time.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_timeval.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sys/timeb.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/sys/timeb_s.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/pthread_time.h
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdlib.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_mac.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_secapi.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/vadefs.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sdks/_mingw_directx.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sdks/_mingw_ddk.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt_wstdlib.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include-fixed/limits.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include-fixed/syslimits.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/limits.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/crtdefs.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/stdlib_s.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/malloc.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/string.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/string_s.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdio.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_off_t.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/swprintf.inl:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/stdio_s.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/setjmp.h:
|
||||||
|
|
||||||
|
F:/lpng1637/png.h:
|
||||||
|
|
||||||
|
F:/lpng1637/pnglibconf.h:
|
||||||
|
|
||||||
|
F:/lpng1637/pngconf.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include/stddef.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stddef.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/time.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_timeval.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sys/timeb.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/sys/timeb_s.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/pthread_time.h:
|
150
libs/libpng-src/contrib/libtests/.deps/pngvalid.Po
Normal file
150
libs/libpng-src/contrib/libtests/.deps/pngvalid.Po
Normal file
|
@ -0,0 +1,150 @@
|
||||||
|
contrib/libtests/pngvalid.o: contrib/libtests/pngvalid.c \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/signal.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/crtdefs.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_mac.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_secapi.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/vadefs.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sdks/_mingw_directx.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sdks/_mingw_ddk.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/pthread_signal.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdio.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_off_t.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/swprintf.inl \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/stdio_s.h config.h \
|
||||||
|
F:/lpng1637/png.h F:/lpng1637/pnglibconf.h F:/lpng1637/pngconf.h \
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include-fixed/limits.h \
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include-fixed/syslimits.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/limits.h \
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include/stddef.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stddef.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/setjmp.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/time.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_timeval.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sys/timeb.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/sys/timeb_s.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/pthread_time.h \
|
||||||
|
C:/msys64/mingw64/include/zlib.h C:/msys64/mingw64/include/zconf.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sys/types.h \
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include/stdarg.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdarg.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_stdarg.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/unistd.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/io.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/string.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/string_s.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/process.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt_startup.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/getopt.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/pthread_unistd.h \
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include/float.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/float.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdlib.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt_wstdlib.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/stdlib_s.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/malloc.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/math.h \
|
||||||
|
contrib/libtests/../visupng/cexcept.h
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/signal.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/crtdefs.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_mac.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_secapi.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/vadefs.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sdks/_mingw_directx.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sdks/_mingw_ddk.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/pthread_signal.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdio.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_off_t.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/swprintf.inl:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/stdio_s.h:
|
||||||
|
|
||||||
|
config.h:
|
||||||
|
|
||||||
|
F:/lpng1637/png.h:
|
||||||
|
|
||||||
|
F:/lpng1637/pnglibconf.h:
|
||||||
|
|
||||||
|
F:/lpng1637/pngconf.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include-fixed/limits.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include-fixed/syslimits.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/limits.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include/stddef.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stddef.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/setjmp.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/time.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_timeval.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sys/timeb.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/sys/timeb_s.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/pthread_time.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/include/zlib.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/include/zconf.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sys/types.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include/stdarg.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdarg.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_stdarg.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/unistd.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/io.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/string.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/string_s.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/process.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt_startup.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/getopt.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/pthread_unistd.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include/float.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/float.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdlib.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt_wstdlib.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/stdlib_s.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/malloc.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/math.h:
|
||||||
|
|
||||||
|
contrib/libtests/../visupng/cexcept.h:
|
100
libs/libpng-src/contrib/libtests/.deps/timepng.Po
Normal file
100
libs/libpng-src/contrib/libtests/.deps/timepng.Po
Normal file
|
@ -0,0 +1,100 @@
|
||||||
|
contrib/libtests/timepng.o: contrib/libtests/timepng.c \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdlib.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_mac.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_secapi.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/vadefs.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sdks/_mingw_directx.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sdks/_mingw_ddk.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt_wstdlib.h \
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include-fixed/limits.h \
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include-fixed/syslimits.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/limits.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/crtdefs.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/stdlib_s.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/malloc.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdio.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_off_t.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/swprintf.inl \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/stdio_s.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/string.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/string_s.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/errno.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/time.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_timeval.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sys/timeb.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/sys/timeb_s.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/pthread_time.h config.h \
|
||||||
|
F:/lpng1637/png.h F:/lpng1637/pnglibconf.h F:/lpng1637/pngconf.h \
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include/stddef.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stddef.h \
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/setjmp.h
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdlib.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_mac.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_secapi.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/vadefs.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sdks/_mingw_directx.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sdks/_mingw_ddk.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/corecrt_wstdlib.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include-fixed/limits.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include-fixed/syslimits.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/limits.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/crtdefs.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/stdlib_s.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/malloc.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stdio.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_mingw_off_t.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/swprintf.inl:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/stdio_s.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/string.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/string_s.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/errno.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/time.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/_timeval.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sys/timeb.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/sec_api/sys/timeb_s.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/pthread_time.h:
|
||||||
|
|
||||||
|
config.h:
|
||||||
|
|
||||||
|
F:/lpng1637/png.h:
|
||||||
|
|
||||||
|
F:/lpng1637/pnglibconf.h:
|
||||||
|
|
||||||
|
F:/lpng1637/pngconf.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/9.1.0/include/stddef.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/stddef.h:
|
||||||
|
|
||||||
|
C:/msys64/mingw64/x86_64-w64-mingw32/include/setjmp.h:
|
0
libs/libpng-src/contrib/libtests/.dirstamp
Normal file
0
libs/libpng-src/contrib/libtests/.dirstamp
Normal file
65
libs/libpng-src/contrib/libtests/fakepng.c
Normal file
65
libs/libpng-src/contrib/libtests/fakepng.c
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
/* Fake a PNG - just write it out directly.
|
||||||
|
*
|
||||||
|
* COPYRIGHT: Written by John Cunningham Bowler, 2014.
|
||||||
|
* To the extent possible under law, the author has waived all copyright and
|
||||||
|
* related or neighboring rights to this work. This work is published from:
|
||||||
|
* United States.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <zlib.h> /* for crc32 */
|
||||||
|
|
||||||
|
void
|
||||||
|
put_uLong(uLong val)
|
||||||
|
{
|
||||||
|
putchar(val >> 24);
|
||||||
|
putchar(val >> 16);
|
||||||
|
putchar(val >> 8);
|
||||||
|
putchar(val >> 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
put_chunk(const unsigned char *chunk, uInt length)
|
||||||
|
{
|
||||||
|
uLong crc;
|
||||||
|
|
||||||
|
put_uLong(length-4); /* Exclude the tag */
|
||||||
|
|
||||||
|
fwrite(chunk, length, 1, stdout);
|
||||||
|
|
||||||
|
crc = crc32(0, Z_NULL, 0);
|
||||||
|
put_uLong(crc32(crc, chunk, length));
|
||||||
|
}
|
||||||
|
|
||||||
|
const unsigned char signature[] =
|
||||||
|
{
|
||||||
|
137, 80, 78, 71, 13, 10, 26, 10
|
||||||
|
};
|
||||||
|
|
||||||
|
const unsigned char IHDR[] =
|
||||||
|
{
|
||||||
|
73, 72, 68, 82, /* IHDR */
|
||||||
|
0, 0, 0, 1, /* width */
|
||||||
|
0, 0, 0, 1, /* height */
|
||||||
|
1, /* bit depth */
|
||||||
|
0, /* color type: greyscale */
|
||||||
|
0, /* compression method */
|
||||||
|
0, /* filter method */
|
||||||
|
0 /* interlace method: none */
|
||||||
|
};
|
||||||
|
|
||||||
|
const unsigned char unknown[] =
|
||||||
|
{
|
||||||
|
'u', 'n', 'K', 'n' /* "unKn" - private safe to copy */
|
||||||
|
};
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
fwrite(signature, sizeof signature, 1, stdout);
|
||||||
|
put_chunk(IHDR, sizeof IHDR);
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
put_chunk(unknown, sizeof unknown);
|
||||||
|
}
|
102
libs/libpng-src/contrib/libtests/gentests.sh
Normal file
102
libs/libpng-src/contrib/libtests/gentests.sh
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# Copyright (c) 2013 John Cunningham Bowler
|
||||||
|
#
|
||||||
|
# Last changed in libpng 1.6.0 [February 14, 2013]
|
||||||
|
#
|
||||||
|
# This code is released under the libpng license.
|
||||||
|
# For conditions of distribution and use, see the disclaimer
|
||||||
|
# and license in png.h
|
||||||
|
#
|
||||||
|
# Generate a set of PNG test images. The images are generated in a
|
||||||
|
# sub-directory called 'tests' by default, however a command line argument will
|
||||||
|
# change that name. The generation requires a built version of makepng in the
|
||||||
|
# current directory.
|
||||||
|
#
|
||||||
|
usage(){
|
||||||
|
exec >&2
|
||||||
|
echo "$0 [<directory>]"
|
||||||
|
echo ' Generate a set of PNG test files in "directory" ("tests" by default)'
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
mp="$PWD/makepng"
|
||||||
|
test -x "$mp" || {
|
||||||
|
exec >&2
|
||||||
|
echo "$0: the 'makepng' program must exist"
|
||||||
|
echo " in the directory within which this program:"
|
||||||
|
echo " $mp"
|
||||||
|
echo " is executed"
|
||||||
|
usage
|
||||||
|
}
|
||||||
|
|
||||||
|
# Just one argument: the directory
|
||||||
|
testdir="tests"
|
||||||
|
test $# -gt 1 && {
|
||||||
|
testdir="$1"
|
||||||
|
shift
|
||||||
|
}
|
||||||
|
test $# -eq 0 || usage
|
||||||
|
|
||||||
|
# Take care not to clobber something
|
||||||
|
if test -e "$testdir"
|
||||||
|
then
|
||||||
|
test -d "$testdir" || usage
|
||||||
|
else
|
||||||
|
# mkdir -p isn't portable, so do the following
|
||||||
|
mkdir "$testdir" 2>/dev/null || mkdir -p "$testdir" || usage
|
||||||
|
fi
|
||||||
|
|
||||||
|
# This fails in a very satisfactory way if it's not accessible
|
||||||
|
cd "$testdir"
|
||||||
|
:>"test$$.png" || {
|
||||||
|
exec >&2
|
||||||
|
echo "$testdir: directory not writable"
|
||||||
|
usage
|
||||||
|
}
|
||||||
|
rm "test$$.png" || {
|
||||||
|
exec >&2
|
||||||
|
echo "$testdir: you have create but not write privileges here."
|
||||||
|
echo " This is unexpected. You have a spurion; "'"'"test$$.png"'"'"."
|
||||||
|
echo " You need to remove this yourself. Try a different directory."
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Now call makepng ($mp) to create every file we can think of with a
|
||||||
|
# reasonable name
|
||||||
|
doit(){
|
||||||
|
for gamma in "" --sRGB --linear --1.8
|
||||||
|
do
|
||||||
|
case "$gamma" in
|
||||||
|
"")
|
||||||
|
gname=;;
|
||||||
|
--sRGB)
|
||||||
|
gname="-srgb";;
|
||||||
|
--linear)
|
||||||
|
gname="-lin";;
|
||||||
|
--1.8)
|
||||||
|
gname="-18";;
|
||||||
|
*)
|
||||||
|
gname="-$gamma";;
|
||||||
|
esac
|
||||||
|
"$mp" $gamma "$1" "$2" "test-$1-$2$gname.png"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
#
|
||||||
|
for ct in gray palette
|
||||||
|
do
|
||||||
|
for bd in 1 2 4 8
|
||||||
|
do
|
||||||
|
doit "$ct" "$bd"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
#
|
||||||
|
doit "gray" "16"
|
||||||
|
#
|
||||||
|
for ct in gray-alpha rgb rgb-alpha
|
||||||
|
do
|
||||||
|
for bd in 8 16
|
||||||
|
do
|
||||||
|
doit "$ct" "$bd"
|
||||||
|
done
|
||||||
|
done
|
1941
libs/libpng-src/contrib/libtests/makepng.c
Normal file
1941
libs/libpng-src/contrib/libtests/makepng.c
Normal file
File diff suppressed because it is too large
Load diff
1712
libs/libpng-src/contrib/libtests/pngimage.c
Normal file
1712
libs/libpng-src/contrib/libtests/pngimage.c
Normal file
File diff suppressed because it is too large
Load diff
165
libs/libpng-src/contrib/libtests/pngstest-errors.h
Normal file
165
libs/libpng-src/contrib/libtests/pngstest-errors.h
Normal file
|
@ -0,0 +1,165 @@
|
||||||
|
/* contrib/libtests/pngstest-errors.h
|
||||||
|
*
|
||||||
|
* BUILT USING: libpng version 1.6.19beta03 - September 25, 2015
|
||||||
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*
|
||||||
|
* THIS IS A MACHINE GENERATED FILE: do not edit it directly!
|
||||||
|
* Instead run:
|
||||||
|
*
|
||||||
|
* pngstest --accumulate
|
||||||
|
*
|
||||||
|
* on as many PNG files as possible; at least PNGSuite and
|
||||||
|
* contrib/libtests/testpngs.
|
||||||
|
*/
|
||||||
|
static png_uint_16 gpc_error[16/*in*/][16/*out*/][4/*a*/] =
|
||||||
|
{
|
||||||
|
{ /* input: sRGB-gray */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 372, 0 }, { 0, 0, 372, 0 }, { 0, 0, 372, 0 }, { 0, 0, 372, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: sRGB-gray+alpha */
|
||||||
|
{ 0, 19, 0, 0 }, { 0, 0, 0, 0 }, { 0, 20, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 897, 788, 0 }, { 0, 897, 788, 0 }, { 0, 897, 788, 0 }, { 0, 897, 788, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: sRGB-rgb */
|
||||||
|
{ 0, 0, 19, 0 }, { 0, 0, 19, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 893, 0 }, { 0, 0, 893, 0 }, { 0, 0, 811, 0 }, { 0, 0, 811, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: sRGB-rgb+alpha */
|
||||||
|
{ 0, 16, 17, 0 }, { 0, 17, 17, 0 }, { 0, 19, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 850, 875, 0 }, { 0, 850, 875, 0 }, { 0, 897, 788, 0 }, { 0, 897, 788, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: linear-gray */
|
||||||
|
{ 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: linear-gray+alpha */
|
||||||
|
{ 0, 74, 9, 0 }, { 0, 20, 9, 0 }, { 0, 74, 9, 0 }, { 0, 20, 9, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 0, 0 }, { 0, 1, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: linear-rgb */
|
||||||
|
{ 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 },
|
||||||
|
{ 0, 0, 4, 0 }, { 0, 0, 4, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: linear-rgb+alpha */
|
||||||
|
{ 0, 126, 143, 0 }, { 0, 11, 7, 0 }, { 0, 74, 9, 0 }, { 0, 17, 9, 0 },
|
||||||
|
{ 0, 4, 4, 0 }, { 0, 5, 4, 0 }, { 0, 0, 0, 0 }, { 0, 1, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: color-mapped-sRGB-gray */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: color-mapped-sRGB-gray+alpha */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: color-mapped-sRGB-rgb */
|
||||||
|
{ 0, 0, 13, 0 }, { 0, 0, 13, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 },
|
||||||
|
{ 0, 0, 673, 0 }, { 0, 0, 673, 0 }, { 0, 0, 674, 0 }, { 0, 0, 674, 0 },
|
||||||
|
{ 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 460, 0 }, { 0, 0, 460, 0 }, { 0, 0, 263, 0 }, { 0, 0, 263, 0 }
|
||||||
|
}, { /* input: color-mapped-sRGB-rgb+alpha */
|
||||||
|
{ 0, 6, 8, 0 }, { 0, 7, 8, 0 }, { 0, 75, 9, 0 }, { 0, 9, 9, 0 },
|
||||||
|
{ 0, 585, 427, 0 }, { 0, 585, 427, 0 }, { 0, 717, 514, 0 }, { 0, 717, 514, 0 },
|
||||||
|
{ 0, 1, 1, 0 }, { 0, 1, 1, 0 }, { 0, 1, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 13323, 460, 0 }, { 0, 427, 460, 0 }, { 0, 16480, 263, 0 }, { 0, 243, 263, 0 }
|
||||||
|
}, { /* input: color-mapped-linear-gray */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 282, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: color-mapped-linear-gray+alpha */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 253, 282, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: color-mapped-linear-rgb */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 265, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: color-mapped-linear-rgb+alpha */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 243, 265, 0 }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
static png_uint_16 gpc_error_via_linear[16][4/*out*/][4] =
|
||||||
|
{
|
||||||
|
{ /* input: sRGB-gray */
|
||||||
|
{ 0, 0, 7, 0 }, { 0, 0, 7, 0 }, { 0, 0, 7, 0 }, { 0, 0, 7, 0 }
|
||||||
|
}, { /* input: sRGB-gray+alpha */
|
||||||
|
{ 0, 15, 15, 0 }, { 0, 186, 15, 0 }, { 0, 15, 15, 0 }, { 0, 186, 15, 0 }
|
||||||
|
}, { /* input: sRGB-rgb */
|
||||||
|
{ 0, 0, 20, 0 }, { 0, 0, 20, 0 }, { 0, 0, 15, 0 }, { 0, 0, 15, 0 }
|
||||||
|
}, { /* input: sRGB-rgb+alpha */
|
||||||
|
{ 0, 16, 17, 0 }, { 0, 187, 17, 0 }, { 0, 15, 15, 0 }, { 0, 186, 15, 0 }
|
||||||
|
}, { /* input: linear-gray */
|
||||||
|
{ 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 }
|
||||||
|
}, { /* input: linear-gray+alpha */
|
||||||
|
{ 0, 1, 1, 0 }, { 0, 1, 1, 0 }, { 0, 1, 1, 0 }, { 0, 1, 1, 0 }
|
||||||
|
}, { /* input: linear-rgb */
|
||||||
|
{ 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 }
|
||||||
|
}, { /* input: linear-rgb+alpha */
|
||||||
|
{ 0, 1, 1, 0 }, { 0, 9, 1, 0 }, { 0, 1, 1, 0 }, { 0, 1, 1, 0 }
|
||||||
|
}, { /* input: color-mapped-sRGB-gray */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: color-mapped-sRGB-gray+alpha */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: color-mapped-sRGB-rgb */
|
||||||
|
{ 0, 0, 13, 0 }, { 0, 0, 13, 0 }, { 0, 0, 14, 0 }, { 0, 0, 14, 0 }
|
||||||
|
}, { /* input: color-mapped-sRGB-rgb+alpha */
|
||||||
|
{ 0, 4, 8, 0 }, { 0, 9, 8, 0 }, { 0, 9, 5, 0 }, { 0, 32, 5, 0 }
|
||||||
|
}, { /* input: color-mapped-linear-gray */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: color-mapped-linear-gray+alpha */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: color-mapped-linear-rgb */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}, { /* input: color-mapped-linear-rgb+alpha */
|
||||||
|
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
static png_uint_16 gpc_error_to_colormap[8/*i*/][8/*o*/][4] =
|
||||||
|
{
|
||||||
|
{ /* input: sRGB-gray */
|
||||||
|
{ 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 },
|
||||||
|
{ 0, 0, 560, 0 }, { 0, 0, 560, 0 }, { 0, 0, 560, 0 }, { 0, 0, 560, 0 }
|
||||||
|
}, { /* input: sRGB-gray+alpha */
|
||||||
|
{ 0, 19, 9, 0 }, { 0, 255, 9, 25 }, { 0, 88, 9, 0 }, { 0, 255, 9, 25 },
|
||||||
|
{ 0, 1012, 928, 0 }, { 0, 16026, 928, 6425 }, { 0, 1012, 928, 0 }, { 0, 16026, 928, 6425 }
|
||||||
|
}, { /* input: sRGB-rgb */
|
||||||
|
{ 0, 0, 19, 0 }, { 0, 0, 19, 0 }, { 0, 0, 25, 0 }, { 0, 0, 25, 0 },
|
||||||
|
{ 0, 0, 962, 0 }, { 0, 0, 962, 0 }, { 0, 0, 13677, 0 }, { 0, 0, 13677, 0 }
|
||||||
|
}, { /* input: sRGB-rgb+alpha */
|
||||||
|
{ 0, 63, 77, 0 }, { 0, 255, 19, 25 }, { 0, 225, 25, 0 }, { 0, 255, 25, 67 },
|
||||||
|
{ 0, 17534, 18491, 0 }, { 0, 15736, 2824, 6425 }, { 0, 14019, 13677, 0 }, { 0, 50115, 13677, 17219 }
|
||||||
|
}, { /* input: linear-gray */
|
||||||
|
{ 0, 0, 73, 0 }, { 0, 0, 73, 0 }, { 0, 0, 73, 0 }, { 0, 0, 73, 0 },
|
||||||
|
{ 0, 0, 18817, 0 }, { 0, 0, 18817, 0 }, { 0, 0, 18817, 0 }, { 0, 0, 18817, 0 }
|
||||||
|
}, { /* input: linear-gray+alpha */
|
||||||
|
{ 0, 74, 74, 0 }, { 0, 255, 74, 25 }, { 0, 99, 74, 0 }, { 0, 255, 74, 25 },
|
||||||
|
{ 0, 18919, 18907, 0 }, { 0, 24549, 18907, 6553 }, { 0, 18919, 18907, 0 }, { 0, 24549, 18907, 6553 }
|
||||||
|
}, { /* input: linear-rgb */
|
||||||
|
{ 0, 0, 73, 0 }, { 0, 0, 73, 0 }, { 0, 0, 98, 0 }, { 0, 0, 98, 0 },
|
||||||
|
{ 0, 0, 18664, 0 }, { 0, 0, 18664, 0 }, { 0, 0, 24998, 0 }, { 0, 0, 24998, 0 }
|
||||||
|
}, { /* input: linear-rgb+alpha */
|
||||||
|
{ 0, 181, 196, 0 }, { 0, 255, 61, 25 }, { 206, 187, 98, 0 }, { 0, 255, 98, 67 },
|
||||||
|
{ 0, 18141, 18137, 0 }, { 0, 17494, 17504, 6553 }, { 0, 24979, 24992, 0 }, { 0, 49172, 24992, 17347 }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/* END MACHINE GENERATED */
|
3828
libs/libpng-src/contrib/libtests/pngstest.c
Normal file
3828
libs/libpng-src/contrib/libtests/pngstest.c
Normal file
File diff suppressed because it is too large
Load diff
1294
libs/libpng-src/contrib/libtests/pngunknown.c
Normal file
1294
libs/libpng-src/contrib/libtests/pngunknown.c
Normal file
File diff suppressed because it is too large
Load diff
12230
libs/libpng-src/contrib/libtests/pngvalid.c
Normal file
12230
libs/libpng-src/contrib/libtests/pngvalid.c
Normal file
File diff suppressed because it is too large
Load diff
115
libs/libpng-src/contrib/libtests/readpng.c
Normal file
115
libs/libpng-src/contrib/libtests/readpng.c
Normal file
|
@ -0,0 +1,115 @@
|
||||||
|
/* readpng.c
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013 John Cunningham Bowler
|
||||||
|
*
|
||||||
|
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||||
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*
|
||||||
|
* Load an arbitrary number of PNG files (from the command line, or, if there
|
||||||
|
* are no arguments on the command line, from stdin) then run a time test by
|
||||||
|
* reading each file by row. The test does nothing with the read result and
|
||||||
|
* does no transforms. The only output is a time as a floating point number of
|
||||||
|
* seconds with 9 decimal digits.
|
||||||
|
*/
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Define the following to use this test against your installed libpng, rather
|
||||||
|
* than the one being built here:
|
||||||
|
*/
|
||||||
|
#ifdef PNG_FREESTANDING_TESTS
|
||||||
|
# include <png.h>
|
||||||
|
#else
|
||||||
|
# include "../../png.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static int
|
||||||
|
read_png(FILE *fp)
|
||||||
|
{
|
||||||
|
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,0);
|
||||||
|
png_infop info_ptr = NULL;
|
||||||
|
png_bytep row = NULL, display = NULL;
|
||||||
|
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (setjmp(png_jmpbuf(png_ptr)))
|
||||||
|
{
|
||||||
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||||
|
if (row != NULL) free(row);
|
||||||
|
if (display != NULL) free(display);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
png_init_io(png_ptr, fp);
|
||||||
|
|
||||||
|
info_ptr = png_create_info_struct(png_ptr);
|
||||||
|
if (info_ptr == NULL)
|
||||||
|
png_error(png_ptr, "OOM allocating info structure");
|
||||||
|
|
||||||
|
png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_ALWAYS, NULL, 0);
|
||||||
|
|
||||||
|
png_read_info(png_ptr, info_ptr);
|
||||||
|
|
||||||
|
{
|
||||||
|
size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||||
|
|
||||||
|
/* Failure to initialize these is harmless */
|
||||||
|
row = malloc(rowbytes);
|
||||||
|
display = malloc(rowbytes);
|
||||||
|
|
||||||
|
if (row == NULL || display == NULL)
|
||||||
|
png_error(png_ptr, "OOM allocating row buffers");
|
||||||
|
|
||||||
|
{
|
||||||
|
png_uint_32 height = png_get_image_height(png_ptr, info_ptr);
|
||||||
|
# ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||||
|
int passes = png_set_interlace_handling(png_ptr);
|
||||||
|
# else /* !READ_INTERLACING */
|
||||||
|
int passes = png_get_interlace_type(png_ptr, info_ptr) ==
|
||||||
|
PNG_INTERLACE_ADAM7 ? PNG_INTERLACE_ADAM7_PASSES : 1;
|
||||||
|
# endif /* !READ_INTERLACING */
|
||||||
|
int pass;
|
||||||
|
|
||||||
|
png_start_read_image(png_ptr);
|
||||||
|
|
||||||
|
for (pass = 0; pass < passes; ++pass)
|
||||||
|
{
|
||||||
|
png_uint_32 y = height;
|
||||||
|
|
||||||
|
# ifndef PNG_READ_INTERLACING_SUPPORTED
|
||||||
|
if (passes == PNG_INTERLACE_ADAM7_PASSES)
|
||||||
|
y = PNG_PASS_ROWS(y, pass);
|
||||||
|
# endif /* READ_INTERLACING */
|
||||||
|
|
||||||
|
/* NOTE: this trashes the row each time; interlace handling won't
|
||||||
|
* work, but this avoids memory thrashing for speed testing.
|
||||||
|
*/
|
||||||
|
while (y-- > 0)
|
||||||
|
png_read_row(png_ptr, row, display);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make sure to read to the end of the file: */
|
||||||
|
png_read_end(png_ptr, info_ptr);
|
||||||
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||||
|
free(row);
|
||||||
|
free(display);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
main(void)
|
||||||
|
{
|
||||||
|
/* Exit code 0 on success. */
|
||||||
|
return !read_png(stdin);
|
||||||
|
}
|
999
libs/libpng-src/contrib/libtests/tarith.c
Normal file
999
libs/libpng-src/contrib/libtests/tarith.c
Normal file
|
@ -0,0 +1,999 @@
|
||||||
|
|
||||||
|
/* tarith.c
|
||||||
|
*
|
||||||
|
* Copyright (c) 2011-2013 John Cunningham Bowler
|
||||||
|
*
|
||||||
|
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||||
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*
|
||||||
|
* Test internal arithmetic functions of libpng.
|
||||||
|
*
|
||||||
|
* This code must be linked against a math library (-lm), but does not require
|
||||||
|
* libpng or zlib to work. Because it includes the complete source of 'png.c'
|
||||||
|
* it tests the code with whatever compiler options are used to build it.
|
||||||
|
* Changing these options can substantially change the errors in the
|
||||||
|
* calculations that the compiler chooses!
|
||||||
|
*/
|
||||||
|
#define _POSIX_SOURCE 1
|
||||||
|
#define _ISOC99_SOURCE 1
|
||||||
|
|
||||||
|
/* Obtain a copy of the code to be tested (plus other things), disabling
|
||||||
|
* stuff that is not required.
|
||||||
|
*/
|
||||||
|
#include <math.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
|
#include "../../pngpriv.h"
|
||||||
|
|
||||||
|
#define png_error png_warning
|
||||||
|
|
||||||
|
void png_warning(png_const_structrp png_ptr, png_const_charp msg)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "validation: %s\n", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define png_fixed_error png_fixed_warning
|
||||||
|
|
||||||
|
void png_fixed_warning(png_const_structrp png_ptr, png_const_charp msg)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "overflow in: %s\n", msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
#define png_set_error_fn(pp, ep, efp, wfp) ((void)0)
|
||||||
|
#define png_malloc(pp, s) malloc(s)
|
||||||
|
#define png_malloc_warn(pp, s) malloc(s)
|
||||||
|
#define png_malloc_base(pp, s) malloc(s)
|
||||||
|
#define png_calloc(pp, s) calloc(1, (s))
|
||||||
|
#define png_free(pp, s) free(s)
|
||||||
|
|
||||||
|
#define png_safecat(b, sb, pos, str) (pos)
|
||||||
|
#define png_format_number(start, end, format, number) (start)
|
||||||
|
|
||||||
|
#define crc32(crc, pp, s) (crc)
|
||||||
|
#define inflateReset(zs) Z_OK
|
||||||
|
|
||||||
|
#define png_create_struct(type) (0)
|
||||||
|
#define png_destroy_struct(pp) ((void)0)
|
||||||
|
#define png_create_struct_2(type, m, mm) (0)
|
||||||
|
#define png_destroy_struct_2(pp, f, mm) ((void)0)
|
||||||
|
|
||||||
|
#undef PNG_SIMPLIFIED_READ_SUPPORTED
|
||||||
|
#undef PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||||
|
#undef PNG_USER_MEM_SUPPORTED
|
||||||
|
|
||||||
|
#include "../../png.c"
|
||||||
|
|
||||||
|
/* Validate ASCII to fp routines. */
|
||||||
|
static int verbose = 0;
|
||||||
|
|
||||||
|
int validation_ascii_to_fp(int count, int argc, char **argv)
|
||||||
|
{
|
||||||
|
int showall = 0;
|
||||||
|
double max_error=2; /* As a percentage error-in-last-digit/.5 */
|
||||||
|
double max_error_abs=17; /* Used when precision is DBL_DIG */
|
||||||
|
double max = 0;
|
||||||
|
double max_abs = 0;
|
||||||
|
double test = 0; /* Important to test this. */
|
||||||
|
int precision = 5;
|
||||||
|
int nonfinite = 0;
|
||||||
|
int finite = 0;
|
||||||
|
int ok = 0;
|
||||||
|
int failcount = 0;
|
||||||
|
int minorarith = 0;
|
||||||
|
|
||||||
|
while (--argc > 0)
|
||||||
|
if (strcmp(*++argv, "-a") == 0)
|
||||||
|
showall = 1;
|
||||||
|
else if (strcmp(*argv, "-e") == 0 && argc > 0)
|
||||||
|
{
|
||||||
|
--argc;
|
||||||
|
max_error = atof(*++argv);
|
||||||
|
}
|
||||||
|
else if (strcmp(*argv, "-E") == 0 && argc > 0)
|
||||||
|
{
|
||||||
|
--argc;
|
||||||
|
max_error_abs = atof(*++argv);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "unknown argument %s\n", *argv);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
size_t index;
|
||||||
|
int state, failed = 0;
|
||||||
|
char buffer[64];
|
||||||
|
|
||||||
|
if (isfinite(test))
|
||||||
|
++finite;
|
||||||
|
else
|
||||||
|
++nonfinite;
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
fprintf(stderr, "%.*g %d\n", DBL_DIG, test, precision);
|
||||||
|
|
||||||
|
/* Check for overflow in the buffer by setting a marker. */
|
||||||
|
memset(buffer, 71, sizeof buffer);
|
||||||
|
|
||||||
|
png_ascii_from_fp(0, buffer, precision+10, test, precision);
|
||||||
|
|
||||||
|
/* Allow for a three digit exponent, this stuff will fail if
|
||||||
|
* the exponent is bigger than this!
|
||||||
|
*/
|
||||||
|
if (buffer[precision+7] != 71)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%g[%d] -> '%s'[%lu] buffer overflow\n", test,
|
||||||
|
precision, buffer, (unsigned long)strlen(buffer));
|
||||||
|
failed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Following are used for the number parser below and must be
|
||||||
|
* initialized to zero.
|
||||||
|
*/
|
||||||
|
state = 0;
|
||||||
|
index = 0;
|
||||||
|
if (!isfinite(test))
|
||||||
|
{
|
||||||
|
/* Expect 'inf' */
|
||||||
|
if (test >= 0 && strcmp(buffer, "inf") ||
|
||||||
|
test < 0 && strcmp(buffer, "-inf"))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%g[%d] -> '%s' but expected 'inf'\n", test,
|
||||||
|
precision, buffer);
|
||||||
|
failed = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (!png_check_fp_number(buffer, precision+10, &state, &index) ||
|
||||||
|
buffer[index] != 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%g[%d] -> '%s' but has bad format ('%c')\n", test,
|
||||||
|
precision, buffer, buffer[index]);
|
||||||
|
failed = 1;
|
||||||
|
}
|
||||||
|
else if (PNG_FP_IS_NEGATIVE(state) && !(test < 0))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%g[%d] -> '%s' but negative value not so reported\n",
|
||||||
|
test, precision, buffer);
|
||||||
|
failed = 1;
|
||||||
|
assert(!PNG_FP_IS_ZERO(state));
|
||||||
|
assert(!PNG_FP_IS_POSITIVE(state));
|
||||||
|
}
|
||||||
|
else if (PNG_FP_IS_ZERO(state) && !(test == 0))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%g[%d] -> '%s' but zero value not so reported\n",
|
||||||
|
test, precision, buffer);
|
||||||
|
failed = 1;
|
||||||
|
assert(!PNG_FP_IS_NEGATIVE(state));
|
||||||
|
assert(!PNG_FP_IS_POSITIVE(state));
|
||||||
|
}
|
||||||
|
else if (PNG_FP_IS_POSITIVE(state) && !(test > 0))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%g[%d] -> '%s' but positive value not so reported\n",
|
||||||
|
test, precision, buffer);
|
||||||
|
failed = 1;
|
||||||
|
assert(!PNG_FP_IS_NEGATIVE(state));
|
||||||
|
assert(!PNG_FP_IS_ZERO(state));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Check the result against the original. */
|
||||||
|
double out = atof(buffer);
|
||||||
|
double change = fabs((out - test)/test);
|
||||||
|
double allow = .5/pow(10,
|
||||||
|
(precision >= DBL_DIG) ? DBL_DIG-1 : precision-1);
|
||||||
|
|
||||||
|
/* NOTE: if you hit this error case are you compiling with gcc
|
||||||
|
* and -O0? Try -O2 - the errors can accumulate if the FP
|
||||||
|
* code above is not optimized and may drift outside the .5 in
|
||||||
|
* DBL_DIG allowed. In any case a small number of errors may
|
||||||
|
* occur (very small ones - 1 or 2%) because of rounding in the
|
||||||
|
* calculations, either in the conversion API or in atof.
|
||||||
|
*/
|
||||||
|
if (change >= allow && (isfinite(out) ||
|
||||||
|
fabs(test/DBL_MAX) <= 1-allow))
|
||||||
|
{
|
||||||
|
double percent = (precision >= DBL_DIG) ? max_error_abs : max_error;
|
||||||
|
double allowp = (change-allow)*100/allow;
|
||||||
|
|
||||||
|
if (precision >= DBL_DIG)
|
||||||
|
{
|
||||||
|
if (max_abs < allowp) max_abs = allowp;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (max < allowp) max = allowp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showall || allowp >= percent)
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"%.*g[%d] -> '%s' -> %.*g number changed (%g > %g (%d%%))\n",
|
||||||
|
DBL_DIG, test, precision, buffer, DBL_DIG, out, change, allow,
|
||||||
|
(int)round(allowp));
|
||||||
|
failed = 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
++minorarith;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (failed)
|
||||||
|
++failcount;
|
||||||
|
else
|
||||||
|
++ok;
|
||||||
|
|
||||||
|
skip:
|
||||||
|
/* Generate a new number and precision. */
|
||||||
|
precision = rand();
|
||||||
|
if (precision & 1) test = -test;
|
||||||
|
precision >>= 1;
|
||||||
|
|
||||||
|
/* Generate random numbers. */
|
||||||
|
if (test == 0 || !isfinite(test))
|
||||||
|
test = precision+1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Derive the exponent from the previous rand() value. */
|
||||||
|
int exponent = precision % (DBL_MAX_EXP - DBL_MIN_EXP) + DBL_MIN_EXP;
|
||||||
|
int tmp;
|
||||||
|
test = frexp(test * rand(), &tmp);
|
||||||
|
test = ldexp(test, exponent);
|
||||||
|
precision >>= 8; /* arbitrary */
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This limits the precision to 32 digits, enough for standard
|
||||||
|
* IEEE implementations which have at most 15 digits.
|
||||||
|
*/
|
||||||
|
precision = (precision & 0x1f) + 1;
|
||||||
|
}
|
||||||
|
while (--count);
|
||||||
|
|
||||||
|
printf("Tested %d finite values, %d non-finite, %d OK (%d failed) %d minor "
|
||||||
|
"arithmetic errors\n", finite, nonfinite, ok, failcount, minorarith);
|
||||||
|
printf(" Error with >=%d digit precision %.2f%%\n", DBL_DIG, max_abs);
|
||||||
|
printf(" Error with < %d digit precision %.2f%%\n", DBL_DIG, max);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Observe that valid FP numbers have the forms listed in the PNG extensions
|
||||||
|
* specification:
|
||||||
|
*
|
||||||
|
* [+,-]{integer,integer.fraction,.fraction}[{e,E}[+,-]integer]
|
||||||
|
*
|
||||||
|
* Test each of these in turn, including invalid cases.
|
||||||
|
*/
|
||||||
|
typedef enum checkfp_state
|
||||||
|
{
|
||||||
|
start, fraction, exponent, states
|
||||||
|
} checkfp_state;
|
||||||
|
|
||||||
|
/* The characters (other than digits) that characterize the states: */
|
||||||
|
static const char none[] = "";
|
||||||
|
static const char hexdigits[16] = "0123456789ABCDEF";
|
||||||
|
|
||||||
|
static const struct
|
||||||
|
{
|
||||||
|
const char *start; /* Characters valid at the start */
|
||||||
|
const char *end; /* Valid characters that end the state */
|
||||||
|
const char *tests; /* Characters to test after 2 digits seen */
|
||||||
|
}
|
||||||
|
state_characters[states] =
|
||||||
|
{
|
||||||
|
/* start: */ { "+-.", ".eE", "+-.e*0369" },
|
||||||
|
/* fraction: */ { none, "eE", "+-.E#0147" },
|
||||||
|
/* exponent: */ { "+-", none, "+-.eE^0258" }
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char number[1024]; /* Buffer for number being tested */
|
||||||
|
int limit; /* Command line limit */
|
||||||
|
int verbose; /* Shadows global variable */
|
||||||
|
int ctimes; /* Number of numbers tested */
|
||||||
|
int cmillions; /* Count of millions of numbers */
|
||||||
|
int cinvalid; /* Invalid strings checked */
|
||||||
|
int cnoaccept; /* Characters not accepted */
|
||||||
|
}
|
||||||
|
checkfp_command;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int cnumber; /* Index into number string */
|
||||||
|
checkfp_state check_state; /* Current number state */
|
||||||
|
int at_start; /* At start (first character) of state */
|
||||||
|
int cdigits_in_state; /* Digits seen in that state */
|
||||||
|
int limit; /* Limit on same for checking all chars */
|
||||||
|
int state; /* Current parser state */
|
||||||
|
int is_negative; /* Number is negative */
|
||||||
|
int is_zero; /* Number is (still) zero */
|
||||||
|
int number_was_valid; /* Previous character validity */
|
||||||
|
}
|
||||||
|
checkfp_control;
|
||||||
|
|
||||||
|
static int check_all_characters(checkfp_command *co, checkfp_control c);
|
||||||
|
|
||||||
|
static int check_some_characters(checkfp_command *co, checkfp_control c,
|
||||||
|
const char *tests);
|
||||||
|
|
||||||
|
static int check_one_character(checkfp_command *co, checkfp_control c, int ch)
|
||||||
|
{
|
||||||
|
/* Test this character (ch) to ensure the parser does the correct thing.
|
||||||
|
*/
|
||||||
|
size_t index = 0;
|
||||||
|
const char test = (char)ch;
|
||||||
|
int number_is_valid = png_check_fp_number(&test, 1, &c.state, &index);
|
||||||
|
int character_accepted = (index == 1);
|
||||||
|
|
||||||
|
if (c.check_state != exponent && isdigit(ch) && ch != '0')
|
||||||
|
c.is_zero = 0;
|
||||||
|
|
||||||
|
if (c.check_state == start && c.at_start && ch == '-')
|
||||||
|
c.is_negative = 1;
|
||||||
|
|
||||||
|
if (isprint(ch))
|
||||||
|
co->number[c.cnumber++] = (char)ch;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
co->number[c.cnumber++] = '<';
|
||||||
|
co->number[c.cnumber++] = hexdigits[(ch >> 4) & 0xf];
|
||||||
|
co->number[c.cnumber++] = hexdigits[ch & 0xf];
|
||||||
|
co->number[c.cnumber++] = '>';
|
||||||
|
}
|
||||||
|
co->number[c.cnumber] = 0;
|
||||||
|
|
||||||
|
if (co->verbose > 1)
|
||||||
|
fprintf(stderr, "%s\n", co->number);
|
||||||
|
|
||||||
|
if (++(co->ctimes) == 1000000)
|
||||||
|
{
|
||||||
|
if (co->verbose == 1)
|
||||||
|
fputc('.', stderr);
|
||||||
|
co->ctimes = 0;
|
||||||
|
++(co->cmillions);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!number_is_valid)
|
||||||
|
++(co->cinvalid);
|
||||||
|
|
||||||
|
if (!character_accepted)
|
||||||
|
++(co->cnoaccept);
|
||||||
|
|
||||||
|
/* This should never fail (it's a serious bug if it does): */
|
||||||
|
if (index != 0 && index != 1)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: read beyond end of string (%lu)\n", co->number,
|
||||||
|
(unsigned long)index);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Validate the new state, note that the PNG_FP_IS_ macros all return
|
||||||
|
* false unless the number is valid.
|
||||||
|
*/
|
||||||
|
if (PNG_FP_IS_NEGATIVE(c.state) !=
|
||||||
|
(number_is_valid && !c.is_zero && c.is_negative))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: negative when it is not\n", co->number);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PNG_FP_IS_ZERO(c.state) != (number_is_valid && c.is_zero))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: zero when it is not\n", co->number);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PNG_FP_IS_POSITIVE(c.state) !=
|
||||||
|
(number_is_valid && !c.is_zero && !c.is_negative))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: positive when it is not\n", co->number);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Testing a digit */
|
||||||
|
if (isdigit(ch))
|
||||||
|
{
|
||||||
|
if (!character_accepted)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: digit '%c' not accepted\n", co->number, ch);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!number_is_valid)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: saw a digit (%c) but number not valid\n",
|
||||||
|
co->number, ch);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
++c.cdigits_in_state;
|
||||||
|
c.at_start = 0;
|
||||||
|
c.number_was_valid = 1;
|
||||||
|
|
||||||
|
/* Continue testing characters in this state. Either test all of
|
||||||
|
* them or, if we have already seen one digit in this state, just test a
|
||||||
|
* limited set.
|
||||||
|
*/
|
||||||
|
if (c.cdigits_in_state < 1)
|
||||||
|
return check_all_characters(co, c);
|
||||||
|
|
||||||
|
else
|
||||||
|
return check_some_characters(co, c,
|
||||||
|
state_characters[c.check_state].tests);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* A non-digit; is it allowed here? */
|
||||||
|
else if (((ch == '+' || ch == '-') && c.check_state != fraction &&
|
||||||
|
c.at_start) ||
|
||||||
|
(ch == '.' && c.check_state == start) ||
|
||||||
|
((ch == 'e' || ch == 'E') && c.number_was_valid &&
|
||||||
|
c.check_state != exponent))
|
||||||
|
{
|
||||||
|
if (!character_accepted)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: character '%c' not accepted\n", co->number, ch);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The number remains valid after start of fraction but nowhere else. */
|
||||||
|
if (number_is_valid && (c.check_state != start || ch != '.'))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: saw a non-digit (%c) but number valid\n",
|
||||||
|
co->number, ch);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
c.number_was_valid = number_is_valid;
|
||||||
|
|
||||||
|
/* Check for a state change. When changing to 'fraction' if the number
|
||||||
|
* is valid at this point set the at_start to false to allow an exponent
|
||||||
|
* 'e' to come next.
|
||||||
|
*/
|
||||||
|
if (c.check_state == start && ch == '.')
|
||||||
|
{
|
||||||
|
c.check_state = fraction;
|
||||||
|
c.at_start = !number_is_valid;
|
||||||
|
c.cdigits_in_state = 0;
|
||||||
|
c.limit = co->limit;
|
||||||
|
return check_all_characters(co, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (c.check_state < exponent && (ch == 'e' || ch == 'E'))
|
||||||
|
{
|
||||||
|
c.check_state = exponent;
|
||||||
|
c.at_start = 1;
|
||||||
|
c.cdigits_in_state = 0;
|
||||||
|
c.limit = co->limit;
|
||||||
|
return check_all_characters(co, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Else it was a sign, and the state doesn't change. */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ch != '-' && ch != '+')
|
||||||
|
{
|
||||||
|
fprintf(stderr, "checkfp: internal error (1)\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
c.at_start = 0;
|
||||||
|
return check_all_characters(co, c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Testing an invalid character */
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (character_accepted)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: character '%c' [0x%.2x] accepted\n", co->number,
|
||||||
|
ch, ch);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (number_is_valid != c.number_was_valid)
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"%s: character '%c' [0x%.2x] changed number validity\n", co->number,
|
||||||
|
ch, ch);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Do nothing - the parser has stuck; return success and keep going with
|
||||||
|
* the next character.
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Successful return (the caller will try the next character.) */
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int check_all_characters(checkfp_command *co, checkfp_control c)
|
||||||
|
{
|
||||||
|
int ch;
|
||||||
|
|
||||||
|
if (c.cnumber+4 < sizeof co->number) for (ch=0; ch<256; ++ch)
|
||||||
|
{
|
||||||
|
if (!check_one_character(co, c, ch))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int check_some_characters(checkfp_command *co, checkfp_control c,
|
||||||
|
const char *tests)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
--(c.limit);
|
||||||
|
|
||||||
|
if (c.cnumber+4 < sizeof co->number && c.limit >= 0)
|
||||||
|
{
|
||||||
|
if (c.limit > 0) for (i=0; tests[i]; ++i)
|
||||||
|
{
|
||||||
|
if (!check_one_character(co, c, tests[i]))
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* At the end check all the characters. */
|
||||||
|
else
|
||||||
|
return check_all_characters(co, c);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int validation_checkfp(int count, int argc, char **argv)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
checkfp_command command;
|
||||||
|
checkfp_control control;
|
||||||
|
|
||||||
|
command.number[0] = 0;
|
||||||
|
command.limit = 3;
|
||||||
|
command.verbose = verbose;
|
||||||
|
command.ctimes = 0;
|
||||||
|
command.cmillions = 0;
|
||||||
|
command.cinvalid = 0;
|
||||||
|
command.cnoaccept = 0;
|
||||||
|
|
||||||
|
while (--argc > 0)
|
||||||
|
{
|
||||||
|
++argv;
|
||||||
|
if (argc > 1 && strcmp(*argv, "-l") == 0)
|
||||||
|
{
|
||||||
|
--argc;
|
||||||
|
command.limit = atoi(*++argv);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "unknown argument %s\n", *argv);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
control.cnumber = 0;
|
||||||
|
control.check_state = start;
|
||||||
|
control.at_start = 1;
|
||||||
|
control.cdigits_in_state = 0;
|
||||||
|
control.limit = command.limit;
|
||||||
|
control.state = 0;
|
||||||
|
control.is_negative = 0;
|
||||||
|
control.is_zero = 1;
|
||||||
|
control.number_was_valid = 0;
|
||||||
|
|
||||||
|
result = check_all_characters(&command, control);
|
||||||
|
|
||||||
|
printf("checkfp: %s: checked %d,%.3d,%.3d,%.3d strings (%d invalid)\n",
|
||||||
|
result ? "pass" : "FAIL", command.cmillions / 1000,
|
||||||
|
command.cmillions % 1000, command.ctimes / 1000, command.ctimes % 1000,
|
||||||
|
command.cinvalid);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
int validation_muldiv(int count, int argc, char **argv)
|
||||||
|
{
|
||||||
|
int tested = 0;
|
||||||
|
int overflow = 0;
|
||||||
|
int error = 0;
|
||||||
|
int error64 = 0;
|
||||||
|
int passed = 0;
|
||||||
|
int randbits = 0;
|
||||||
|
png_uint_32 randbuffer;
|
||||||
|
png_fixed_point a;
|
||||||
|
png_int_32 times, div;
|
||||||
|
|
||||||
|
while (--argc > 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "unknown argument %s\n", *++argv);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Find out about the random number generator. */
|
||||||
|
randbuffer = RAND_MAX;
|
||||||
|
while (randbuffer != 0) ++randbits, randbuffer >>= 1;
|
||||||
|
printf("Using random number generator that makes %d bits\n", randbits);
|
||||||
|
for (div=0; div<32; div += randbits)
|
||||||
|
randbuffer = (randbuffer << randbits) ^ rand();
|
||||||
|
|
||||||
|
a = 0;
|
||||||
|
times = div = 0;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
png_fixed_point result;
|
||||||
|
/* NOTE: your mileage may vary, a type is required below that can
|
||||||
|
* hold 64 bits or more, if floating point is used a 64-bit or
|
||||||
|
* better mantissa is required.
|
||||||
|
*/
|
||||||
|
long long int fp, fpround;
|
||||||
|
unsigned long hi, lo;
|
||||||
|
int ok;
|
||||||
|
|
||||||
|
/* Check the values, png_64bit_product can only handle positive
|
||||||
|
* numbers, so correct for that here.
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
long u1, u2;
|
||||||
|
int n = 0;
|
||||||
|
if (a < 0) u1 = -a, n = 1; else u1 = a;
|
||||||
|
if (times < 0) u2 = -times, n = !n; else u2 = times;
|
||||||
|
png_64bit_product(u1, u2, &hi, &lo);
|
||||||
|
if (n)
|
||||||
|
{
|
||||||
|
/* -x = ~x+1 */
|
||||||
|
lo = ((~lo) + 1) & 0xffffffff;
|
||||||
|
hi = ~hi;
|
||||||
|
if (lo == 0) ++hi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fp = a;
|
||||||
|
fp *= times;
|
||||||
|
if ((fp & 0xffffffff) != lo || ((fp >> 32) & 0xffffffff) != hi)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "png_64bit_product %d * %d -> %lx|%.8lx not %llx\n",
|
||||||
|
a, times, hi, lo, fp);
|
||||||
|
++error64;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (div != 0)
|
||||||
|
{
|
||||||
|
/* Round - this is C round to zero. */
|
||||||
|
if ((fp < 0) != (div < 0))
|
||||||
|
fp -= div/2;
|
||||||
|
else
|
||||||
|
fp += div/2;
|
||||||
|
|
||||||
|
fp /= div;
|
||||||
|
fpround = fp;
|
||||||
|
/* Assume 2's complement here: */
|
||||||
|
ok = fpround <= PNG_UINT_31_MAX &&
|
||||||
|
fpround >= -1-(long long int)PNG_UINT_31_MAX;
|
||||||
|
if (!ok) ++overflow;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ok = 0, ++overflow, fpround = fp/*misleading*/;
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
fprintf(stderr, "TEST %d * %d / %d -> %lld (%s)\n", a, times, div,
|
||||||
|
fp, ok ? "ok" : "overflow");
|
||||||
|
|
||||||
|
++tested;
|
||||||
|
if (png_muldiv(&result, a, times, div) != ok)
|
||||||
|
{
|
||||||
|
++error;
|
||||||
|
if (ok)
|
||||||
|
fprintf(stderr, "%d * %d / %d -> overflow (expected %lld)\n", a,
|
||||||
|
times, div, fp);
|
||||||
|
else
|
||||||
|
fprintf(stderr, "%d * %d / %d -> %d (expected overflow %lld)\n", a,
|
||||||
|
times, div, result, fp);
|
||||||
|
}
|
||||||
|
else if (ok && result != fpround)
|
||||||
|
{
|
||||||
|
++error;
|
||||||
|
fprintf(stderr, "%d * %d / %d -> %d not %lld\n", a, times, div, result,
|
||||||
|
fp);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
++passed;
|
||||||
|
|
||||||
|
/* Generate three new values, this uses rand() and rand() only returns
|
||||||
|
* up to RAND_MAX.
|
||||||
|
*/
|
||||||
|
/* CRUDE */
|
||||||
|
a += times;
|
||||||
|
times += div;
|
||||||
|
div = randbuffer;
|
||||||
|
randbuffer = (randbuffer << randbits) ^ rand();
|
||||||
|
}
|
||||||
|
while (--count > 0);
|
||||||
|
|
||||||
|
printf("%d tests including %d overflows, %d passed, %d failed (%d 64-bit "
|
||||||
|
"errors)\n", tested, overflow, passed, error, error64);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* When FP is on this just becomes a speed test - compile without FP to get real
|
||||||
|
* validation.
|
||||||
|
*/
|
||||||
|
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||||
|
#define LN2 .000010576586617430806112933839 /* log(2)/65536 */
|
||||||
|
#define L2INV 94548.46219969910586572651 /* 65536/log(2) */
|
||||||
|
|
||||||
|
/* For speed testing, need the internal functions too: */
|
||||||
|
static png_uint_32 png_log8bit(unsigned x)
|
||||||
|
{
|
||||||
|
if (x > 0)
|
||||||
|
return (png_uint_32)floor(.5-log(x/255.)*L2INV);
|
||||||
|
|
||||||
|
return 0xffffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
static png_uint_32 png_log16bit(png_uint_32 x)
|
||||||
|
{
|
||||||
|
if (x > 0)
|
||||||
|
return (png_uint_32)floor(.5-log(x/65535.)*L2INV);
|
||||||
|
|
||||||
|
return 0xffffffff;
|
||||||
|
}
|
||||||
|
|
||||||
|
static png_uint_32 png_exp(png_uint_32 x)
|
||||||
|
{
|
||||||
|
return (png_uint_32)floor(.5 + exp(x * -LN2) * 0xffffffffU);
|
||||||
|
}
|
||||||
|
|
||||||
|
static png_byte png_exp8bit(png_uint_32 log)
|
||||||
|
{
|
||||||
|
return (png_byte)floor(.5 + exp(log * -LN2) * 255);
|
||||||
|
}
|
||||||
|
|
||||||
|
static png_uint_16 png_exp16bit(png_uint_32 log)
|
||||||
|
{
|
||||||
|
return (png_uint_16)floor(.5 + exp(log * -LN2) * 65535);
|
||||||
|
}
|
||||||
|
#endif /* FLOATING_ARITHMETIC */
|
||||||
|
|
||||||
|
int validation_gamma(int argc, char **argv)
|
||||||
|
{
|
||||||
|
double gamma[9] = { 2.2, 1.8, 1.52, 1.45, 1., 1/1.45, 1/1.52, 1/1.8, 1/2.2 };
|
||||||
|
double maxerr;
|
||||||
|
int i, silent=0, onlygamma=0;
|
||||||
|
|
||||||
|
/* Silence the output with -s, just test the gamma functions with -g: */
|
||||||
|
while (--argc > 0)
|
||||||
|
if (strcmp(*++argv, "-s") == 0)
|
||||||
|
silent = 1;
|
||||||
|
else if (strcmp(*argv, "-g") == 0)
|
||||||
|
onlygamma = 1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "unknown argument %s\n", *argv);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!onlygamma)
|
||||||
|
{
|
||||||
|
/* First validate the log functions: */
|
||||||
|
maxerr = 0;
|
||||||
|
for (i=0; i<256; ++i)
|
||||||
|
{
|
||||||
|
double correct = -log(i/255.)/log(2.)*65536;
|
||||||
|
double error = png_log8bit(i) - correct;
|
||||||
|
|
||||||
|
if (i != 0 && fabs(error) > maxerr)
|
||||||
|
maxerr = fabs(error);
|
||||||
|
|
||||||
|
if (i == 0 && png_log8bit(i) != 0xffffffff ||
|
||||||
|
i != 0 && png_log8bit(i) != floor(correct+.5))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "8-bit log error: %d: got %u, expected %f\n",
|
||||||
|
i, png_log8bit(i), correct);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
printf("maximum 8-bit log error = %f\n", maxerr);
|
||||||
|
|
||||||
|
maxerr = 0;
|
||||||
|
for (i=0; i<65536; ++i)
|
||||||
|
{
|
||||||
|
double correct = -log(i/65535.)/log(2.)*65536;
|
||||||
|
double error = png_log16bit(i) - correct;
|
||||||
|
|
||||||
|
if (i != 0 && fabs(error) > maxerr)
|
||||||
|
maxerr = fabs(error);
|
||||||
|
|
||||||
|
if (i == 0 && png_log16bit(i) != 0xffffffff ||
|
||||||
|
i != 0 && png_log16bit(i) != floor(correct+.5))
|
||||||
|
{
|
||||||
|
if (error > .68) /* By experiment error is less than .68 */
|
||||||
|
{
|
||||||
|
fprintf(stderr, "16-bit log error: %d: got %u, expected %f"
|
||||||
|
" error: %f\n", i, png_log16bit(i), correct, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
printf("maximum 16-bit log error = %f\n", maxerr);
|
||||||
|
|
||||||
|
/* Now exponentiations. */
|
||||||
|
maxerr = 0;
|
||||||
|
for (i=0; i<=0xfffff; ++i)
|
||||||
|
{
|
||||||
|
double correct = exp(-i/65536. * log(2.)) * (65536. * 65536);
|
||||||
|
double error = png_exp(i) - correct;
|
||||||
|
|
||||||
|
if (fabs(error) > maxerr)
|
||||||
|
maxerr = fabs(error);
|
||||||
|
if (fabs(error) > 1883) /* By experiment. */
|
||||||
|
{
|
||||||
|
fprintf(stderr, "32-bit exp error: %d: got %u, expected %f"
|
||||||
|
" error: %f\n", i, png_exp(i), correct, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
printf("maximum 32-bit exp error = %f\n", maxerr);
|
||||||
|
|
||||||
|
maxerr = 0;
|
||||||
|
for (i=0; i<=0xfffff; ++i)
|
||||||
|
{
|
||||||
|
double correct = exp(-i/65536. * log(2.)) * 255;
|
||||||
|
double error = png_exp8bit(i) - correct;
|
||||||
|
|
||||||
|
if (fabs(error) > maxerr)
|
||||||
|
maxerr = fabs(error);
|
||||||
|
if (fabs(error) > .50002) /* By experiment */
|
||||||
|
{
|
||||||
|
fprintf(stderr, "8-bit exp error: %d: got %u, expected %f"
|
||||||
|
" error: %f\n", i, png_exp8bit(i), correct, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
printf("maximum 8-bit exp error = %f\n", maxerr);
|
||||||
|
|
||||||
|
maxerr = 0;
|
||||||
|
for (i=0; i<=0xfffff; ++i)
|
||||||
|
{
|
||||||
|
double correct = exp(-i/65536. * log(2.)) * 65535;
|
||||||
|
double error = png_exp16bit(i) - correct;
|
||||||
|
|
||||||
|
if (fabs(error) > maxerr)
|
||||||
|
maxerr = fabs(error);
|
||||||
|
if (fabs(error) > .524) /* By experiment */
|
||||||
|
{
|
||||||
|
fprintf(stderr, "16-bit exp error: %d: got %u, expected %f"
|
||||||
|
" error: %f\n", i, png_exp16bit(i), correct, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
printf("maximum 16-bit exp error = %f\n", maxerr);
|
||||||
|
} /* !onlygamma */
|
||||||
|
|
||||||
|
/* Test the overall gamma correction. */
|
||||||
|
for (i=0; i<9; ++i)
|
||||||
|
{
|
||||||
|
unsigned j;
|
||||||
|
double g = gamma[i];
|
||||||
|
png_fixed_point gfp = floor(g * PNG_FP_1 + .5);
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
printf("Test gamma %f\n", g);
|
||||||
|
|
||||||
|
maxerr = 0;
|
||||||
|
for (j=0; j<256; ++j)
|
||||||
|
{
|
||||||
|
double correct = pow(j/255., g) * 255;
|
||||||
|
png_byte out = png_gamma_8bit_correct(j, gfp);
|
||||||
|
double error = out - correct;
|
||||||
|
|
||||||
|
if (fabs(error) > maxerr)
|
||||||
|
maxerr = fabs(error);
|
||||||
|
if (out != floor(correct+.5))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "8bit %d ^ %f: got %d expected %f error %f\n",
|
||||||
|
j, g, out, correct, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
printf("gamma %f: maximum 8-bit error %f\n", g, maxerr);
|
||||||
|
|
||||||
|
maxerr = 0;
|
||||||
|
for (j=0; j<65536; ++j)
|
||||||
|
{
|
||||||
|
double correct = pow(j/65535., g) * 65535;
|
||||||
|
png_uint_16 out = png_gamma_16bit_correct(j, gfp);
|
||||||
|
double error = out - correct;
|
||||||
|
|
||||||
|
if (fabs(error) > maxerr)
|
||||||
|
maxerr = fabs(error);
|
||||||
|
if (fabs(error) > 1.62)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "16bit %d ^ %f: got %d expected %f error %f\n",
|
||||||
|
j, g, out, correct, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
printf("gamma %f: maximum 16-bit error %f\n", g, maxerr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**************************** VALIDATION TESTS ********************************/
|
||||||
|
/* Various validation routines are included herein, they require some
|
||||||
|
* definition for png_warning and png_error, seetings of VALIDATION:
|
||||||
|
*
|
||||||
|
* 1: validates the ASCII to floating point conversions
|
||||||
|
* 2: validates png_muldiv
|
||||||
|
* 3: accuracy test of fixed point gamma tables
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* The following COUNT (10^8) takes about 1 hour on a 1GHz Pentium IV
|
||||||
|
* processor.
|
||||||
|
*/
|
||||||
|
#define COUNT 1000000000
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int count = COUNT;
|
||||||
|
|
||||||
|
while (argc > 1)
|
||||||
|
{
|
||||||
|
if (argc > 2 && strcmp(argv[1], "-c") == 0)
|
||||||
|
{
|
||||||
|
count = atoi(argv[2]);
|
||||||
|
argc -= 2;
|
||||||
|
argv += 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (strcmp(argv[1], "-v") == 0)
|
||||||
|
{
|
||||||
|
++verbose;
|
||||||
|
--argc;
|
||||||
|
++argv;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count > 0 && argc > 1)
|
||||||
|
{
|
||||||
|
if (strcmp(argv[1], "ascii") == 0)
|
||||||
|
return validation_ascii_to_fp(count, argc-1, argv+1);
|
||||||
|
else if (strcmp(argv[1], "checkfp") == 0)
|
||||||
|
return validation_checkfp(count, argc-1, argv+1);
|
||||||
|
else if (strcmp(argv[1], "muldiv") == 0)
|
||||||
|
return validation_muldiv(count, argc-1, argv+1);
|
||||||
|
else if (strcmp(argv[1], "gamma") == 0)
|
||||||
|
return validation_gamma(argc-1, argv+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Bad argument: */
|
||||||
|
fprintf(stderr,
|
||||||
|
"usage: tarith [-v] [-c count] {ascii,muldiv,gamma} [args]\n");
|
||||||
|
fprintf(stderr, " arguments: ascii [-a (all results)] [-e error%%]\n");
|
||||||
|
fprintf(stderr, " checkfp [-l max-number-chars]\n");
|
||||||
|
fprintf(stderr, " muldiv\n");
|
||||||
|
fprintf(stderr, " gamma -s (silent) -g (only gamma; no log)\n");
|
||||||
|
return 1;
|
||||||
|
}
|
608
libs/libpng-src/contrib/libtests/timepng.c
Normal file
608
libs/libpng-src/contrib/libtests/timepng.c
Normal file
|
@ -0,0 +1,608 @@
|
||||||
|
/* timepng.c
|
||||||
|
*
|
||||||
|
* Copyright (c) 2013,2016 John Cunningham Bowler
|
||||||
|
*
|
||||||
|
* Last changed in libpng 1.6.22 [May 26, 2016]
|
||||||
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*
|
||||||
|
* Load an arbitrary number of PNG files (from the command line, or, if there
|
||||||
|
* are no arguments on the command line, from stdin) then run a time test by
|
||||||
|
* reading each file by row or by image (possibly with transforms in the latter
|
||||||
|
* case). The only output is a time as a floating point number of seconds with
|
||||||
|
* 9 decimal digits.
|
||||||
|
*/
|
||||||
|
#define _POSIX_C_SOURCE 199309L /* for clock_gettime */
|
||||||
|
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <limits.h>
|
||||||
|
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
|
||||||
|
# include <config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Define the following to use this test against your installed libpng, rather
|
||||||
|
* than the one being built here:
|
||||||
|
*/
|
||||||
|
#ifdef PNG_FREESTANDING_TESTS
|
||||||
|
# include <png.h>
|
||||||
|
#else
|
||||||
|
# include "../../png.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* The following is to support direct compilation of this file as C++ */
|
||||||
|
#ifdef __cplusplus
|
||||||
|
# define voidcast(type, value) static_cast<type>(value)
|
||||||
|
#else
|
||||||
|
# define voidcast(type, value) (value)
|
||||||
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
|
/* 'CLOCK_PROCESS_CPUTIME_ID' is one of the clock timers for clock_gettime. It
|
||||||
|
* need not be supported even when clock_gettime is available. It returns the
|
||||||
|
* 'CPU' time the process has consumed. 'CPU' time is assumed to include time
|
||||||
|
* when the CPU is actually blocked by a pending cache fill but not time
|
||||||
|
* waiting for page faults. The attempt is to get a measure of the actual time
|
||||||
|
* the implementation takes to read a PNG ignoring the potentially very large IO
|
||||||
|
* overhead.
|
||||||
|
*/
|
||||||
|
#if defined (CLOCK_PROCESS_CPUTIME_ID) && defined(PNG_STDIO_SUPPORTED) &&\
|
||||||
|
defined(PNG_EASY_ACCESS_SUPPORTED) &&\
|
||||||
|
(PNG_LIBPNG_VER >= 10700 ? defined(PNG_READ_PNG_SUPPORTED) :\
|
||||||
|
defined (PNG_SEQUENTIAL_READ_SUPPORTED) &&\
|
||||||
|
defined(PNG_INFO_IMAGE_SUPPORTED))
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
FILE *input;
|
||||||
|
FILE *output;
|
||||||
|
} io_data;
|
||||||
|
|
||||||
|
static PNG_CALLBACK(void, read_and_copy,
|
||||||
|
(png_structp png_ptr, png_bytep buffer, size_t cb))
|
||||||
|
{
|
||||||
|
io_data *io = (io_data*)png_get_io_ptr(png_ptr);
|
||||||
|
|
||||||
|
if (fread(buffer, cb, 1, io->input) != 1)
|
||||||
|
png_error(png_ptr, strerror(errno));
|
||||||
|
|
||||||
|
if (fwrite(buffer, cb, 1, io->output) != 1)
|
||||||
|
{
|
||||||
|
perror("temporary file");
|
||||||
|
fprintf(stderr, "temporary file PNG write failed\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void read_by_row(png_structp png_ptr, png_infop info_ptr,
|
||||||
|
FILE *write_ptr, FILE *read_ptr)
|
||||||
|
{
|
||||||
|
/* These don't get freed on error, this is fine; the program immediately
|
||||||
|
* exits.
|
||||||
|
*/
|
||||||
|
png_bytep row = NULL, display = NULL;
|
||||||
|
io_data io_copy;
|
||||||
|
|
||||||
|
if (write_ptr != NULL)
|
||||||
|
{
|
||||||
|
/* Set up for a copy to the temporary file: */
|
||||||
|
io_copy.input = read_ptr;
|
||||||
|
io_copy.output = write_ptr;
|
||||||
|
png_set_read_fn(png_ptr, &io_copy, read_and_copy);
|
||||||
|
}
|
||||||
|
|
||||||
|
png_read_info(png_ptr, info_ptr);
|
||||||
|
|
||||||
|
{
|
||||||
|
size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||||
|
|
||||||
|
row = voidcast(png_bytep,malloc(rowbytes));
|
||||||
|
display = voidcast(png_bytep,malloc(rowbytes));
|
||||||
|
|
||||||
|
if (row == NULL || display == NULL)
|
||||||
|
png_error(png_ptr, "OOM allocating row buffers");
|
||||||
|
|
||||||
|
{
|
||||||
|
png_uint_32 height = png_get_image_height(png_ptr, info_ptr);
|
||||||
|
int passes = png_set_interlace_handling(png_ptr);
|
||||||
|
int pass;
|
||||||
|
|
||||||
|
png_start_read_image(png_ptr);
|
||||||
|
|
||||||
|
for (pass = 0; pass < passes; ++pass)
|
||||||
|
{
|
||||||
|
png_uint_32 y = height;
|
||||||
|
|
||||||
|
/* NOTE: this trashes the row each time; interlace handling won't
|
||||||
|
* work, but this avoids memory thrashing for speed testing and is
|
||||||
|
* somewhat representative of an application that works row-by-row.
|
||||||
|
*/
|
||||||
|
while (y-- > 0)
|
||||||
|
png_read_row(png_ptr, row, display);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Make sure to read to the end of the file: */
|
||||||
|
png_read_end(png_ptr, info_ptr);
|
||||||
|
|
||||||
|
/* Free this up: */
|
||||||
|
free(row);
|
||||||
|
free(display);
|
||||||
|
}
|
||||||
|
|
||||||
|
static PNG_CALLBACK(void, no_warnings, (png_structp png_ptr,
|
||||||
|
png_const_charp warning))
|
||||||
|
{
|
||||||
|
(void)png_ptr;
|
||||||
|
(void)warning;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int read_png(FILE *fp, png_int_32 transforms, FILE *write_file)
|
||||||
|
{
|
||||||
|
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,
|
||||||
|
no_warnings);
|
||||||
|
png_infop info_ptr = NULL;
|
||||||
|
|
||||||
|
if (png_ptr == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (setjmp(png_jmpbuf(png_ptr)))
|
||||||
|
{
|
||||||
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
# ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||||
|
png_set_benign_errors(png_ptr, 1/*allowed*/);
|
||||||
|
# endif
|
||||||
|
png_init_io(png_ptr, fp);
|
||||||
|
|
||||||
|
info_ptr = png_create_info_struct(png_ptr);
|
||||||
|
|
||||||
|
if (info_ptr == NULL)
|
||||||
|
png_error(png_ptr, "OOM allocating info structure");
|
||||||
|
|
||||||
|
if (transforms < 0)
|
||||||
|
read_by_row(png_ptr, info_ptr, write_file, fp);
|
||||||
|
|
||||||
|
else
|
||||||
|
png_read_png(png_ptr, info_ptr, transforms, NULL/*params*/);
|
||||||
|
|
||||||
|
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int mytime(struct timespec *t)
|
||||||
|
{
|
||||||
|
/* Do the timing using clock_gettime and the per-process timer. */
|
||||||
|
if (!clock_gettime(CLOCK_PROCESS_CPUTIME_ID, t))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
perror("CLOCK_PROCESS_CPUTIME_ID");
|
||||||
|
fprintf(stderr, "timepng: could not get the time\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int perform_one_test(FILE *fp, int nfiles, png_int_32 transforms)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
struct timespec before, after;
|
||||||
|
|
||||||
|
/* Clear out all errors: */
|
||||||
|
rewind(fp);
|
||||||
|
|
||||||
|
if (mytime(&before))
|
||||||
|
{
|
||||||
|
for (i=0; i<nfiles; ++i)
|
||||||
|
{
|
||||||
|
if (read_png(fp, transforms, NULL/*write*/))
|
||||||
|
{
|
||||||
|
if (ferror(fp))
|
||||||
|
{
|
||||||
|
perror("temporary file");
|
||||||
|
fprintf(stderr, "file %d: error reading PNG data\n", i);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
perror("temporary file");
|
||||||
|
fprintf(stderr, "file %d: error from libpng\n", i);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (mytime(&after))
|
||||||
|
{
|
||||||
|
/* Work out the time difference and print it - this is the only output,
|
||||||
|
* so flush it immediately.
|
||||||
|
*/
|
||||||
|
unsigned long s = after.tv_sec - before.tv_sec;
|
||||||
|
long ns = after.tv_nsec - before.tv_nsec;
|
||||||
|
|
||||||
|
if (ns < 0)
|
||||||
|
{
|
||||||
|
--s;
|
||||||
|
ns += 1000000000;
|
||||||
|
|
||||||
|
if (ns < 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "timepng: bad clock from kernel\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%lu.%.9ld\n", s, ns);
|
||||||
|
fflush(stdout);
|
||||||
|
if (ferror(stdout))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "timepng: error writing output\n");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Successful return */
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int add_one_file(FILE *fp, char *name)
|
||||||
|
{
|
||||||
|
FILE *ip = fopen(name, "rb");
|
||||||
|
|
||||||
|
if (ip != NULL)
|
||||||
|
{
|
||||||
|
/* Read the file using libpng; this detects errors and also deals with
|
||||||
|
* files which contain data beyond the end of the file.
|
||||||
|
*/
|
||||||
|
int ok = 0;
|
||||||
|
fpos_t pos;
|
||||||
|
|
||||||
|
if (fgetpos(fp, &pos))
|
||||||
|
{
|
||||||
|
/* Fatal error reading the start: */
|
||||||
|
perror("temporary file");
|
||||||
|
fprintf(stderr, "temporary file fgetpos error\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (read_png(ip, -1/*by row*/, fp/*output*/))
|
||||||
|
{
|
||||||
|
if (ferror(ip))
|
||||||
|
{
|
||||||
|
perror(name);
|
||||||
|
fprintf(stderr, "%s: read error\n", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
ok = 1; /* read ok */
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
fprintf(stderr, "%s: file not added\n", name);
|
||||||
|
|
||||||
|
(void)fclose(ip);
|
||||||
|
|
||||||
|
/* An error in the output is fatal; exit immediately: */
|
||||||
|
if (ferror(fp))
|
||||||
|
{
|
||||||
|
perror("temporary file");
|
||||||
|
fprintf(stderr, "temporary file write error\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ok)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
/* Did not read the file successfully, simply rewind the temporary
|
||||||
|
* file. This must happen after the ferror check above to avoid clearing
|
||||||
|
* the error.
|
||||||
|
*/
|
||||||
|
if (fsetpos(fp, &pos))
|
||||||
|
{
|
||||||
|
perror("temporary file");
|
||||||
|
fprintf(stderr, "temporary file fsetpos error\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* file open error: */
|
||||||
|
perror(name);
|
||||||
|
fprintf(stderr, "%s: open failed\n", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0; /* file not added */
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
usage(FILE *fp)
|
||||||
|
{
|
||||||
|
if (fp != NULL) fclose(fp);
|
||||||
|
|
||||||
|
fprintf(stderr,
|
||||||
|
"Usage:\n"
|
||||||
|
" timepng --assemble <assembly> {files}\n"
|
||||||
|
" Read the files into <assembly>, output the count. Options are ignored.\n"
|
||||||
|
" timepng --dissemble <assembly> <count> [options]\n"
|
||||||
|
" Time <count> files from <assembly>, additional files may not be given.\n"
|
||||||
|
" Otherwise:\n"
|
||||||
|
" Read the files into a temporary file and time the decode\n"
|
||||||
|
"Transforms:\n"
|
||||||
|
" --by-image: read by image with png_read_png\n"
|
||||||
|
" --<transform>: implies by-image, use PNG_TRANSFORM_<transform>\n"
|
||||||
|
" Otherwise: read by row using png_read_row (to a single row buffer)\n"
|
||||||
|
/* ISO C90 string length max 509 */);fprintf(stderr,
|
||||||
|
"{files}:\n"
|
||||||
|
" PNG files to copy into the assembly and time. Invalid files are skipped\n"
|
||||||
|
" with appropriate error messages. If no files are given the list of files\n"
|
||||||
|
" is read from stdin with each file name terminated by a newline\n"
|
||||||
|
"Output:\n"
|
||||||
|
" For --assemble the output is the name of the assembly file followed by the\n"
|
||||||
|
" count of the files it contains; the arguments for --dissemble. Otherwise\n"
|
||||||
|
" the output is the total decode time in seconds.\n");
|
||||||
|
|
||||||
|
exit(99);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int ok = 0;
|
||||||
|
int err = 0;
|
||||||
|
int nfiles = 0;
|
||||||
|
int transforms = -1; /* by row */
|
||||||
|
const char *assembly = NULL;
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
if (argc > 2 && strcmp(argv[1], "--assemble") == 0)
|
||||||
|
{
|
||||||
|
/* Just build the test file, argv[2] is the file name. */
|
||||||
|
assembly = argv[2];
|
||||||
|
fp = fopen(assembly, "wb");
|
||||||
|
if (fp == NULL)
|
||||||
|
{
|
||||||
|
perror(assembly);
|
||||||
|
fprintf(stderr, "timepng --assemble %s: could not open for write\n",
|
||||||
|
assembly);
|
||||||
|
usage(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
argv += 2;
|
||||||
|
argc -= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (argc > 3 && strcmp(argv[1], "--dissemble") == 0)
|
||||||
|
{
|
||||||
|
fp = fopen(argv[2], "rb");
|
||||||
|
|
||||||
|
if (fp == NULL)
|
||||||
|
{
|
||||||
|
perror(argv[2]);
|
||||||
|
fprintf(stderr, "timepng --dissemble %s: could not open for read\n",
|
||||||
|
argv[2]);
|
||||||
|
usage(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
nfiles = atoi(argv[3]);
|
||||||
|
if (nfiles <= 0)
|
||||||
|
{
|
||||||
|
fprintf(stderr,
|
||||||
|
"timepng --dissemble <file> <count>: %s is not a count\n",
|
||||||
|
argv[3]);
|
||||||
|
exit(99);
|
||||||
|
}
|
||||||
|
#ifdef __COVERITY__
|
||||||
|
else
|
||||||
|
{
|
||||||
|
nfiles &= PNG_UINT_31_MAX;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
argv += 3;
|
||||||
|
argc -= 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
else /* Else use a temporary file */
|
||||||
|
{
|
||||||
|
#ifndef __COVERITY__
|
||||||
|
fp = tmpfile();
|
||||||
|
#else
|
||||||
|
/* Experimental. Coverity says tmpfile() is insecure because it
|
||||||
|
* generates predictable names.
|
||||||
|
*
|
||||||
|
* It is possible to satisfy Coverity by using mkstemp(); however,
|
||||||
|
* any platform supporting mkstemp() undoubtedly has a secure tmpfile()
|
||||||
|
* implementation as well, and doesn't need the fix. Note that
|
||||||
|
* the fix won't work on platforms that don't support mkstemp().
|
||||||
|
*
|
||||||
|
* https://www.securecoding.cert.org/confluence/display/c/
|
||||||
|
* FIO21-C.+Do+not+create+temporary+files+in+shared+directories
|
||||||
|
* says that most historic implementations of tmpfile() provide
|
||||||
|
* only a limited number of possible temporary file names
|
||||||
|
* (usually 26) before file names are recycled. That article also
|
||||||
|
* provides a secure solution that unfortunately depends upon mkstemp().
|
||||||
|
*/
|
||||||
|
char tmpfile[] = "timepng-XXXXXX";
|
||||||
|
int filedes;
|
||||||
|
umask(0177);
|
||||||
|
filedes = mkstemp(tmpfile);
|
||||||
|
if (filedes < 0)
|
||||||
|
fp = NULL;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fp = fdopen(filedes,"w+");
|
||||||
|
/* Hide the filename immediately and ensure that the file does
|
||||||
|
* not exist after the program ends
|
||||||
|
*/
|
||||||
|
(void) unlink(tmpfile);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (fp == NULL)
|
||||||
|
{
|
||||||
|
perror("tmpfile");
|
||||||
|
fprintf(stderr, "timepng: could not open the temporary file\n");
|
||||||
|
exit(1); /* not a user error */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Handle the transforms: */
|
||||||
|
while (argc > 1 && argv[1][0] == '-' && argv[1][1] == '-')
|
||||||
|
{
|
||||||
|
const char *opt = *++argv + 2;
|
||||||
|
|
||||||
|
--argc;
|
||||||
|
|
||||||
|
/* Transforms turn on the by-image processing and maybe set some
|
||||||
|
* transforms:
|
||||||
|
*/
|
||||||
|
if (transforms == -1)
|
||||||
|
transforms = PNG_TRANSFORM_IDENTITY;
|
||||||
|
|
||||||
|
if (strcmp(opt, "by-image") == 0)
|
||||||
|
{
|
||||||
|
/* handled above */
|
||||||
|
}
|
||||||
|
|
||||||
|
# define OPT(name) else if (strcmp(opt, #name) == 0)\
|
||||||
|
transforms |= PNG_TRANSFORM_ ## name
|
||||||
|
|
||||||
|
OPT(STRIP_16);
|
||||||
|
OPT(STRIP_ALPHA);
|
||||||
|
OPT(PACKING);
|
||||||
|
OPT(PACKSWAP);
|
||||||
|
OPT(EXPAND);
|
||||||
|
OPT(INVERT_MONO);
|
||||||
|
OPT(SHIFT);
|
||||||
|
OPT(BGR);
|
||||||
|
OPT(SWAP_ALPHA);
|
||||||
|
OPT(SWAP_ENDIAN);
|
||||||
|
OPT(INVERT_ALPHA);
|
||||||
|
OPT(STRIP_FILLER);
|
||||||
|
OPT(STRIP_FILLER_BEFORE);
|
||||||
|
OPT(STRIP_FILLER_AFTER);
|
||||||
|
OPT(GRAY_TO_RGB);
|
||||||
|
OPT(EXPAND_16);
|
||||||
|
OPT(SCALE_16);
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "timepng %s: unrecognized transform\n", opt);
|
||||||
|
usage(fp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Handle the files: */
|
||||||
|
if (argc > 1 && nfiles > 0)
|
||||||
|
usage(fp); /* Additional files not valid with --dissemble */
|
||||||
|
|
||||||
|
else if (argc > 1)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i=1; i<argc; ++i)
|
||||||
|
{
|
||||||
|
if (nfiles == INT_MAX)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: skipped, too many files\n", argv[i]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (add_one_file(fp, argv[i]))
|
||||||
|
++nfiles;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (nfiles == 0) /* Read from stdin withoout --dissemble */
|
||||||
|
{
|
||||||
|
char filename[FILENAME_MAX+1];
|
||||||
|
|
||||||
|
while (fgets(filename, FILENAME_MAX+1, stdin))
|
||||||
|
{
|
||||||
|
size_t len = strlen(filename);
|
||||||
|
|
||||||
|
if (filename[len-1] == '\n')
|
||||||
|
{
|
||||||
|
filename[len-1] = 0;
|
||||||
|
if (nfiles == INT_MAX)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: skipped, too many files\n", filename);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (add_one_file(fp, filename))
|
||||||
|
++nfiles;
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fprintf(stderr, "timepng: file name too long: ...%s\n",
|
||||||
|
filename+len-32);
|
||||||
|
err = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ferror(stdin))
|
||||||
|
{
|
||||||
|
fprintf(stderr, "timepng: stdin: read error\n");
|
||||||
|
err = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Perform the test, or produce the --assemble output: */
|
||||||
|
if (!err)
|
||||||
|
{
|
||||||
|
if (nfiles > 0)
|
||||||
|
{
|
||||||
|
if (assembly != NULL)
|
||||||
|
{
|
||||||
|
if (fflush(fp) && !ferror(fp) && fclose(fp))
|
||||||
|
{
|
||||||
|
perror(assembly);
|
||||||
|
fprintf(stderr, "%s: close failed\n", assembly);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("%s %d\n", assembly, nfiles);
|
||||||
|
fflush(stdout);
|
||||||
|
ok = !ferror(stdout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ok = perform_one_test(fp, nfiles, transforms);
|
||||||
|
(void)fclose(fp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
usage(fp);
|
||||||
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
(void)fclose(fp);
|
||||||
|
|
||||||
|
/* Exit code 0 on success. */
|
||||||
|
return ok == 0;
|
||||||
|
}
|
||||||
|
#else /* !sufficient support */
|
||||||
|
int main(void) { return 77; }
|
||||||
|
#endif /* !sufficient support */
|
83
libs/libpng-src/contrib/mips-msa/README
Normal file
83
libs/libpng-src/contrib/mips-msa/README
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
OPERATING SYSTEM SPECIFIC MIPS MSA DETECTION
|
||||||
|
--------------------------------------------
|
||||||
|
|
||||||
|
Detection of the ability to execute MIPS MSA on an MIPS processor requires
|
||||||
|
operating system support. (The information is not available in user mode.)
|
||||||
|
|
||||||
|
HOW TO USE THIS
|
||||||
|
---------------
|
||||||
|
|
||||||
|
This directory contains C code fragments that can be included in mips/mips_init.c
|
||||||
|
by setting the macro PNG_MIPS_MSA_FILE to the file name in "" or <> at build
|
||||||
|
time. This setting is not recorded in pnglibconf.h and can be changed simply by
|
||||||
|
rebuilding mips/msa_init.o with the required macro definition.
|
||||||
|
|
||||||
|
For any of this code to be used the MIPS MSA code must be enabled and run time
|
||||||
|
checks must be supported. I.e.:
|
||||||
|
|
||||||
|
#if PNG_MIPS_MSA_OPT > 0
|
||||||
|
#ifdef PNG_MIPS_MSA_CHECK_SUPPORTED
|
||||||
|
|
||||||
|
This is done in a 'configure' build by passing configure the argument:
|
||||||
|
|
||||||
|
--enable-mips-msa=check
|
||||||
|
|
||||||
|
Apart from the basic Linux implementation in contrib/mips-msa/linux.c this code
|
||||||
|
is unsupported. That means that it is not even compiled on a regular basis and
|
||||||
|
may be broken in any given minor release.
|
||||||
|
|
||||||
|
FILE FORMAT
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Each file documents its testing status as of the last time it was tested (which
|
||||||
|
may have been a long time ago):
|
||||||
|
|
||||||
|
STATUS: one of:
|
||||||
|
SUPPORTED: This indicates that the file is included in the regularly
|
||||||
|
performed test builds and bugs are fixed when discovered.
|
||||||
|
COMPILED: This indicates that the code did compile at least once. See the
|
||||||
|
more detailed description for the extent to which the result was
|
||||||
|
successful.
|
||||||
|
TESTED: This means the code was fully compiled into the libpng test programs
|
||||||
|
and these were run at least once.
|
||||||
|
|
||||||
|
BUG REPORTS: an email address to which to send reports of problems
|
||||||
|
|
||||||
|
The file is a fragment of C code. It should not define any 'extern' symbols;
|
||||||
|
everything should be static. It must define the function:
|
||||||
|
|
||||||
|
static int png_have_msa(png_structp png_ptr);
|
||||||
|
|
||||||
|
That function must return 1 if MIPS MSA instructions are supported, 0 if not.
|
||||||
|
It must not execute png_error unless it detects a bug. A png_error will prevent
|
||||||
|
the reading of the PNG and in the future, writing too.
|
||||||
|
|
||||||
|
BUG REPORTS
|
||||||
|
-----------
|
||||||
|
|
||||||
|
If you mail a bug report for any file that is not SUPPORTED there may only be
|
||||||
|
limited response. Consider fixing it and sending a patch to fix the problem -
|
||||||
|
this is more likely to result in action.
|
||||||
|
|
||||||
|
CONTRIBUTIONS
|
||||||
|
-------------
|
||||||
|
|
||||||
|
You may send contributions of new implementations to
|
||||||
|
png-mng-implement@sourceforge.net. Please write code in strict C90 C where
|
||||||
|
possible. Obviously OS dependencies are to be expected. If you submit code you
|
||||||
|
must have the authors permission and it must have a license that is acceptable
|
||||||
|
to the current maintainer; in particular that license must permit modification
|
||||||
|
and redistribution.
|
||||||
|
|
||||||
|
Please try to make the contribution a single file and give the file a clear and
|
||||||
|
unambiguous name that identifies the target OS. If multiple files really are
|
||||||
|
required put them all in a sub-directory.
|
||||||
|
|
||||||
|
You must also be prepared to handle bug reports from users of the code, either
|
||||||
|
by joining the png-mng-implement mailing list or by providing an email for the
|
||||||
|
"BUG REPORTS" entry or both. Please make sure that the header of the file
|
||||||
|
contains the STATUS and BUG REPORTS fields as above.
|
||||||
|
|
||||||
|
Please list the OS requirements as precisely as possible. Ideally you should
|
||||||
|
also list the environment in which the code has been tested and certainly list
|
||||||
|
any environments where you suspect it might not work.
|
64
libs/libpng-src/contrib/mips-msa/linux.c
Normal file
64
libs/libpng-src/contrib/mips-msa/linux.c
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
/* contrib/mips-msa/linux.c
|
||||||
|
*
|
||||||
|
* Copyright (c) 2016 Glenn Randers-Pehrson
|
||||||
|
* Written by Mandar Sahastrabuddhe, 2016.
|
||||||
|
* Last changed in libpng 1.6.25beta03 [August 29, 2016]
|
||||||
|
*
|
||||||
|
* This code is released under the libpng license.
|
||||||
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
* and license in png.h
|
||||||
|
*
|
||||||
|
* SEE contrib/mips-msa/README before reporting bugs
|
||||||
|
*
|
||||||
|
* STATUS: SUPPORTED
|
||||||
|
* BUG REPORTS: png-mng-implement@sourceforge.net
|
||||||
|
*
|
||||||
|
* png_have_msa implemented for Linux by reading the widely available
|
||||||
|
* pseudo-file /proc/cpuinfo.
|
||||||
|
*
|
||||||
|
* This code is strict ANSI-C and is probably moderately portable; it does
|
||||||
|
* however use <stdio.h> and it assumes that /proc/cpuinfo is never localized.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
static int
|
||||||
|
png_have_msa(png_structp png_ptr)
|
||||||
|
{
|
||||||
|
FILE *f = fopen("/proc/cpuinfo", "rb");
|
||||||
|
|
||||||
|
char *string = "msa";
|
||||||
|
char word[10];
|
||||||
|
|
||||||
|
if (f != NULL)
|
||||||
|
{
|
||||||
|
while(!feof(f))
|
||||||
|
{
|
||||||
|
int ch = fgetc(f);
|
||||||
|
static int i = 0;
|
||||||
|
|
||||||
|
while(!(ch <= 32))
|
||||||
|
{
|
||||||
|
word[i++] = ch;
|
||||||
|
ch = fgetc(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
int val = strcmp(string, word);
|
||||||
|
|
||||||
|
if (val == 0)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
memset(word, 0, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(f);
|
||||||
|
}
|
||||||
|
#ifdef PNG_WARNINGS_SUPPORTED
|
||||||
|
else
|
||||||
|
png_warning(png_ptr, "/proc/cpuinfo open failed");
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
25
libs/libpng-src/contrib/oss-fuzz/Dockerfile
Normal file
25
libs/libpng-src/contrib/oss-fuzz/Dockerfile
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
# Copyright 2016 Google Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
FROM gcr.io/oss-fuzz-base/base-builder
|
||||||
|
MAINTAINER glennrp@gmail.com
|
||||||
|
RUN apt-get update && \
|
||||||
|
apt-get install -y make autoconf automake libtool
|
||||||
|
|
||||||
|
RUN git clone --depth 1 https://github.com/madler/zlib.git
|
||||||
|
RUN git clone --depth 1 https://github.com/glennrp/libpng.git
|
||||||
|
RUN cp libpng/contrib/oss-fuzz/build.sh $SRC
|
||||||
|
WORKDIR libpng
|
37
libs/libpng-src/contrib/oss-fuzz/README.txt
Normal file
37
libs/libpng-src/contrib/oss-fuzz/README.txt
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
Last changed in libpng 1.6.33 [September 28, 2017]
|
||||||
|
Copyright (c) 2017 Glenn Randers-Pehrson
|
||||||
|
|
||||||
|
This code is released under the libpng license.
|
||||||
|
For conditions of distribution and use, see the disclaimer
|
||||||
|
and license in png.h
|
||||||
|
|
||||||
|
Files in this directory are used by the oss-fuzz project
|
||||||
|
(https://github.com/google/oss-fuzz/tree/master/projects/libpng).
|
||||||
|
for "fuzzing" libpng.
|
||||||
|
|
||||||
|
They were licensed by Google Inc, using the BSD-like Chromium license,
|
||||||
|
which may be found at https://cs.chromium.org/chromium/src/LICENSE, or, if
|
||||||
|
noted in the source, under the Apache-2.0 license, which may
|
||||||
|
be found at http://www.apache.org/licenses/LICENSE-2.0 .
|
||||||
|
If they have been modified, the derivatives are copyright Glenn Randers-Pehrson
|
||||||
|
and are released under the same licenses as the originals. Several of
|
||||||
|
the original files (libpng_read_fuzzer.options, png.dict, project.yaml)
|
||||||
|
had no licensing information; we assumed that these were under the Chromium
|
||||||
|
license. Any new files are released under the libpng license (see png.h).
|
||||||
|
|
||||||
|
The files are
|
||||||
|
Original
|
||||||
|
Filename or derived Copyright License
|
||||||
|
========================= ========== ================ ==========
|
||||||
|
Dockerfile* derived 2017, Glenn R-P Apache 2.0
|
||||||
|
build.sh derived 2017, Glenn R-P Apache 2.0
|
||||||
|
libpng_read_fuzzer.cc derived 2017, Glenn R-P Chromium
|
||||||
|
libpng_read_fuzzer.options original 2015, Chrome Devs Chromium
|
||||||
|
png.dict original 2015, Chrome Devs Chromium
|
||||||
|
README.txt (this file) original 2017, Glenn R-P libpng
|
||||||
|
|
||||||
|
* Dockerfile is a copy of the file used by oss-fuzz. build.sh,
|
||||||
|
png.dict and libpng_read_fuzzer.* are the actual files used by oss-fuzz,
|
||||||
|
which retrieves them from the libpng repository at Github.
|
||||||
|
|
||||||
|
To do: exercise the progressive reader and the png encoder.
|
51
libs/libpng-src/contrib/oss-fuzz/build.sh
Normal file
51
libs/libpng-src/contrib/oss-fuzz/build.sh
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
#!/bin/bash -eu
|
||||||
|
# Copyright 2017-2018 Glenn Randers-Pehrson
|
||||||
|
# Copyright 2016 Google Inc.
|
||||||
|
#
|
||||||
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
# you may not use this file except in compliance with the License.
|
||||||
|
# You may obtain a copy of the License at
|
||||||
|
#
|
||||||
|
# http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
#
|
||||||
|
# Unless required by applicable law or agreed to in writing, software
|
||||||
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
# See the License for the specific language governing permissions and
|
||||||
|
# limitations under the License.
|
||||||
|
#
|
||||||
|
# Last changed in libpng 1.6.35 [July 15, 2018]
|
||||||
|
#
|
||||||
|
# Revisions by Glenn Randers-Pehrson, 2017:
|
||||||
|
# 1. Build only the library, not the tools (changed "make -j$(nproc) all" to
|
||||||
|
# "make -j$(nproc) libpng16.la").
|
||||||
|
# 2. Disabled WARNING and WRITE options in pnglibconf.dfa.
|
||||||
|
# 3. Build zlib alongside libpng
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
# Disable logging via library build configuration control.
|
||||||
|
cat scripts/pnglibconf.dfa | \
|
||||||
|
sed -e "s/option STDIO/option STDIO disabled/" \
|
||||||
|
-e "s/option WARNING /option WARNING disabled/" \
|
||||||
|
-e "s/option WRITE enables WRITE_INT_FUNCTIONS/option WRITE disabled/" \
|
||||||
|
> scripts/pnglibconf.dfa.temp
|
||||||
|
mv scripts/pnglibconf.dfa.temp scripts/pnglibconf.dfa
|
||||||
|
|
||||||
|
# build the libpng library.
|
||||||
|
autoreconf -f -i
|
||||||
|
./configure --with-libpng-prefix=OSS_FUZZ_
|
||||||
|
make -j$(nproc) clean
|
||||||
|
make -j$(nproc) libpng16.la
|
||||||
|
|
||||||
|
# build libpng_read_fuzzer.
|
||||||
|
$CXX $CXXFLAGS -std=c++11 -I. \
|
||||||
|
$SRC/libpng/contrib/oss-fuzz/libpng_read_fuzzer.cc \
|
||||||
|
-o $OUT/libpng_read_fuzzer \
|
||||||
|
-lFuzzingEngine .libs/libpng16.a -lz
|
||||||
|
|
||||||
|
# add seed corpus.
|
||||||
|
find $SRC/libpng -name "*.png" | grep -v crashers | \
|
||||||
|
xargs zip $OUT/libpng_read_fuzzer_seed_corpus.zip
|
||||||
|
|
||||||
|
cp $SRC/libpng/contrib/oss-fuzz/*.dict \
|
||||||
|
$SRC/libpng/contrib/oss-fuzz/*.options $OUT/
|
190
libs/libpng-src/contrib/oss-fuzz/libpng_read_fuzzer.cc
Normal file
190
libs/libpng-src/contrib/oss-fuzz/libpng_read_fuzzer.cc
Normal file
|
@ -0,0 +1,190 @@
|
||||||
|
|
||||||
|
// libpng_read_fuzzer.cc
|
||||||
|
// Copyright 2017-2018 Glenn Randers-Pehrson
|
||||||
|
// Copyright 2015 The Chromium Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style license that may
|
||||||
|
// be found in the LICENSE file https://cs.chromium.org/chromium/src/LICENSE
|
||||||
|
|
||||||
|
// Last changed in libpng 1.6.35 [July 15, 2018]
|
||||||
|
|
||||||
|
// The modifications in 2017 by Glenn Randers-Pehrson include
|
||||||
|
// 1. addition of a PNG_CLEANUP macro,
|
||||||
|
// 2. setting the option to ignore ADLER32 checksums,
|
||||||
|
// 3. adding "#include <string.h>" which is needed on some platforms
|
||||||
|
// to provide memcpy().
|
||||||
|
// 4. adding read_end_info() and creating an end_info structure.
|
||||||
|
// 5. adding calls to png_set_*() transforms commonly used by browsers.
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#define PNG_INTERNAL
|
||||||
|
#include "png.h"
|
||||||
|
|
||||||
|
#define PNG_CLEANUP \
|
||||||
|
if(png_handler.png_ptr) \
|
||||||
|
{ \
|
||||||
|
if (png_handler.row_ptr) \
|
||||||
|
png_free(png_handler.png_ptr, png_handler.row_ptr); \
|
||||||
|
if (png_handler.end_info_ptr) \
|
||||||
|
png_destroy_read_struct(&png_handler.png_ptr, &png_handler.info_ptr,\
|
||||||
|
&png_handler.end_info_ptr); \
|
||||||
|
else if (png_handler.info_ptr) \
|
||||||
|
png_destroy_read_struct(&png_handler.png_ptr, &png_handler.info_ptr,\
|
||||||
|
nullptr); \
|
||||||
|
else \
|
||||||
|
png_destroy_read_struct(&png_handler.png_ptr, nullptr, nullptr); \
|
||||||
|
png_handler.png_ptr = nullptr; \
|
||||||
|
png_handler.row_ptr = nullptr; \
|
||||||
|
png_handler.info_ptr = nullptr; \
|
||||||
|
png_handler.end_info_ptr = nullptr; \
|
||||||
|
}
|
||||||
|
|
||||||
|
struct BufState {
|
||||||
|
const uint8_t* data;
|
||||||
|
size_t bytes_left;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct PngObjectHandler {
|
||||||
|
png_infop info_ptr = nullptr;
|
||||||
|
png_structp png_ptr = nullptr;
|
||||||
|
png_infop end_info_ptr = nullptr;
|
||||||
|
png_voidp row_ptr = nullptr;
|
||||||
|
BufState* buf_state = nullptr;
|
||||||
|
|
||||||
|
~PngObjectHandler() {
|
||||||
|
if (row_ptr)
|
||||||
|
png_free(png_ptr, row_ptr);
|
||||||
|
if (end_info_ptr)
|
||||||
|
png_destroy_read_struct(&png_ptr, &info_ptr, &end_info_ptr);
|
||||||
|
else if (info_ptr)
|
||||||
|
png_destroy_read_struct(&png_ptr, &info_ptr, nullptr);
|
||||||
|
else
|
||||||
|
png_destroy_read_struct(&png_ptr, nullptr, nullptr);
|
||||||
|
delete buf_state;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void user_read_data(png_structp png_ptr, png_bytep data, size_t length) {
|
||||||
|
BufState* buf_state = static_cast<BufState*>(png_get_io_ptr(png_ptr));
|
||||||
|
if (length > buf_state->bytes_left) {
|
||||||
|
png_error(png_ptr, "read error");
|
||||||
|
}
|
||||||
|
memcpy(data, buf_state->data, length);
|
||||||
|
buf_state->bytes_left -= length;
|
||||||
|
buf_state->data += length;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const int kPngHeaderSize = 8;
|
||||||
|
|
||||||
|
// Entry point for LibFuzzer.
|
||||||
|
// Roughly follows the libpng book example:
|
||||||
|
// http://www.libpng.org/pub/png/book/chapter13.html
|
||||||
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
|
||||||
|
if (size < kPngHeaderSize) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<unsigned char> v(data, data + size);
|
||||||
|
if (png_sig_cmp(v.data(), 0, kPngHeaderSize)) {
|
||||||
|
// not a PNG.
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
PngObjectHandler png_handler;
|
||||||
|
png_handler.png_ptr = nullptr;
|
||||||
|
png_handler.row_ptr = nullptr;
|
||||||
|
png_handler.info_ptr = nullptr;
|
||||||
|
png_handler.end_info_ptr = nullptr;
|
||||||
|
|
||||||
|
png_handler.png_ptr = png_create_read_struct
|
||||||
|
(PNG_LIBPNG_VER_STRING, nullptr, nullptr, nullptr);
|
||||||
|
if (!png_handler.png_ptr) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
png_handler.info_ptr = png_create_info_struct(png_handler.png_ptr);
|
||||||
|
if (!png_handler.info_ptr) {
|
||||||
|
PNG_CLEANUP
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
png_handler.end_info_ptr = png_create_info_struct(png_handler.png_ptr);
|
||||||
|
if (!png_handler.end_info_ptr) {
|
||||||
|
PNG_CLEANUP
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
png_set_crc_action(png_handler.png_ptr, PNG_CRC_QUIET_USE, PNG_CRC_QUIET_USE);
|
||||||
|
#ifdef PNG_IGNORE_ADLER32
|
||||||
|
png_set_option(png_handler.png_ptr, PNG_IGNORE_ADLER32, PNG_OPTION_ON);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Setting up reading from buffer.
|
||||||
|
png_handler.buf_state = new BufState();
|
||||||
|
png_handler.buf_state->data = data + kPngHeaderSize;
|
||||||
|
png_handler.buf_state->bytes_left = size - kPngHeaderSize;
|
||||||
|
png_set_read_fn(png_handler.png_ptr, png_handler.buf_state, user_read_data);
|
||||||
|
png_set_sig_bytes(png_handler.png_ptr, kPngHeaderSize);
|
||||||
|
|
||||||
|
if (setjmp(png_jmpbuf(png_handler.png_ptr))) {
|
||||||
|
PNG_CLEANUP
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reading.
|
||||||
|
png_read_info(png_handler.png_ptr, png_handler.info_ptr);
|
||||||
|
|
||||||
|
// reset error handler to put png_deleter into scope.
|
||||||
|
if (setjmp(png_jmpbuf(png_handler.png_ptr))) {
|
||||||
|
PNG_CLEANUP
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
png_uint_32 width, height;
|
||||||
|
int bit_depth, color_type, interlace_type, compression_type;
|
||||||
|
int filter_type;
|
||||||
|
|
||||||
|
if (!png_get_IHDR(png_handler.png_ptr, png_handler.info_ptr, &width,
|
||||||
|
&height, &bit_depth, &color_type, &interlace_type,
|
||||||
|
&compression_type, &filter_type)) {
|
||||||
|
PNG_CLEANUP
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is going to be too slow.
|
||||||
|
if (width && height > 100000000 / width) {
|
||||||
|
PNG_CLEANUP
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set several transforms that browsers typically use:
|
||||||
|
png_set_gray_to_rgb(png_handler.png_ptr);
|
||||||
|
png_set_expand(png_handler.png_ptr);
|
||||||
|
png_set_packing(png_handler.png_ptr);
|
||||||
|
png_set_scale_16(png_handler.png_ptr);
|
||||||
|
png_set_tRNS_to_alpha(png_handler.png_ptr);
|
||||||
|
|
||||||
|
int passes = png_set_interlace_handling(png_handler.png_ptr);
|
||||||
|
|
||||||
|
png_read_update_info(png_handler.png_ptr, png_handler.info_ptr);
|
||||||
|
|
||||||
|
png_handler.row_ptr = png_malloc(
|
||||||
|
png_handler.png_ptr, png_get_rowbytes(png_handler.png_ptr,
|
||||||
|
png_handler.info_ptr));
|
||||||
|
|
||||||
|
for (int pass = 0; pass < passes; ++pass) {
|
||||||
|
for (png_uint_32 y = 0; y < height; ++y) {
|
||||||
|
png_read_row(png_handler.png_ptr,
|
||||||
|
static_cast<png_bytep>(png_handler.row_ptr), nullptr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
png_read_end(png_handler.png_ptr, png_handler.end_info_ptr);
|
||||||
|
|
||||||
|
PNG_CLEANUP
|
||||||
|
return 0;
|
||||||
|
}
|
|
@ -0,0 +1,2 @@
|
||||||
|
[libfuzzer]
|
||||||
|
dict = png.dict
|
39
libs/libpng-src/contrib/oss-fuzz/png.dict
Normal file
39
libs/libpng-src/contrib/oss-fuzz/png.dict
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
#
|
||||||
|
# AFL dictionary for PNG images
|
||||||
|
# -----------------------------
|
||||||
|
#
|
||||||
|
# Just the basic, standard-originating sections; does not include vendor
|
||||||
|
# extensions.
|
||||||
|
#
|
||||||
|
# Created by Michal Zalewski <lcamtuf@google.com>
|
||||||
|
#
|
||||||
|
|
||||||
|
header_png="\x89PNG\x0d\x0a\x1a\x0a"
|
||||||
|
|
||||||
|
section_IDAT="IDAT"
|
||||||
|
section_IEND="IEND"
|
||||||
|
section_IHDR="IHDR"
|
||||||
|
section_PLTE="PLTE"
|
||||||
|
section_bKGD="bKGD"
|
||||||
|
section_cHRM="cHRM"
|
||||||
|
section_eXIf="eXIf"
|
||||||
|
section_fRAc="fRAc"
|
||||||
|
section_gAMA="gAMA"
|
||||||
|
section_gIFg="gIFg"
|
||||||
|
section_gIFt="gIFt"
|
||||||
|
section_gIFx="gIFx"
|
||||||
|
section_hIST="hIST"
|
||||||
|
section_iCCP="iCCP"
|
||||||
|
section_iTXt="iTXt"
|
||||||
|
section_oFFs="oFFs"
|
||||||
|
section_pCAL="pCAL"
|
||||||
|
section_pHYs="pHYs"
|
||||||
|
section_sBIT="sBIT"
|
||||||
|
section_sCAL="sCAL"
|
||||||
|
section_sPLT="sPLT"
|
||||||
|
section_sRGB="sRGB"
|
||||||
|
section_sTER="sTER"
|
||||||
|
section_tEXt="tEXt"
|
||||||
|
section_tIME="tIME"
|
||||||
|
section_tRNS="tRNS"
|
||||||
|
section_zTXt="zTXt"
|
5
libs/libpng-src/contrib/pngminim/README
Normal file
5
libs/libpng-src/contrib/pngminim/README
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
This demonstrates the use of PNG_USER_CONFIG, pngusr.h and pngusr.dfa
|
||||||
|
to build minimal decoder, encoder, and progressive reader applications.
|
||||||
|
|
||||||
|
See the individual README and pngusr.dfa files for more explanation.
|
|
@ -1,9 +1,10 @@
|
||||||
This demonstrates the use of PNG_USER_CONFIG and pngusr.h
|
This demonstrates the use of PNG_USER_CONFIG, pngusr.h and pngusr.dfa
|
||||||
|
|
||||||
To build a minimal read-only decoder with embedded libpng and zlib, run
|
The makefile builds a minimal read-only decoder with embedded libpng
|
||||||
|
and zlib.
|
||||||
|
|
||||||
gather.sh # to collect needed files from pngminus, libpng, and zlib
|
Specify the location of the zlib source (1.2.1 or later) as ZLIBSRC
|
||||||
make
|
on the make command line.
|
||||||
|
|
||||||
If you prefer to use the shared libraries, go to contrib/pngminus
|
If you prefer to use the shared libraries, go to contrib/pngminus
|
||||||
and build the png2pnm application there.
|
and build the png2pnm application there.
|
||||||
|
|
|
@ -5,28 +5,84 @@
|
||||||
CC=gcc
|
CC=gcc
|
||||||
LD=$(CC)
|
LD=$(CC)
|
||||||
|
|
||||||
RM=rm -f
|
# If awk fails try
|
||||||
|
# make AWK=nawk
|
||||||
|
|
||||||
CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DNO_GZIP \
|
# If cpp fails try
|
||||||
-DdeflateParams\(a,b,c\)=Z_OK -I. -O1
|
# make CPP=/lib/cpp
|
||||||
|
|
||||||
|
RM=rm -f
|
||||||
|
COPY=cp
|
||||||
|
|
||||||
|
CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
|
||||||
|
CFLAGS=-O1 -Wall
|
||||||
|
|
||||||
C=.c
|
C=.c
|
||||||
O=.o
|
O=.o
|
||||||
L=.a
|
L=.a
|
||||||
E=
|
E=
|
||||||
|
|
||||||
ZOBJS = adler32$(O) crc32$(O) \
|
# Where to find the source code:
|
||||||
infback$(O) inffast$(O) inflate$(O) inftrees$(O) \
|
PNGSRC =../../..
|
||||||
trees$(O) uncompr$(O) zutil$(O)
|
ZLIBSRC=$(PNGSRC)/../zlib
|
||||||
|
PROGSRC=$(PNGSRC)/contrib/pngminus
|
||||||
|
|
||||||
OBJS = pngm2pnm$(O) png$(O) pngerror$(O) pngget$(O) pngmem$(O) \
|
# Zlib (minimal inflate requirements - crc32 is used by libpng)
|
||||||
|
# zutil can be eliminated if you provide your own zcalloc and zcfree
|
||||||
|
ZSRCS = adler32$(C) crc32$(C) \
|
||||||
|
inffast$(C) inflate$(C) inftrees$(C) \
|
||||||
|
zutil$(C)
|
||||||
|
|
||||||
|
# Standard headers
|
||||||
|
ZH = zlib.h crc32.h inffast.h inffixed.h \
|
||||||
|
inflate.h inftrees.h zutil.h
|
||||||
|
|
||||||
|
# Machine generated headers
|
||||||
|
ZCONF = zconf.h
|
||||||
|
|
||||||
|
# Headers callers use
|
||||||
|
ZINC = zlib.h $(ZCONF)
|
||||||
|
|
||||||
|
# Headers the Zlib source uses
|
||||||
|
ZHDRS = $(ZH) $(ZCONF)
|
||||||
|
|
||||||
|
ZOBJS = adler32$(O) crc32$(O) \
|
||||||
|
inffast$(O) inflate$(O) inftrees$(O) \
|
||||||
|
zutil$(O)
|
||||||
|
|
||||||
|
# libpng
|
||||||
|
PNGSRCS=png$(C) pngerror$(C) pngget$(C) pngmem$(C) \
|
||||||
|
pngread$(C) pngrio$(C) pngrtran$(C) pngrutil$(C) \
|
||||||
|
pngset$(C) pngtrans$(C)
|
||||||
|
|
||||||
|
# Standard headers
|
||||||
|
PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h
|
||||||
|
|
||||||
|
# Machine generated headers
|
||||||
|
PNGCONF=pnglibconf.h
|
||||||
|
|
||||||
|
# Headers callers use
|
||||||
|
PNGINC= png.h pngconf.h pngusr.h $(PNGCONF)
|
||||||
|
|
||||||
|
# Headers the PNG library uses
|
||||||
|
PNGHDRS=$(PNGH) $(PNGCONF) pngusr.h
|
||||||
|
|
||||||
|
PNGOBJS=png$(O) pngerror$(O) pngget$(O) pngmem$(O) \
|
||||||
pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) \
|
pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) \
|
||||||
pngset$(O) pngtrans$(O) $(ZOBJS)
|
pngset$(O) pngtrans$(O)
|
||||||
|
|
||||||
|
PROGSRCS= pngm2pnm$(C)
|
||||||
|
PROGHDRS=
|
||||||
|
PROGDOCS=
|
||||||
|
PROGOBJS= pngm2pnm$(O)
|
||||||
|
|
||||||
|
OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
|
||||||
|
|
||||||
# implicit make rules -------------------------------------------------------
|
# implicit make rules -------------------------------------------------------
|
||||||
|
|
||||||
.c$(O): png.h pngconf.h pngusr.h zlib.h
|
# note: dependencies do not work on implicit rule lines
|
||||||
$(CC) -c $(CFLAGS) $<
|
.c$(O):
|
||||||
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
|
|
||||||
|
@ -34,11 +90,62 @@ all: pngm2pnm$(E)
|
||||||
|
|
||||||
pngm2pnm$(E): $(OBJS)
|
pngm2pnm$(E): $(OBJS)
|
||||||
$(LD) -o pngm2pnm$(E) $(OBJS)
|
$(LD) -o pngm2pnm$(E) $(OBJS)
|
||||||
strip pngm2pnm$(E)
|
|
||||||
|
# The DFA_XTRA setting turns all libpng options off then
|
||||||
|
# turns on those required for this minimal build.
|
||||||
|
# The CPP_FLAGS setting causes pngusr.h to be included in
|
||||||
|
# both the build of pnglibconf.h and, subsequently, when
|
||||||
|
# building libpng itself.
|
||||||
|
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
|
||||||
|
$(PNGSRC)/scripts/pnglibconf.dfa \
|
||||||
|
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
|
||||||
|
$(RM) pnglibconf.h pnglibconf.dfn
|
||||||
|
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
|
||||||
|
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
|
||||||
|
DFA_XTRA="pngusr.dfa" $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
|
||||||
|
srcdir=$(PNGSRC) clean
|
||||||
$(RM) pngm2pnm$(O)
|
$(RM) pngm2pnm$(O)
|
||||||
$(RM) pngm2pnm$(E)
|
$(RM) pngm2pnm$(E)
|
||||||
$(RM) $(OBJS)
|
$(RM) $(OBJS)
|
||||||
|
|
||||||
|
# distclean also removes the copied source and headers
|
||||||
|
distclean: clean
|
||||||
|
$(RM) -r scripts # historical reasons
|
||||||
|
$(RM) $(PNGSRCS) $(PNGH)
|
||||||
|
$(RM) $(ZSRCS) $(ZH) $(ZCONF)
|
||||||
|
$(RM) $(PROGSRCS) $(PROGHDRS) $(PROGDOCS)
|
||||||
|
|
||||||
|
# Header file dependencies:
|
||||||
|
$(PROGOBJS): $(PROGHDRS) $(PNGINC) $(ZINC)
|
||||||
|
$(PNGOBJS): $(PNGHDRS) $(ZINC)
|
||||||
|
$(ZOBJS): $(ZHDRS)
|
||||||
|
|
||||||
|
# Gather the source code from the respective directories
|
||||||
|
$(PNGSRCS) $(PNGH): $(PNGSRC)/$@
|
||||||
|
$(RM) $@
|
||||||
|
$(COPY) $(PNGSRC)/$@ $@
|
||||||
|
|
||||||
|
# No dependency on the ZLIBSRC target so that it only needs
|
||||||
|
# to be specified once.
|
||||||
|
$(ZSRCS) $(ZH):
|
||||||
|
$(RM) $@
|
||||||
|
$(COPY) $(ZLIBSRC)/$@ $@
|
||||||
|
|
||||||
|
# The unconfigured zconf.h varies in name according to the
|
||||||
|
# zlib release
|
||||||
|
$(ZCONF):
|
||||||
|
$(RM) $@
|
||||||
|
@for f in zconf.h.in zconf.in.h zconf.h; do\
|
||||||
|
test -r $(ZLIBSRC)/$$f &&\
|
||||||
|
echo $(COPY) $(ZLIBSRC)/$$f $@ &&\
|
||||||
|
$(COPY) $(ZLIBSRC)/$$f $@ && exit 0;\
|
||||||
|
done; echo copy: $(ZLIBSRC)/zconf.h not found; exit 1
|
||||||
|
|
||||||
|
pngm2pnm.c: $(PROGSRC)/png2pnm.c
|
||||||
|
$(RM) $@
|
||||||
|
$(COPY) $(PROGSRC)/png2pnm.c $@
|
||||||
|
|
||||||
# End of makefile for pngm2pnm
|
# End of makefile for pngm2pnm
|
||||||
|
|
40
libs/libpng-src/contrib/pngminim/decoder/pngusr.dfa
Normal file
40
libs/libpng-src/contrib/pngminim/decoder/pngusr.dfa
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
# pngminim/decoder/pngusr.dfa
|
||||||
|
#
|
||||||
|
# Copyright (c) 2010-2013 Glenn Randers-Pehrson
|
||||||
|
#
|
||||||
|
# This code is released under the libpng license.
|
||||||
|
# For conditions of distribution and use, see the disclaimer
|
||||||
|
# and license in png.h
|
||||||
|
|
||||||
|
# First all the build options off:
|
||||||
|
|
||||||
|
everything = off
|
||||||
|
|
||||||
|
# All that is required is some read code. This example switches
|
||||||
|
# on the sequential read code (see ../preader for a progressive
|
||||||
|
# read example).
|
||||||
|
|
||||||
|
option SEQUENTIAL_READ on
|
||||||
|
|
||||||
|
# You must choose fixed or floating point arithmetic:
|
||||||
|
# option FLOATING_POINT on
|
||||||
|
|
||||||
|
option FIXED_POINT on
|
||||||
|
|
||||||
|
# You must chose the internal fixed point implementation or to
|
||||||
|
# use the system floating point. The latter is considerably
|
||||||
|
# smaller (by about 1kbyte on an x86 system):
|
||||||
|
# option FLOATING_ARITHMETIC on
|
||||||
|
|
||||||
|
option FLOATING_ARITHMETIC off
|
||||||
|
|
||||||
|
# Your program will probably need other options. The example
|
||||||
|
# program here, pngm2pnm, requires the following. Take a look
|
||||||
|
# at pnglibconf.h to find out the full set of what has to be
|
||||||
|
# enabled to make the following work.
|
||||||
|
|
||||||
|
option SETJMP on
|
||||||
|
option STDIO on
|
||||||
|
option READ_EXPAND on
|
||||||
|
option READ_STRIP_16_TO_8 on
|
||||||
|
option USER_LIMITS on
|
|
@ -1,6 +1,6 @@
|
||||||
/* minrdpngconf.h: headers to make a minimal png-read-only library
|
/* minrdpngconf.h: headers to make a minimal png-read-only library
|
||||||
*
|
*
|
||||||
* Copyright (c) 2007, 2009 Glenn Randers-Pehrson
|
* Copyright (c) 2007, 2010-2013 Glenn Randers-Pehrson
|
||||||
*
|
*
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
* For conditions of distribution and use, see the disclaimer
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
@ -12,67 +12,12 @@
|
||||||
#ifndef MINRDPNGCONF_H
|
#ifndef MINRDPNGCONF_H
|
||||||
#define MINRDPNGCONF_H
|
#define MINRDPNGCONF_H
|
||||||
|
|
||||||
#ifdef NJET
|
/* To include pngusr.h set -DPNG_USER_CONFIG in CPPFLAGS */
|
||||||
/* No 16-bit support beyond reading with strip_16 */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define PNG_NO_GLOBAL_ARRAYS
|
/* List options to turn off features of the build that do not
|
||||||
|
* affect the API (so are not recorded in pnglibconf.h)
|
||||||
|
*/
|
||||||
|
|
||||||
#define PNG_NO_WARNINGS
|
#define PNG_ALIGN_TYPE PNG_ALIGN_NONE
|
||||||
#define png_warning(s1,s2) ""
|
|
||||||
#define png_chunk_warning(s1,s2) ""
|
|
||||||
#define PNG_NO_ERROR_TEXT
|
|
||||||
#define png_error(s1,s2) png_err(s1)
|
|
||||||
#define png_chunk_error(s1,s2) png_err(s1)
|
|
||||||
|
|
||||||
#define PNG_NO_ASSEMBLER_CODE
|
|
||||||
#define PNG_NO_OPTIMIZED_CODE
|
|
||||||
#define PNG_NO_READ_GAMMA
|
|
||||||
#define PNG_NO_READ_BACKGROUND
|
|
||||||
#define PNG_NO_READ_DITHER
|
|
||||||
#define PNG_NO_READ_INVERT
|
|
||||||
#define PNG_NO_READ_SHIFT
|
|
||||||
#define PNG_NO_READ_PACK
|
|
||||||
#define PNG_NO_READ_PACKSWAP
|
|
||||||
#define PNG_NO_READ_FILLER
|
|
||||||
#define PNG_NO_READ_SWAP
|
|
||||||
#define PNG_NO_READ_SWAP_ALPHA
|
|
||||||
#define PNG_NO_READ_INVERT_ALPHA
|
|
||||||
#define PNG_NO_READ_RGB_TO_GRAY
|
|
||||||
#define PNG_NO_READ_USER_TRANSFORM
|
|
||||||
#define PNG_NO_READ_bKGD
|
|
||||||
#define PNG_NO_READ_cHRM
|
|
||||||
#define PNG_NO_READ_gAMA
|
|
||||||
#define PNG_NO_READ_hIST
|
|
||||||
#define PNG_NO_READ_iCCP
|
|
||||||
#define PNG_NO_READ_pCAL
|
|
||||||
#define PNG_NO_READ_pHYs
|
|
||||||
#define PNG_NO_READ_sBIT
|
|
||||||
#define PNG_NO_READ_sCAL
|
|
||||||
#define PNG_NO_READ_sPLT
|
|
||||||
#define PNG_NO_READ_sRGB
|
|
||||||
#define PNG_NO_READ_TEXT
|
|
||||||
#define PNG_NO_READ_tIME
|
|
||||||
#define PNG_NO_READ_UNKNOWN_CHUNKS
|
|
||||||
#define PNG_NO_READ_USER_CHUNKS
|
|
||||||
#define PNG_NO_READ_EMPTY_PLTE
|
|
||||||
#define PNG_NO_READ_OPT_PLTE
|
|
||||||
#define PNG_NO_READ_STRIP_ALPHA
|
|
||||||
#define PNG_NO_READ_oFFs
|
|
||||||
#define PNG_NO_WARN_UNINITIALIZED_ROW
|
|
||||||
|
|
||||||
#define PNG_NO_WRITE_SUPPORTED
|
|
||||||
|
|
||||||
#define PNG_NO_INFO_IMAGE
|
|
||||||
#define PNG_NO_USER_MEM
|
|
||||||
#define PNG_NO_FIXED_POINT_SUPPORTED
|
|
||||||
#define PNG_NO_MNG_FEATURES
|
|
||||||
#define PNG_NO_USER_TRANSFORM_PTR
|
|
||||||
#define PNG_NO_HANDLE_AS_UNKNOWN
|
|
||||||
#define PNG_NO_CONSOLE_IO
|
|
||||||
#define PNG_NO_ZALLOC_ZERO
|
|
||||||
#define PNG_NO_ERROR_NUMBERS
|
|
||||||
#define PNG_NO_EASY_ACCESS
|
|
||||||
#define PNG_NO_PROGRESSIVE_READ
|
|
||||||
|
|
||||||
#endif /* MINRDPNGCONF_H */
|
#endif /* MINRDPNGCONF_H */
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
This demonstrates the use of PNG_USER_CONFIG and pngusr.h
|
This demonstrates the use of PNG_USER_CONFIG and pngusr.h
|
||||||
|
|
||||||
To build a minimal write-only decoder with embedded libpng and zlib, run
|
The makefile builds a minimal write-only encoder with embedded libpng
|
||||||
|
and zlib.
|
||||||
|
|
||||||
gather.sh # to collect needed files from pngminus, libpng, and zlib
|
Specify the location of the zlib source (1.2.1 or later) as ZLIBSRC
|
||||||
make
|
on the make command line.
|
||||||
|
|
||||||
If you prefer to use the shared libraries, go to contrib/pngminus
|
If you prefer to use the shared libraries, go to contrib/pngminus
|
||||||
and build the pnm2png application there.
|
and build the pnm2png application there.
|
||||||
|
|
|
@ -5,27 +5,83 @@
|
||||||
CC=gcc
|
CC=gcc
|
||||||
LD=$(CC)
|
LD=$(CC)
|
||||||
|
|
||||||
RM=rm -f
|
# If awk fails try
|
||||||
|
# make AWK=nawk
|
||||||
|
|
||||||
CFLAGS=-DPNG_USER_CONFIG -DNO_GZIP -I. -O1
|
# If cpp fails try
|
||||||
|
# make CPP=/lib/cpp
|
||||||
|
|
||||||
|
RM=rm -f
|
||||||
|
COPY=cp
|
||||||
|
|
||||||
|
CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
|
||||||
|
CFLAGS=-O1 -Wall
|
||||||
|
|
||||||
C=.c
|
C=.c
|
||||||
O=.o
|
O=.o
|
||||||
L=.a
|
L=.a
|
||||||
E=
|
E=
|
||||||
|
|
||||||
ZOBJS = adler32$(O) compress$(O) crc32$(O) deflate$(O) \
|
# Where to find the source code:
|
||||||
dummy_inflate$(O) \
|
PNGSRC =../../..
|
||||||
trees$(O) uncompr$(O) zutil$(O)
|
ZLIBSRC=$(PNGSRC)/../zlib
|
||||||
|
PROGSRC=$(PNGSRC)/contrib/pngminus
|
||||||
|
|
||||||
OBJS = pnm2pngm$(O) png$(O) pngerror$(O) pngget$(O) pngmem$(O) \
|
# Zlib
|
||||||
|
ZSRCS = adler32$(C) compress$(C) crc32$(C) deflate$(C) \
|
||||||
|
trees$(C) zutil$(C)
|
||||||
|
|
||||||
|
# Standard headers
|
||||||
|
#ZH = zlib.h crc32.h deflate.h trees.h zutil.h
|
||||||
|
ZH = zlib.h crc32.h deflate.h trees.h zutil.h
|
||||||
|
|
||||||
|
# Machine generated headers
|
||||||
|
ZCONF = zconf.h
|
||||||
|
|
||||||
|
# Headers callers use
|
||||||
|
ZINC = zlib.h $(ZCONF)
|
||||||
|
|
||||||
|
# Headers the Zlib source uses
|
||||||
|
ZHDRS = $(ZH) $(ZCONF)
|
||||||
|
|
||||||
|
# compress is not required; it is needed to link the zlib
|
||||||
|
# code because deflate defines an unused API function deflateBound
|
||||||
|
# which itself calls compressBound from compress.
|
||||||
|
ZOBJS = adler32$(O) compress$(O) crc32$(O) deflate$(O) \
|
||||||
|
trees$(O) zutil$(O)
|
||||||
|
|
||||||
|
# libpng
|
||||||
|
PNGSRCS=png$(C) pngerror$(C) pngget$(C) pngmem$(C) \
|
||||||
|
pngset$(C) pngtrans$(C) pngwio$(C) pngwrite$(C) \
|
||||||
|
pngwtran$(C) pngwutil$(C)
|
||||||
|
|
||||||
|
# Standard headers
|
||||||
|
PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h
|
||||||
|
|
||||||
|
# Machine generated headers
|
||||||
|
PNGCONF=pnglibconf.h
|
||||||
|
|
||||||
|
# Headers callers use
|
||||||
|
PNGINC= png.h pngconf.h pngusr.h $(PNGCONF)
|
||||||
|
|
||||||
|
# Headers the PNG library uses
|
||||||
|
PNGHDRS=$(PNGH) $(PNGCONF) pngusr.h
|
||||||
|
|
||||||
|
PNGOBJS=png$(O) pngerror$(O) pngget$(O) pngmem$(O) \
|
||||||
pngset$(O) pngtrans$(O) pngwio$(O) pngwrite$(O) \
|
pngset$(O) pngtrans$(O) pngwio$(O) pngwrite$(O) \
|
||||||
pngwtran$(O) pngwutil$(O) $(ZOBJS)
|
pngwtran$(O) pngwutil$(O)
|
||||||
|
|
||||||
|
PROGSRCS= pnm2pngm$(C)
|
||||||
|
PROGHDRS=
|
||||||
|
PROGDOCS=
|
||||||
|
PROGOBJS= pnm2pngm$(O)
|
||||||
|
|
||||||
|
OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
|
||||||
|
|
||||||
# implicit make rules -------------------------------------------------------
|
# implicit make rules -------------------------------------------------------
|
||||||
|
|
||||||
.c$(O): png.h pngconf.h pngusr.h zlib.h
|
.c$(O):
|
||||||
$(CC) -c $(CFLAGS) $<
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
|
|
||||||
|
@ -33,11 +89,62 @@ all: pnm2pngm$(E)
|
||||||
|
|
||||||
pnm2pngm$(E): $(OBJS)
|
pnm2pngm$(E): $(OBJS)
|
||||||
$(LD) -o pnm2pngm$(E) $(OBJS)
|
$(LD) -o pnm2pngm$(E) $(OBJS)
|
||||||
strip pnm2pngm$(E)
|
|
||||||
|
# The DFA_XTRA setting turns all libpng options off then
|
||||||
|
# turns on those required for this minimal build.
|
||||||
|
# The CPP_FLAGS setting causes pngusr.h to be included in
|
||||||
|
# both the build of pnglibconf.h and, subsequently, when
|
||||||
|
# building libpng itself.
|
||||||
|
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
|
||||||
|
$(PNGSRC)/scripts/pnglibconf.dfa \
|
||||||
|
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
|
||||||
|
$(RM) pnglibconf.h pnglibconf.dfn
|
||||||
|
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
|
||||||
|
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
|
||||||
|
DFA_XTRA="pngusr.dfa" $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
|
||||||
|
srcdir=$(PNGSRC) clean
|
||||||
$(RM) pnm2pngm$(O)
|
$(RM) pnm2pngm$(O)
|
||||||
$(RM) pnm2pngm$(E)
|
$(RM) pnm2pngm$(E)
|
||||||
$(RM) $(OBJS)
|
$(RM) $(OBJS)
|
||||||
|
|
||||||
|
# distclean also removes the copied source and headers
|
||||||
|
distclean: clean
|
||||||
|
$(RM) -r scripts # historical reasons
|
||||||
|
$(RM) $(PNGSRCS) $(PNGH)
|
||||||
|
$(RM) $(ZSRCS) $(ZH) $(ZCONF)
|
||||||
|
$(RM) $(PROGSRCS) $(PROGHDRS) $(PROGDOCS)
|
||||||
|
|
||||||
|
# Header file dependencies:
|
||||||
|
$(PROGOBJS): $(PROGHDRS) $(PNGINC) $(ZINC)
|
||||||
|
$(PNGOBJS): $(PNGHDRS) $(ZINC)
|
||||||
|
$(ZOBJS): $(ZHDRS)
|
||||||
|
|
||||||
|
# Gather the source code from the respective directories
|
||||||
|
$(PNGSRCS) $(PNGH): $(PNGSRC)/$@
|
||||||
|
$(RM) $@
|
||||||
|
$(COPY) $(PNGSRC)/$@ $@
|
||||||
|
|
||||||
|
# No dependency on the ZLIBSRC target so that it only needs
|
||||||
|
# to be specified once.
|
||||||
|
$(ZSRCS) $(ZH):
|
||||||
|
$(RM) $@
|
||||||
|
$(COPY) $(ZLIBSRC)/$@ $@
|
||||||
|
|
||||||
|
# The unconfigured zconf.h varies in name according to the
|
||||||
|
# zlib release
|
||||||
|
$(ZCONF):
|
||||||
|
$(RM) $@
|
||||||
|
@for f in zconf.h.in zconf.in.h zconf.h; do\
|
||||||
|
test -r $(ZLIBSRC)/$$f &&\
|
||||||
|
echo $(COPY) $(ZLIBSRC)/$$f $@ &&\
|
||||||
|
$(COPY) $(ZLIBSRC)/$$f $@ && exit 0;\
|
||||||
|
done; echo copy: $(ZLIBSRC)/zconf.h not found; exit 1
|
||||||
|
|
||||||
|
pnm2pngm.c: $(PROGSRC)/pnm2png.c
|
||||||
|
$(RM) $@
|
||||||
|
$(COPY) $(PROGSRC)/pnm2png.c $@
|
||||||
|
|
||||||
# End of makefile for pnm2pngm
|
# End of makefile for pnm2pngm
|
||||||
|
|
39
libs/libpng-src/contrib/pngminim/encoder/pngusr.dfa
Normal file
39
libs/libpng-src/contrib/pngminim/encoder/pngusr.dfa
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
# pngminim/encoder/pngusr.dfa
|
||||||
|
#
|
||||||
|
# Copyright (c) 2010-2013 Glenn Randers-Pehrson
|
||||||
|
#
|
||||||
|
# This code is released under the libpng license.
|
||||||
|
# For conditions of distribution and use, see the disclaimer
|
||||||
|
# and license in png.h
|
||||||
|
|
||||||
|
# First all the build options off:
|
||||||
|
|
||||||
|
everything = off
|
||||||
|
|
||||||
|
# Switch on the write code - this makes a minimalist encoder
|
||||||
|
|
||||||
|
option WRITE on
|
||||||
|
|
||||||
|
# These 2 options are required if you need to read PBM (P1 or P4) files.
|
||||||
|
option WRITE_INVERT on
|
||||||
|
option WRITE_PACK on
|
||||||
|
|
||||||
|
# You must choose fixed or floating point arithmetic:
|
||||||
|
# option FLOATING_POINT on
|
||||||
|
|
||||||
|
option FIXED_POINT on
|
||||||
|
|
||||||
|
# You must chose the internal fixed point implementation or to
|
||||||
|
# use the system floating point. The latter is considerably
|
||||||
|
# smaller (by about 1kbyte on an x86 system):
|
||||||
|
# option FLOATING_ARITHMETIC on
|
||||||
|
|
||||||
|
option FLOATING_ARITHMETIC off
|
||||||
|
|
||||||
|
# Your program will probably need other options. The example
|
||||||
|
# program here, pnm2pngm, requires the following. Take a look
|
||||||
|
# at pnglibconf.h to find out the full set of what has to be
|
||||||
|
# enabled to make the following work.
|
||||||
|
|
||||||
|
option SETJMP on
|
||||||
|
option STDIO on
|
|
@ -1,6 +1,6 @@
|
||||||
/* minwrpngconf.h: headers to make a minimal png-write-only library
|
/* minwrpngconf.h: headers to make a minimal png-write-only library
|
||||||
*
|
*
|
||||||
* Copyright (c) 2007, 2009 Glenn Randers-Pehrson
|
* Copyright (c) 2007, 2010-2013 Glenn Randers-Pehrson
|
||||||
*
|
*
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
* For conditions of distribution and use, see the disclaimer
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
@ -12,62 +12,12 @@
|
||||||
#ifndef MINWRPNGCONF_H
|
#ifndef MINWRPNGCONF_H
|
||||||
#define MINWRPNGCONF_H
|
#define MINWRPNGCONF_H
|
||||||
|
|
||||||
#define PNG_NO_GLOBAL_ARRAYS
|
/* To include pngusr.h set -DPNG_USER_CONFIG in CPPFLAGS */
|
||||||
|
|
||||||
#define PNG_NO_READ_SUPPORTED
|
/* List options to turn off features of the build that do not
|
||||||
|
* affect the API (so are not recorded in pnglibconf.h)
|
||||||
|
*/
|
||||||
|
|
||||||
#define PNG_NO_WARNINGS
|
#define PNG_ALIGN_TYPE PNG_ALIGN_NONE
|
||||||
#define png_warning(s1,s2) ""
|
|
||||||
#define png_chunk_warning(s1,s2) ""
|
|
||||||
#define PNG_NO_ERROR_TEXT
|
|
||||||
#define png_error(s1,s2) png_err(s1)
|
|
||||||
#define png_chunk_error(s1,s2) png_err(s1)
|
|
||||||
|
|
||||||
#define PNG_NO_WRITE_BACKGROUND
|
|
||||||
#define PNG_NO_WRITE_GAMMA
|
|
||||||
#define PNG_NO_WRITE_DITHER
|
|
||||||
#define PNG_NO_WRITE_INVERT
|
|
||||||
#define PNG_NO_WRITE_SHIFT
|
|
||||||
#define PNG_NO_WRITE_PACK
|
|
||||||
#define PNG_NO_WRITE_PACKSWAP
|
|
||||||
#define PNG_NO_WRITE_FILLER
|
|
||||||
#define PNG_NO_WRITE_SWAP
|
|
||||||
#define PNG_NO_WRITE_SWAP_ALPHA
|
|
||||||
#define PNG_NO_WRITE_INVERT_ALPHA
|
|
||||||
#define PNG_NO_WRITE_RGB_TO_GRAY
|
|
||||||
#define PNG_NO_WRITE_USER_TRANSFORM
|
|
||||||
#define PNG_NO_WRITE_bKGD
|
|
||||||
#define PNG_NO_WRITE_cHRM
|
|
||||||
#define PNG_NO_WRITE_gAMA
|
|
||||||
#define PNG_NO_WRITE_hIST
|
|
||||||
#define PNG_NO_WRITE_iCCP
|
|
||||||
#define PNG_NO_WRITE_oFFs
|
|
||||||
#define PNG_NO_WRITE_pCAL
|
|
||||||
#define PNG_NO_WRITE_pHYs
|
|
||||||
#define PNG_NO_WRITE_sBIT
|
|
||||||
#define PNG_NO_WRITE_sCAL
|
|
||||||
#define PNG_NO_WRITE_sPLT
|
|
||||||
#define PNG_NO_WRITE_sRGB
|
|
||||||
#define PNG_NO_WRITE_TEXT
|
|
||||||
#define PNG_NO_WRITE_tIME
|
|
||||||
#define PNG_NO_WRITE_UNKNOWN_CHUNKS
|
|
||||||
#define PNG_NO_WRITE_USER_CHUNKS
|
|
||||||
#define PNG_NO_WRITE_EMPTY_PLTE
|
|
||||||
#define PNG_NO_WRITE_OPT_PLTE
|
|
||||||
#define PNG_NO_WRITE_FILTER
|
|
||||||
#define PNG_NO_WRITE_WEIGHTED_FILTER
|
|
||||||
#define PNG_NO_WRITE_INTERLACING_SUPPORTED
|
|
||||||
#define PNG_NO_WRITE_FLUSH
|
|
||||||
|
|
||||||
#define PNG_NO_INFO_IMAGE
|
|
||||||
#define PNG_NO_USER_MEM
|
|
||||||
#define PNG_NO_FIXED_POINT_SUPPORTED
|
|
||||||
#define PNG_NO_MNG_FEATURES
|
|
||||||
#define PNG_NO_USER_TRANSFORM_PTR
|
|
||||||
#define PNG_NO_HANDLE_AS_UNKNOWN
|
|
||||||
#define PNG_NO_CONSOLE_IO
|
|
||||||
#define PNG_NO_ZALLOC_ZERO
|
|
||||||
#define PNG_NO_ERROR_NUMBERS
|
|
||||||
#define PNG_NO_EASY_ACCESS
|
|
||||||
|
|
||||||
#endif /* MINWRPNGCONF_H */
|
#endif /* MINWRPNGCONF_H */
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
This demonstrates the use of PNG_USER_CONFIG and pngusr.h
|
This demonstrates the use of PNG_USER_CONFIG and pngusr.h
|
||||||
|
|
||||||
To build a minimal read-only progressive decoder embedded libpng and
|
The makefile builds a minimal read-only progressive decoder with
|
||||||
zlib and with your system's X library, run
|
embedded libpng, zlib and your system's X library.
|
||||||
|
|
||||||
gather.sh # to collect needed files from gregbook, libpng, and zlib
|
Specify the location of the zlib source (1.2.1 or later) as ZLIBSRC
|
||||||
|
on the make command line.
|
||||||
|
|
||||||
Edit makefile if required, to find your X library and include files,
|
Edit makefile if required, to find your X library and include files,
|
||||||
then
|
then
|
||||||
|
|
||||||
make
|
make ZLIBSRC=directory
|
||||||
|
|
||||||
If you prefer to use the shared libraries, go to contrib/gregbook
|
If you prefer to use the shared libraries, go to contrib/gregbook
|
||||||
and build the rpng2-x application there.
|
and build the rpng2-x application there.
|
||||||
|
|
|
@ -5,7 +5,14 @@
|
||||||
CC=gcc
|
CC=gcc
|
||||||
LD=$(CC)
|
LD=$(CC)
|
||||||
|
|
||||||
|
# If awk fails try
|
||||||
|
# make AWK=nawk
|
||||||
|
|
||||||
|
# If cpp fails try
|
||||||
|
# make CPP=/lib/cpp
|
||||||
|
|
||||||
RM=rm -f
|
RM=rm -f
|
||||||
|
COPY=cp
|
||||||
|
|
||||||
#XINC = -I/usr/include # old-style, stock X distributions
|
#XINC = -I/usr/include # old-style, stock X distributions
|
||||||
#XLIB = -L/usr/lib/X11 -lX11 # (including SGI IRIX)
|
#XLIB = -L/usr/lib/X11 -lX11 # (including SGI IRIX)
|
||||||
|
@ -23,38 +30,137 @@ XLIB = -L/usr/X11R6/lib -lX11
|
||||||
#LIBS = $(XLIB)
|
#LIBS = $(XLIB)
|
||||||
LIBS = $(XLIB) -lm #platforms that need libm
|
LIBS = $(XLIB) -lm #platforms that need libm
|
||||||
|
|
||||||
CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DNO_GZIP \
|
CPPFLAGS=-I. $(XINC) -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
|
||||||
-DdeflateParams\(a,b,c\)=Z_OK -I. $(XINC) -O1
|
CFLAGS=-O1 -Wall
|
||||||
|
|
||||||
C=.c
|
C=.c
|
||||||
O=.o
|
O=.o
|
||||||
L=.a
|
L=.a
|
||||||
E=
|
E=
|
||||||
|
|
||||||
ZOBJS = adler32$(O) crc32$(O) \
|
# Where to find the source code:
|
||||||
infback$(O) inffast$(O) inflate$(O) inftrees$(O) \
|
PNGSRC =../../..
|
||||||
trees$(O) uncompr$(O) zutil$(O)
|
ZLIBSRC=$(PNGSRC)/../zlib
|
||||||
|
PROGSRC=$(PNGSRC)/contrib/gregbook
|
||||||
|
|
||||||
OBJS = rpng2-x$(O) readpng2$(O) png$(O) pngerror$(O) pngget$(O) pngmem$(O) \
|
# Zlib (minimal inflate requirements - crc32 is used by libpng)
|
||||||
|
# zutil can be eliminated if you provide your own zcalloc and zcfree
|
||||||
|
ZSRCS = adler32$(C) crc32$(C) \
|
||||||
|
inffast$(C) inflate$(C) inftrees$(C) \
|
||||||
|
zutil$(C)
|
||||||
|
|
||||||
|
# Standard headers
|
||||||
|
ZH = zlib.h crc32.h inffast.h inffixed.h \
|
||||||
|
inflate.h inftrees.h zutil.h
|
||||||
|
|
||||||
|
# Machine generated headers
|
||||||
|
ZCONF = zconf.h
|
||||||
|
|
||||||
|
# Headers callers use
|
||||||
|
ZINC = zlib.h $(ZCONF)
|
||||||
|
|
||||||
|
# Headers the Zlib source uses
|
||||||
|
ZHDRS = $(ZH) $(ZCONF)
|
||||||
|
|
||||||
|
ZOBJS = adler32$(O) crc32$(O) \
|
||||||
|
inffast$(O) inflate$(O) inftrees$(O) \
|
||||||
|
zutil$(O)
|
||||||
|
|
||||||
|
# libpng
|
||||||
|
PNGSRCS=png$(C) pngerror$(C) pngget$(C) pngmem$(C) \
|
||||||
|
pngpread$(C) pngread$(C) pngrio$(C) pngrtran$(C) pngrutil$(C) \
|
||||||
|
pngset$(C) pngtrans$(C)
|
||||||
|
|
||||||
|
# Standard headers
|
||||||
|
PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h
|
||||||
|
|
||||||
|
# Machine generated headers
|
||||||
|
PNGCONF=pnglibconf.h
|
||||||
|
|
||||||
|
# Headers callers use
|
||||||
|
PNGINC= png.h pngconf.h pngusr.h $(PNGCONF)
|
||||||
|
|
||||||
|
# Headers the PNG library uses
|
||||||
|
PNGHDRS=$(PNGH) $(PNGCONF) pngusr.h
|
||||||
|
|
||||||
|
PNGOBJS=png$(O) pngerror$(O) pngget$(O) pngmem$(O) \
|
||||||
pngpread$(O) pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) \
|
pngpread$(O) pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) \
|
||||||
pngset$(O) pngtrans$(O) $(ZOBJS)
|
pngset$(O) pngtrans$(O)
|
||||||
|
|
||||||
|
PROGSRCS= rpng2-x$(C) readpng2$(C)
|
||||||
|
PROGHDRS= readpng2.h
|
||||||
|
PROGDOCS= COPYING LICENSE
|
||||||
|
PROGOBJS= rpng2-x$(O) readpng2$(O)
|
||||||
|
|
||||||
|
OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
|
||||||
|
|
||||||
# implicit make rules -------------------------------------------------------
|
# implicit make rules -------------------------------------------------------
|
||||||
|
|
||||||
.c$(O): png.h pngconf.h readpng2.h pngusr.h zlib.h
|
.c$(O):
|
||||||
$(CC) -c $(CFLAGS) $<
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
|
||||||
|
|
||||||
# dependencies
|
# dependencies
|
||||||
|
|
||||||
all: rpng2-x$(E)
|
all: $(PROGDOCS) rpng2-x$(E)
|
||||||
|
|
||||||
rpng2-x$(E): $(OBJS)
|
rpng2-x$(E): $(OBJS)
|
||||||
$(LD) -o rpng2-x$(E) $(OBJS) $(LIBS)
|
$(LD) -o rpng2-x$(E) $(OBJS) $(LIBS)
|
||||||
strip rpng2-x$(E)
|
|
||||||
|
# The DFA_XTRA setting turns all libpng options off then
|
||||||
|
# turns on those required for this minimal build.
|
||||||
|
# The CPP_FLAGS setting causes pngusr.h to be included in
|
||||||
|
# both the build of pnglibconf.h and, subsequently, when
|
||||||
|
# building libpng itself.
|
||||||
|
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
|
||||||
|
$(PNGSRC)/scripts/pnglibconf.dfa \
|
||||||
|
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
|
||||||
|
$(RM) pnglibconf.h pnglibconf.dfn
|
||||||
|
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
|
||||||
|
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
|
||||||
|
DFA_XTRA="pngusr.dfa" $@
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
|
||||||
|
srcdir=$(PNGSRC) clean
|
||||||
$(RM) rpng2-x$(O)
|
$(RM) rpng2-x$(O)
|
||||||
$(RM) rpng2-x$(E)
|
$(RM) rpng2-x$(E)
|
||||||
$(RM) $(OBJS)
|
$(RM) $(OBJS)
|
||||||
|
|
||||||
|
# distclean also removes the copied source and headers
|
||||||
|
distclean: clean
|
||||||
|
$(RM) -r scripts # historical reasons
|
||||||
|
$(RM) $(PNGSRCS) $(PNGH)
|
||||||
|
$(RM) $(ZSRCS) $(ZH) $(ZCONF)
|
||||||
|
$(RM) $(PROGSRCS) $(PROGHDRS) $(PROGDOCS)
|
||||||
|
|
||||||
|
# Header file dependencies:
|
||||||
|
$(PROGOBJS): $(PROGHDRS) $(PNGINC) $(ZINC)
|
||||||
|
$(PNGOBJS): $(PNGHDRS) $(ZINC)
|
||||||
|
$(ZOBJS): $(ZHDRS)
|
||||||
|
|
||||||
|
# Gather the source code from the respective directories
|
||||||
|
$(PNGSRCS) $(PNGH): $(PNGSRC)/$@
|
||||||
|
$(RM) $@
|
||||||
|
$(COPY) $(PNGSRC)/$@ $@
|
||||||
|
|
||||||
|
# No dependency on the ZLIBSRC target so that it only needs
|
||||||
|
# to be specified once.
|
||||||
|
$(ZSRCS) $(ZH):
|
||||||
|
$(RM) $@
|
||||||
|
$(COPY) $(ZLIBSRC)/$@ $@
|
||||||
|
|
||||||
|
# The unconfigured zconf.h varies in name according to the
|
||||||
|
# zlib release
|
||||||
|
$(ZCONF):
|
||||||
|
$(RM) $@
|
||||||
|
@for f in zconf.h.in zconf.in.h zconf.h; do\
|
||||||
|
test -r $(ZLIBSRC)/$$f &&\
|
||||||
|
echo $(COPY) $(ZLIBSRC)/$$f $@ &&\
|
||||||
|
$(COPY) $(ZLIBSRC)/$$f $@ && exit 0;\
|
||||||
|
done; echo copy: $(ZLIBSRC)/zconf.h not found; exit 1
|
||||||
|
|
||||||
|
$(PROGSRCS) $(PROGHDRS) $(PROGDOCS): $(PROGSRC)/$@
|
||||||
|
$(RM) $@
|
||||||
|
$(COPY) $(PROGSRC)/$@ $@
|
||||||
|
|
||||||
# End of makefile for rpng2-x
|
# End of makefile for rpng2-x
|
||||||
|
|
40
libs/libpng-src/contrib/pngminim/preader/pngusr.dfa
Normal file
40
libs/libpng-src/contrib/pngminim/preader/pngusr.dfa
Normal file
|
@ -0,0 +1,40 @@
|
||||||
|
# pngminim/preader/pngusr.dfa
|
||||||
|
#
|
||||||
|
# Copyright (c) 2010-2013 Glenn Randers-Pehrson
|
||||||
|
#
|
||||||
|
# This code is released under the libpng license.
|
||||||
|
# For conditions of distribution and use, see the disclaimer
|
||||||
|
# and license in png.h
|
||||||
|
|
||||||
|
# First all the build options off:
|
||||||
|
|
||||||
|
everything = off
|
||||||
|
|
||||||
|
# Just switch on the progressive read code
|
||||||
|
|
||||||
|
option PROGRESSIVE_READ on
|
||||||
|
|
||||||
|
# You may choose fixed or floating point APIs:
|
||||||
|
# option FLOATING_POINT on
|
||||||
|
|
||||||
|
option FIXED_POINT on
|
||||||
|
|
||||||
|
# You must chose the internal fixed point implementation or to
|
||||||
|
# use the system floating point. The latter is considerably
|
||||||
|
# smaller (by about 1kbyte on an x86 system):
|
||||||
|
|
||||||
|
option FLOATING_ARITHMETIC on
|
||||||
|
# option FLOATING_ARITHMETIC off
|
||||||
|
|
||||||
|
# Your program will probably need other options. The example
|
||||||
|
# program here, rpng2-x, requires the following. Take a look
|
||||||
|
# at pnglibconf.h to find out the full set of what has to be
|
||||||
|
# enabled to make the following work.
|
||||||
|
|
||||||
|
option SETJMP on
|
||||||
|
option STDIO on
|
||||||
|
option READ_bKGD on
|
||||||
|
option READ_GAMMA on
|
||||||
|
option READ_EXPAND on
|
||||||
|
option READ_STRIP_16_TO_8 on
|
||||||
|
option READ_GRAY_TO_RGB on
|
|
@ -1,6 +1,6 @@
|
||||||
/* minrdpngconf.h: headers to make a minimal png-read-only library
|
/* minrdpngconf.h: headers to make a minimal png-read-only library
|
||||||
*
|
*
|
||||||
* Copyright (c) 2009 Glenn Randers-Pehrson
|
* Copyright (c) 2009, 2010-2013 Glenn Randers-Pehrson
|
||||||
*
|
*
|
||||||
* This code is released under the libpng license.
|
* This code is released under the libpng license.
|
||||||
* For conditions of distribution and use, see the disclaimer
|
* For conditions of distribution and use, see the disclaimer
|
||||||
|
@ -12,57 +12,12 @@
|
||||||
#ifndef MINPRDPNGCONF_H
|
#ifndef MINPRDPNGCONF_H
|
||||||
#define MINPRDPNGCONF_H
|
#define MINPRDPNGCONF_H
|
||||||
|
|
||||||
#define PNG_NO_GLOBAL_ARRAYS
|
/* To include pngusr.h set -DPNG_USER_CONFIG in CPPFLAGS */
|
||||||
|
|
||||||
#define PNG_NO_WARNINGS
|
/* List options to turn off features of the build that do not
|
||||||
#define png_warning(s1,s2) ""
|
* affect the API (so are not recorded in pnglibconf.h)
|
||||||
#define png_chunk_warning(s1,s2) ""
|
*/
|
||||||
#define PNG_NO_ERROR_TEXT
|
|
||||||
#define png_error(s1,s2) png_err(s1)
|
|
||||||
#define png_chunk_error(s1,s2) png_err(s1)
|
|
||||||
|
|
||||||
#define PNG_NO_ASSEMBLER_CODE
|
#define PNG_ALIGN_TYPE PNG_ALIGN_NONE
|
||||||
#define PNG_NO_OPTIMIZED_CODE
|
|
||||||
#define PNG_NO_READ_DITHER
|
|
||||||
#define PNG_NO_READ_INVERT
|
|
||||||
#define PNG_NO_READ_SHIFT
|
|
||||||
#define PNG_NO_READ_PACK
|
|
||||||
#define PNG_NO_READ_PACKSWAP
|
|
||||||
#define PNG_NO_READ_FILLER
|
|
||||||
#define PNG_NO_READ_SWAP
|
|
||||||
#define PNG_NO_READ_SWAP_ALPHA
|
|
||||||
#define PNG_NO_READ_INVERT_ALPHA
|
|
||||||
#define PNG_NO_READ_RGB_TO_GRAY
|
|
||||||
#define PNG_NO_READ_USER_TRANSFORM
|
|
||||||
#define PNG_NO_READ_cHRM
|
|
||||||
#define PNG_NO_READ_hIST
|
|
||||||
#define PNG_NO_READ_iCCP
|
|
||||||
#define PNG_NO_READ_pCAL
|
|
||||||
#define PNG_NO_READ_pHYs
|
|
||||||
#define PNG_NO_READ_sBIT
|
|
||||||
#define PNG_NO_READ_sCAL
|
|
||||||
#define PNG_NO_READ_sPLT
|
|
||||||
#define PNG_NO_READ_TEXT
|
|
||||||
#define PNG_NO_READ_tIME
|
|
||||||
#define PNG_NO_READ_UNKNOWN_CHUNKS
|
|
||||||
#define PNG_NO_READ_USER_CHUNKS
|
|
||||||
#define PNG_NO_READ_EMPTY_PLTE
|
|
||||||
#define PNG_NO_READ_OPT_PLTE
|
|
||||||
#define PNG_NO_READ_STRIP_ALPHA
|
|
||||||
#define PNG_NO_READ_oFFs
|
|
||||||
#define PNG_NO_WARN_UNINITIALIZED_ROW
|
|
||||||
|
|
||||||
#define PNG_NO_WRITE_SUPPORTED
|
|
||||||
|
|
||||||
#define PNG_NO_INFO_IMAGE
|
|
||||||
#define PNG_NO_USER_MEM
|
|
||||||
#define PNG_NO_FIXED_POINT_SUPPORTED
|
|
||||||
#define PNG_NO_MNG_FEATURES
|
|
||||||
#define PNG_NO_USER_TRANSFORM_PTR
|
|
||||||
#define PNG_NO_HANDLE_AS_UNKNOWN
|
|
||||||
#define PNG_NO_CONSOLE_IO
|
|
||||||
#define PNG_NO_ZALLOC_ZERO
|
|
||||||
#define PNG_NO_ERROR_NUMBERS
|
|
||||||
#define PNG_NO_EASY_ACCESS
|
|
||||||
|
|
||||||
#endif /* MINPRDPNGCONF_H */
|
#endif /* MINPRDPNGCONF_H */
|
||||||
|
|
13
libs/libpng-src/contrib/pngminus/CHANGES.txt
Normal file
13
libs/libpng-src/contrib/pngminus/CHANGES.txt
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
pnm2png / png2pnm --- conversion from PBM/PGM/PPM-file to PNG-file
|
||||||
|
copyright (C) 1999-2019 by Willem van Schaik <willem at schaik dot com>
|
||||||
|
|
||||||
|
version 1.0 - 1999.10.15 - First version.
|
||||||
|
1.1 - 2015.07.29 - Fixed leaks (Glenn Randers-Pehrson)
|
||||||
|
1.2 - 2017.04.22 - Add buffer-size check
|
||||||
|
1.3 - 2017.08.24 - Fix potential overflow in buffer-size check
|
||||||
|
(Glenn Randers-Pehrson)
|
||||||
|
1.4 - 2017.08.28 - Add PNGMINUS_UNUSED (Christian Hesse)
|
||||||
|
1.5 - 2018.08.05 - Fix buffer overflow in tokenizer (Cosmin Truta)
|
||||||
|
1.6 - 2018.08.05 - Improve portability and fix style (Cosmin Truta)
|
||||||
|
1.7 - 2019.01.22 - Change license to MIT (Willem van Schaik)
|
24
libs/libpng-src/contrib/pngminus/CMakeLists.txt
Normal file
24
libs/libpng-src/contrib/pngminus/CMakeLists.txt
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
cmake_minimum_required(VERSION 3.1)
|
||||||
|
cmake_policy(VERSION 3.1)
|
||||||
|
|
||||||
|
project(PNGMINUS C)
|
||||||
|
|
||||||
|
option(PNGMINUS_USE_STATIC_LIBRARIES "Use the static library builds" ON)
|
||||||
|
|
||||||
|
# libpng
|
||||||
|
add_subdirectory(../.. libpng)
|
||||||
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../..)
|
||||||
|
include_directories(${CMAKE_CURRENT_BINARY_DIR}/libpng)
|
||||||
|
if(PNGMINUS_USE_STATIC_LIBRARIES)
|
||||||
|
set(PNGMINUS_PNG_LIBRARY png_static)
|
||||||
|
else()
|
||||||
|
set(PNGMINUS_PNG_LIBRARY png)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# png2pnm
|
||||||
|
add_executable(png2pnm png2pnm.c)
|
||||||
|
target_link_libraries(png2pnm ${PNGMINUS_PNG_LIBRARY})
|
||||||
|
|
||||||
|
# pnm2png
|
||||||
|
add_executable(pnm2png pnm2png.c)
|
||||||
|
target_link_libraries(pnm2png ${PNGMINUS_PNG_LIBRARY})
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue