mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Compare commits
156 Commits
21895b05ab
...
v1.7.0beta
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9bf3c70730 | ||
|
|
1bc5747713 | ||
|
|
4a7796faca | ||
|
|
34081a0e2f | ||
|
|
b88c94208a | ||
|
|
30662f5e92 | ||
|
|
46ad4c5bd4 | ||
|
|
5c32606ec0 | ||
|
|
a08ac031fc | ||
|
|
c233ec8743 | ||
|
|
d594be641a | ||
|
|
4c9168875b | ||
|
|
3c051ee282 | ||
|
|
e1ded944f0 | ||
|
|
c09dddc0cd | ||
|
|
bd56d76417 | ||
|
|
0cc23ac171 | ||
|
|
cb10e19725 | ||
|
|
9dba7219a0 | ||
|
|
17c6af8c40 | ||
|
|
6a02eb6d2c | ||
|
|
40d41fe6f8 | ||
|
|
7073d26e51 | ||
|
|
cf76fe8654 | ||
|
|
b780b64fbf | ||
|
|
b1876ab6e2 | ||
|
|
28a95d125f | ||
|
|
993f68c006 | ||
|
|
8d23524359 | ||
|
|
e0f4aaa668 | ||
|
|
3de174cd2f | ||
|
|
eaf2f1dcbe | ||
|
|
ea0b4c602e | ||
|
|
371c3d4dfd | ||
|
|
0bcf5fb451 | ||
|
|
57d6907d89 | ||
|
|
6cf97e37af | ||
|
|
8ef61c4693 | ||
|
|
25a116f97d | ||
|
|
d6d41c847a | ||
|
|
9e0297546f | ||
|
|
d529363d13 | ||
|
|
55e93d7090 | ||
|
|
23674b75be | ||
|
|
0ddf350360 | ||
|
|
066f9862f0 | ||
|
|
ae1a5c811c | ||
|
|
5a1ce92c0c | ||
|
|
7a498039c5 | ||
|
|
40a93652aa | ||
|
|
a1362f38de | ||
|
|
30bc0333fe | ||
|
|
55794013d4 | ||
|
|
2e92b4dfa0 | ||
|
|
f46106fa04 | ||
|
|
0dcd32f39c | ||
|
|
808ea281a4 | ||
|
|
ec89aefb44 | ||
|
|
6152dbd424 | ||
|
|
fe18c0d9ea | ||
|
|
1b0358302d | ||
|
|
d20f9d5030 | ||
|
|
fc447311aa | ||
|
|
8e30e43587 | ||
|
|
0403ccf1de | ||
|
|
1a321cc088 | ||
|
|
c9f99f487b | ||
|
|
8360e60abc | ||
|
|
2799f74489 | ||
|
|
7363babe4f | ||
|
|
e3a526f789 | ||
|
|
8f0935b8dc | ||
|
|
ae6503fe0e | ||
|
|
851a6265a8 | ||
|
|
ffa24d4108 | ||
|
|
206f4d2678 | ||
|
|
bb040784c2 | ||
|
|
70e1af50ed | ||
|
|
eb4a645eda | ||
|
|
9f7f03a3c4 | ||
|
|
395ddbd318 | ||
|
|
9f0d36c85f | ||
|
|
e9760e5e95 | ||
|
|
b96b2b7e90 | ||
|
|
9bb705e0a8 | ||
|
|
e860f77393 | ||
|
|
b5a7565908 | ||
|
|
e88e221d91 | ||
|
|
b10867cdc2 | ||
|
|
bf7084b80d | ||
|
|
6afcee826f | ||
|
|
f15a5006c8 | ||
|
|
cdbd5174bd | ||
|
|
7a9b6203ef | ||
|
|
803493e19c | ||
|
|
4245e6b1b2 | ||
|
|
81892f6b90 | ||
|
|
862993827d | ||
|
|
d304125332 | ||
|
|
9124f3e29a | ||
|
|
2969375aa6 | ||
|
|
5e8ba1cbbf | ||
|
|
8aee43d10a | ||
|
|
e355657bbe | ||
|
|
fb6ba9acf4 | ||
|
|
815173a0b5 | ||
|
|
7f489a77bb | ||
|
|
8ec8e8fcd5 | ||
|
|
a4e606dd5f | ||
|
|
646de7962b | ||
|
|
4accd423c2 | ||
|
|
f62caaf4dc | ||
|
|
b789bb84bb | ||
|
|
ce60ad642b | ||
|
|
ab097b1168 | ||
|
|
3a737d86c7 | ||
|
|
a1337e57a8 | ||
|
|
247b3fcf49 | ||
|
|
f01273b25c | ||
|
|
8cb1a2ac6d | ||
|
|
e6e5ac8cb7 | ||
|
|
a4798fb83e | ||
|
|
46369f35c5 | ||
|
|
e699993d70 | ||
|
|
5a0afcfa63 | ||
|
|
3fc9cbf126 | ||
|
|
36b628b19e | ||
|
|
2c31365fd4 | ||
|
|
e1e3c1a2a2 | ||
|
|
b940e5dc5d | ||
|
|
fbbbc620b8 | ||
|
|
9b99600c4d | ||
|
|
3129d7426e | ||
|
|
325ceea971 | ||
|
|
ac39fc3024 | ||
|
|
99343407e6 | ||
|
|
3e23f45ba9 | ||
|
|
72389dec42 | ||
|
|
1f0853f47e | ||
|
|
32a60a4885 | ||
|
|
5e07dc6970 | ||
|
|
4b90a8d416 | ||
|
|
d59c19b64c | ||
|
|
bbabd977d1 | ||
|
|
0cf9c7d63d | ||
|
|
b4e241559e | ||
|
|
1e15aee6be | ||
|
|
d59e60d0fb | ||
|
|
ec1d13a1d4 | ||
|
|
d9002f94cb | ||
|
|
1fa858db48 | ||
|
|
0f2a5bac64 | ||
|
|
eac85878bf | ||
|
|
240ac287eb | ||
|
|
3e42c81193 | ||
|
|
ac3b4d9b69 |
806
ANNOUNCE
806
ANNOUNCE
@@ -1,5 +1,5 @@
|
||||
|
||||
Libpng 1.6.0beta33 - December 10, 2012
|
||||
Libpng 1.7.0beta15 - June 18, 2013
|
||||
|
||||
This is not intended to be a public release. It will be replaced
|
||||
within a few weeks by a public version or by another test version.
|
||||
@@ -9,555 +9,327 @@ Files available for download:
|
||||
Source files with LF line endings (for Unix/Linux) and with a
|
||||
"configure" script
|
||||
|
||||
1.6.0beta33.tar.xz (LZMA-compressed, recommended)
|
||||
1.6.0beta33.tar.gz
|
||||
1.6.0beta33.tar.bz2
|
||||
1.7.0beta15.tar.xz (LZMA-compressed, recommended)
|
||||
1.7.0beta15.tar.gz
|
||||
|
||||
Source files with CRLF line endings (for Windows), without the
|
||||
"configure" script
|
||||
|
||||
lp160b33.7z (LZMA-compressed, recommended)
|
||||
lp160b33.zip
|
||||
lp170b15.7z (LZMA-compressed, recommended)
|
||||
lp170b15.zip
|
||||
|
||||
Other information:
|
||||
|
||||
1.6.0beta33-README.txt
|
||||
1.6.0beta33-LICENSE.txt
|
||||
1.7.0beta15-README.txt
|
||||
1.7.0beta15-LICENSE.txt
|
||||
|
||||
Changes since the last public release (1.5.7):
|
||||
Changes since the last public release (1.6.0):
|
||||
|
||||
Version 1.6.0beta01 [December 15, 2011]
|
||||
Removed machine-generated configure files from the GIT repository (they will
|
||||
continue to appear in the tarball distributions).
|
||||
Restored the new 'simplified' API, which was started in libpng-1.5.7beta02
|
||||
but later deleted from libpng-1.5.7beta05.
|
||||
Added example programs for the new 'simplified' API.
|
||||
Added ANSI-C (C90) headers and require them, and take advantage of the
|
||||
change. Also fixed some of the projects/* and contrib/* files that needed
|
||||
updates for libpng16 and the move of pngvalid.c.
|
||||
With this change the required ANSI-C header files are assumed to exist: the
|
||||
implementation must provide float.h, limits.h, stdarg.h and stddef.h and
|
||||
libpng relies on limits.h and stddef.h existing and behaving as defined
|
||||
(the other two required headers aren't used). Non-ANSI systems that don't
|
||||
have stddef.h or limits.h will have to provide an appropriate fake
|
||||
containing the relevant types and #defines.
|
||||
The use of FAR/far has been eliminated and the definition of png_alloc_size_t
|
||||
is now controlled by a flag so that 'small size_t' systems can select it
|
||||
if necessary. Libpng 1.6 may not currently work on such systems -- it
|
||||
seems likely that it will ask 'malloc' for more than 65535 bytes with any
|
||||
image that has a sufficiently large row size (rather than simply failing
|
||||
to read such images).
|
||||
New tools directory containing tools used to generate libpng code.
|
||||
Fixed race conditions in parallel make builds. With higher degrees of
|
||||
parallelism during 'make' the use of the same temporary file names such
|
||||
as 'dfn*' can result in a race where a temporary file from one arm of the
|
||||
build is deleted or overwritten in another arm. This changes the
|
||||
temporary files for suffix rules to always use $* and ensures that the
|
||||
non-suffix rules use unique file names.
|
||||
Version 1.7.0alpha01 [December 15, 2012]
|
||||
Started 1.7.0 branch from libpng-1.6.0beta33.
|
||||
Made 8-bit compose and rgb_to_grayscale accuracy improvements. These
|
||||
changes cause 16-bit arithmetic to be used for 8-bit data in the gamma
|
||||
corrected compose and grayscale operations. The arithmetic errors have
|
||||
three sources all of which are fixed in this commit:
|
||||
1) 8-bit linear calculations produce massive errors for lower intensity
|
||||
values.
|
||||
2) The old 16-bit "16 to 8" gamma table code erroneously wrote the lowest
|
||||
output value into a table entry which corresponded to multiple output
|
||||
values (so where the value written should have been the closest to the
|
||||
transformed input value.)
|
||||
3) In a number of cases the code to access the 16-bit table did not round;
|
||||
it did a simple shift, which was wrong and made the side effects of (2)
|
||||
even worse.
|
||||
The new gamma code does not have the 16-to-8 problem at the cost of slightly
|
||||
more calculations and the algorithm used to minimize the number of
|
||||
calculations has been extended to all the 16-bit tables; it has advantages
|
||||
for any significant gamma correction.
|
||||
Rearranged png_struct, remove unused members, change png_set_filter handling
|
||||
png_struct members rearranged - partly to reorder to avoid packing, partly
|
||||
to put frequently accessed members at the start and partly to make
|
||||
the grouping more clear. png_set_filter code has been rewritten and the
|
||||
code shared with png_write_start_row moved to a common function. Comments
|
||||
in png.h have been made more clear. Minor fixes to
|
||||
contrib/libtests/timepng.c and some of the png_*_tRNS logic, including
|
||||
more error detection in png_set_tRNS.
|
||||
Cleaned up USER_LIMITS feature, removing members from png_struct when not
|
||||
required.
|
||||
Rearranged ARM-NEON optimizations to isolate the machine specific code to
|
||||
the hardware subdirectory, and add comments to pngrutil.c so that
|
||||
implementors of other optimizations will know what to do.
|
||||
Fixed cases of unquoted DESTDIR in Makefile.am.
|
||||
Rebuilt Makefile.in, configure, etc., with autoconf-2.69 and automake-1.12.5.
|
||||
|
||||
Version 1.6.0beta02 [December 21, 2011]
|
||||
Correct configure builds where build and source directories are separate.
|
||||
The include path of 'config.h' was erroneously made relative in pngvalid.c
|
||||
in libpng 1.5.7.
|
||||
Version 1.7.0alpha02 [December 17, 2012]
|
||||
Removed functions that were deprecated in libpng-1.6.0:
|
||||
png_reset_zstream(), png_info_init_3(), and png_data_freer() and its
|
||||
associated flags.
|
||||
Removed some duplicated lines from contrib/tools/scale.c and png.c.
|
||||
Changed some instances of png_warning() to png_app_error().
|
||||
Updated some left over "1.6.0beta32" in code sources.
|
||||
Fixed a "png_structp" prototype (should be png_structrp) in arm_init.c
|
||||
Updated the version-number hack in pngvalid.c
|
||||
|
||||
Version 1.6.0beta03 [December 22, 2011]
|
||||
Start-up code size improvements, error handler flexibility. These changes
|
||||
alter how the tricky allocation of the initial png_struct and png_info
|
||||
structures are handled. png_info is now handled in pretty much the same
|
||||
way as everything else, except that the allocations handle NULL return
|
||||
silently. png_struct is changed in a similar way on allocation and on
|
||||
deallocation a 'safety' error handler is put in place (which should never
|
||||
be required). The error handler itself is changed to permit mismatches
|
||||
in the application and libpng error buffer size; however, this means a
|
||||
silent change to the API to return the jmp_buf if the size doesn't match
|
||||
the size from the libpng compilation; libpng now allocates the memory and
|
||||
this may fail. Overall these changes result in slight code size
|
||||
reductions; however, this is a reduction in code that is always executed
|
||||
so is particularly valuable. Overall on a 64-bit system the libpng DLL
|
||||
decreases in code size by 1733 bytes. pngerror.o increases in size by
|
||||
about 465 bytes because of the new functionality.
|
||||
Added png_convert_to_rfc1123_buffer() and deprecated png_convert_to_rfc1123()
|
||||
to avoid including a spurious buffer in the png_struct.
|
||||
Version 1.7.0alpha03 [December 19, 2012]
|
||||
Cleaned up and enhanced the configure option; libpng now correctly
|
||||
links and tests against zlib with a prefix; tests have been clarified; and
|
||||
irrelevant or obsolete things (as defined by the autotools man page) have
|
||||
been removed.
|
||||
Documented new PNG_ABORT behavior in the manual and commentary in pngerror.c
|
||||
Cleaned up whitespace in the synopsis portion of the manpage "libpng.3"
|
||||
Fixed previous support for Z_PREFIX in configure builds, corrected sCAL APIs;
|
||||
some of these use floating point arithmetic so they need to be disabled if
|
||||
floating point arithmetic is switched off. This is a quiet API change -
|
||||
previously it appeared that the APIs were supported if fixed point
|
||||
arithmetic was used internally, however they required certain APIs (floor,
|
||||
modf, frexp, atof) that are part of C floating point support. Changed
|
||||
png_fixed and the gamma code specific version of the same to avoid floor(),
|
||||
which may be a library function (not an intrinsic). Removed unused #if 0
|
||||
code.
|
||||
Disassembled the version number in scripts/options.awk (necessary for
|
||||
building on SunOs).
|
||||
|
||||
Version 1.6.0beta04 [December 30, 2011]
|
||||
Regenerated configure scripts with automake-1.11.2
|
||||
Eliminated png_info_destroy(). It is now used only in png.c and only calls
|
||||
one other internal function and memset().
|
||||
Enabled png_get_sCAL_fixed() if floating point APIs are enabled. Previously
|
||||
it was disabled whenever internal fixed point arithmetic was selected,
|
||||
which meant it didn't exist even on systems where FP was available but not
|
||||
preferred.
|
||||
Added pngvalid.c compile time checks for const APIs.
|
||||
Implemented 'restrict' for png_info and png_struct. Because of the way
|
||||
libpng works both png_info and png_struct are always accessed via a
|
||||
single pointer. This means adding C99 'restrict' to the pointer gives
|
||||
the compiler some opportunity to optimize the code. This change allows
|
||||
that.
|
||||
Moved AC_MSG_CHECKING([if libraries can be versioned]) later to the proper
|
||||
location in configure.ac (Gilles Espinasse).
|
||||
Changed png_memcpy to C assignment where appropriate. Changed all those
|
||||
uses of png_memcpy that were doing a simple assignment to assignments
|
||||
(all those cases where the thing being copied is a non-array C L-value).
|
||||
Added some error checking to png_set_*() routines.
|
||||
Removed the reference to the non-exported function png_memcpy() from
|
||||
example.c.
|
||||
Fixed the Visual C 64-bit build - it requires jmp_buf to be aligned, but
|
||||
it had become misaligned.
|
||||
Revised contrib/pngminus/pnm2png.c to avoid warnings when png_uint_32
|
||||
and unsigned long are of different sizes.
|
||||
Version 1.7.0alpha04 [December 23, 2012]
|
||||
Added scripts/makefile.msys contributed by Christopher M. Wheeler
|
||||
Made default Zlib compression settings be configurable. This adds #defines to
|
||||
pnglibconf.h to control the defaults.
|
||||
Fixed Windows build issues, enabled ARM compilation. Various warnings issued
|
||||
by earlier versions of GCC fixed for Cygwin and Min/GW (which both use old
|
||||
GCCs.) ARM support is enabled by default in zlib.props (unsupported by
|
||||
Microsoft) and ARM compilation is made possible by deleting the check for
|
||||
x86. The test programs cannot be run because they are not signed.
|
||||
|
||||
Version 1.6.0beta05 [January 15, 2012]
|
||||
Updated manual with description of the simplified API (copied from png.h)
|
||||
Fix bug in pngerror.c: some long warnings were being improperly truncated
|
||||
(CVE-2011-3464, bug introduced in libpng-1.5.3beta05).
|
||||
Version 1.7.0alpha05 [December 24, 2012]
|
||||
Discontinued distributing libpng-1.x.x.tar.bz2.
|
||||
Discontinued distributing libpng-1.7.0-1.6.0-diff.txt and similar.
|
||||
|
||||
Version 1.6.0beta06 [January 24, 2012]
|
||||
Added palette support to the simplified APIs. This commit
|
||||
changes some of the macro definitions in png.h, app code
|
||||
may need corresponding changes.
|
||||
Increased the formatted warning buffer to 192 bytes.
|
||||
Added color-map support to simplified API. This is an initial version for
|
||||
review; the documentation has not yet been updated.
|
||||
Fixed Min/GW uninstall to remove libpng.dll.a
|
||||
Version 1.7.0alpha06 [January 1, 2013]
|
||||
Fixed 'make distcheck' on SUN OS - libpng.so was not being removed
|
||||
|
||||
Version 1.6.0beta07 [January 28, 2012]
|
||||
Eliminated Intel icc/icl compiler warnings. The Intel (GCC derived)
|
||||
compiler issues slightly different warnings from those issued by the
|
||||
current vesions of GCC. This eliminates those warnings by
|
||||
adding/removing casts and small code rewrites.
|
||||
Updated configure.ac from autoupdate: added --enable-werror option.
|
||||
Also some layout regularization and removal of introduced tab characters
|
||||
(replaced with 3-character indentation). Obsolete macros identified by
|
||||
autoupdate have been removed; the replacements are all in 2.59 so
|
||||
the pre-req hasn't been changed. --enable-werror checks for support
|
||||
for -Werror (or the given argument) in the compiler. This mimics the
|
||||
gcc configure option by allowing -Werror to be turned on safely; without
|
||||
the option the tests written in configure itself fail compilation because
|
||||
they cause compiler warnings.
|
||||
Rewrote autogen.sh to run autoreconf instead of running tools one-by-one.
|
||||
Conditionalize the install rules for MINGW and CYGWIN in CMakeLists.txt and
|
||||
set CMAKE_LIBRARY_OUTPUT_DIRECTORY to "lib" on all platforms (C. Yapp).
|
||||
Freeze libtool files in the 'scripts' directory. This version of autogen.sh
|
||||
attempts to dissuade people from running it when it is not, or should not,
|
||||
be necessary. In fact, autogen.sh does not work when run in a libpng
|
||||
directory extracted from atar distribution anymore. You must run it in
|
||||
a GIT clone instead.
|
||||
Added two images to contrib/pngsuite (1-bit and 2-bit transparent grayscale),
|
||||
and renamed three whose names were inconsistent with those in
|
||||
pngsuite/README.txt.
|
||||
Version 1.7.0alpha07 [January 10, 2013]
|
||||
Fixed conceivable but difficult to repro overflow. Also added two test
|
||||
programs to generate and test a PNG which should have the problem.
|
||||
|
||||
Version 1.6.0beta08 [February 1, 2012]
|
||||
Fixed Image::colormap misalignment in pngstest.c
|
||||
Check libtool/libtoolize version number (2.4.2) in configure.ac
|
||||
Divide test-pngstest.sh into separate pngstest runs for basic and
|
||||
transparent images.
|
||||
Moved automake options to AM_INIT_AUTOMAKE in configure.ac
|
||||
Added color-tests, silent-rules (Not yet implemented in Makefile.am) and
|
||||
version checking to configure.ac
|
||||
Improved pngstest speed by not doing redundant tests and add const to
|
||||
the background parameter of png_image_finish_read. The --background
|
||||
option is now done automagically only when required, so that commandline
|
||||
option no longer exists.
|
||||
Cleaned up pngpriv.h to consistently declare all functions and data.
|
||||
Also eliminated PNG_CONST_DATA, which is apparently not needed but we
|
||||
can't be sure until it is gone.
|
||||
Added symbol prefixing that allows all the libpng external symbols
|
||||
to be prefixed (suggested by Reuben Hawkins).
|
||||
Updated "ftbb*.png" list in the owatcom and vstudio projects.
|
||||
Fixed 'prefix' builds on clean systems. The generation of pngprefix.h
|
||||
should not require itself.
|
||||
Updated INSTALL to explain that autogen.sh must be run in a GIT clone,
|
||||
not in a libpng directory extracted from a tar distribution.
|
||||
Version 1.7.0alpha08 [January 17, 2013]
|
||||
Corrected previous attempt at overflow detection in png_set_unknown_chunks().
|
||||
|
||||
Version 1.6.0beta09 [February 1, 2012]
|
||||
Reverted the prebuilt configure files to libpng-1.6.0beta05 condition.
|
||||
Version 1.7.0alpha09 [January 21, 2013]
|
||||
Pulled changes to multi-chunk handling from libpng-1.6.0beta40.
|
||||
|
||||
Version 1.6.0beta10 [February 3, 2012]
|
||||
Added Z_SOLO for zlib-1.2.6+ and correct pngstest tests
|
||||
Updated list of test images in CMakeLists.txt
|
||||
Updated the prebuilt configure files to current condition.
|
||||
Revised INSTALL information about autogen.sh; it works in tar distributions.
|
||||
Version 1.7.0alpha10 [February 5, 2013]
|
||||
Make symbol prefixing work with the ARM neon optimizations. Also
|
||||
allow pngpriv.h to be included for preprocessor definitions only, so
|
||||
it can be used in non-C/C++ files.
|
||||
Added png_get_palette_max() function.
|
||||
Changed png_size_t to size_t throughout headers, make sRGB check numbers
|
||||
consistent.
|
||||
Fixed ARM support (Mans Rullgard).
|
||||
Removed stray out-of-order #endif and #ifdef (Mans Rullgard).
|
||||
Ported libpng 1.5 options.awk/dfn file handling to 1.7, fixed one bug.
|
||||
Rebuilt Makefile.in, configure, etc., with autoconf-2.69 and automake-1.13.
|
||||
Minor fixes to assembler changes, verified with a dummy .S file
|
||||
Removed cc -E workround, corrected png_get_palette_max API. Tested on
|
||||
SUN OS cc 5.9, which demonstrates the tokenization problem previously
|
||||
avoided by using /lib/cpp. Since all .dfn output is now protected
|
||||
in double quotes unless it is to be macro substituted the fix should work
|
||||
everywhere.
|
||||
|
||||
Version 1.6.0beta11 [February 16, 2012]
|
||||
Fix character count in pngstest command in projects/owatcom/pngstest.tgt
|
||||
Revised test-pngstest.sh to report PASS/FAIL for each image.
|
||||
Updated documentation about the simplified API.
|
||||
Corrected estimate of error in libpng png_set_rgb_to_gray API. The API is
|
||||
extremely inaccurate for sRGB conversions because it uses an 8-bit
|
||||
intermediate linear value and it does not use the sRGB transform, so it
|
||||
suffers from the known instability in gamma transforms for values close
|
||||
to 0 (see Poynton). The net result is that the calculation has a maximum
|
||||
error of 14.99/255; 0.5/255^(1/2.2). pngstest now uses 15 for the
|
||||
permitted 8-bit error. This may still not be enough because of arithmetic
|
||||
error.
|
||||
Removed some unused arrays (with #ifdef) from png_read_push_finish_row().
|
||||
Fixed a memory overwrite bug in simplified read of RGB PNG with
|
||||
non-linear gamma Also bugs in the error checking in pngread.c and changed
|
||||
quite a lot of the checks in pngstest.c to be correct; either correctly
|
||||
written or not over-optimistic. The pngstest changes are insufficient to
|
||||
allow all possible RGB transforms to be passed; pngstest cmppixel needs
|
||||
to be rewritten to make it clearer which errors it allows and then changed
|
||||
to permit known inaccuracies.
|
||||
Removed tests for no-longer-used *_EMPTY_PLTE_SUPPORTED from pngstruct.h
|
||||
Fixed fixed/float API export conditionals. 1) If FIXED_POINT or
|
||||
FLOATING_POINT options were switched off, png.h ended up with lone ';'
|
||||
characters. This is not valid ANSI-C outside a function. The ';'
|
||||
characters have been moved inside the definition of PNG_FP_EXPORT and
|
||||
PNG_FIXED_EXPORT. 2) If either option was switched off, the declaration
|
||||
of the corresponding functions were completely omitted, even though some
|
||||
of them are still used internally. The result is still valid, but
|
||||
produces warnings from gcc with some warning options (including -Wall). The
|
||||
fix is to cause png.h to declare the functions with PNG_INTERNAL_FUNCTION
|
||||
when png.h is included from pngpriv.h.
|
||||
Check for invalid palette index while reading paletted PNG. When one is
|
||||
found, issue a warning and increase png_ptr->num_palette accordingly.
|
||||
Apps are responsible for checking to see if that happened.
|
||||
Version 1.7.0beta01 [February 15, 2013]
|
||||
Enable parallel tests and rearrange TESTS order to take advantage of
|
||||
the massive speed improvements use a make capable of parallel builds
|
||||
on a multi-CPU machine and pass the right arguments to make (-j10000
|
||||
for GNU make) to get the build to run in parallel.
|
||||
Fixed previous support for Z_PREFIX in configure builds, corrected
|
||||
sCAL APIs; some of these use floating point arithmetic so need to be
|
||||
disabled if floating point arithmetic is switched off. This is a quiet API
|
||||
change - previously it appeared that the APIs were supported if fixed point
|
||||
arithmetic was used internally, however they required certain APIs (floor,
|
||||
modf, frexp, atof) that are part of C floating point support. Changed
|
||||
png_fixed and the gamma code specific version of the same to avoid floor(),
|
||||
which may be a library function (not an intrinsic). Removed unused #if 0
|
||||
code.
|
||||
Fixed make distcheck to skip over the test result files. They were
|
||||
being included because the whole of the 'tests' directory is included,
|
||||
fixed to just include the actual test files and tests/pngstest. Also
|
||||
reverted the previous erroneous change to remove the ${srcdir} from the
|
||||
front of contrib, scripts, projects and added an explanation of what is
|
||||
going on to Makefile.am
|
||||
Fixed missing dependency in --prefix builds. The intermediate
|
||||
internal 'prefix.h' file can only be generated correctly after pnglibconf.h,
|
||||
however the dependency was not in Makefile.am. The symptoms are
|
||||
unpredictable depending on the order make chooses to build pngprefix.h and
|
||||
pnglibconf.h, often the error goes unnoticed because there is a system
|
||||
pnglibconf.h to use instead.
|
||||
Accept "," as a separator in pnglibconf.dfa and allow for
|
||||
continuation lines. This adds to the syntax of "option" and "chunk" lines,
|
||||
allowing the elements to be separated by a "," at the end of an element and
|
||||
interpreting a "," at end of line as a continuation - so the following line
|
||||
is read. The new syntax is optional and solely provided for readability.
|
||||
Enclosed the new png_get_palette_max in #ifdef PNG_GET_PALETTE_MAX_SUPPORTED
|
||||
block, and revised pnglibconf.h and pnglibconf.h.prebuilt accordingly.
|
||||
|
||||
Version 1.6.0beta12 [February 18, 2012]
|
||||
Do not increase num_palette on invalid_index.
|
||||
Relocated check for invalid palette index to pngrtran.c, after unpacking
|
||||
the sub-8-bit pixels.
|
||||
Fixed CVE-2011-3026 buffer overrun bug. Deal more correctly with the test
|
||||
on iCCP chunk length. Also removed spurious casts that may hide problems
|
||||
on 16-bit systems.
|
||||
Version 1.7.0beta02 [February 18, 2013]
|
||||
Fixed a race condition in the creation of the build 'scripts' directory
|
||||
while building with a parallel make.
|
||||
Use approved/supported Android method to check for NEON, use Linux/POSIX
|
||||
1003.1 API to check /proc/self/auxv avoiding buffer allocation and other
|
||||
library calls (ported from libpng15).
|
||||
Use parentheses more consistently in "#if defined(MACRO)" tests.
|
||||
Folded long lines.
|
||||
|
||||
Version 1.6.0beta13 [February 24, 2012]
|
||||
Eliminated redundant png_push_read_tEXt|zTXt|iTXt|unknown code from
|
||||
pngpread.c and use the sequential png_handle_tEXt, etc., in pngrutil.c;
|
||||
now that png_ptr->buffer is inaccessible to applications, the special
|
||||
handling is no longer useful.
|
||||
Added PNG_SAFE_LIMITS feature to pnglibconf.dfa, pngpriv.h, and new
|
||||
pngusr.dfa to reset the user limits to safe ones if PNG_SAFE_LIMITS is
|
||||
defined. To enable, use "CPPFLAGS=-DPNG_SAFE_LIMITS_SUPPORTED=1" on the
|
||||
configure command or put #define PNG_SAFE_LIMITS_SUPPORTED in
|
||||
pnglibconf.h.prebuilt and pnglibconf.h.
|
||||
Version 1.7.0beta03 [February 22, 2013]
|
||||
Reenabled code to allow zero length PLTE chunks for MNG.
|
||||
Fixed ALIGNED_MEMORY support.
|
||||
Allow run-time ARM NEON checking to be disabled. A new configure option:
|
||||
--enable-arm-neon=always will stop the run-time checks. New checks
|
||||
within arm/arm_init.c will cause the code not to be compiled unless
|
||||
__ARM_NEON__ is set. This should make it fail safe (if someone asks
|
||||
for it on then the build will fail if it can't be done.)
|
||||
Updated the INSTALL document.
|
||||
|
||||
Version 1.6.0beta14 [February 27, 2012]
|
||||
Added information about the new limits in the manual.
|
||||
Updated Makefile.in
|
||||
Version 1.7.0beta04 [February 27, 2013]
|
||||
Revised INSTALL to recommend using CPPFLAGS instead of INCLUDES.
|
||||
Revised scripts/makefile.freebsd to respect ZLIBLIB and ZLIBINC.
|
||||
Revised scripts/dfn.awk to work with the buggy MSYS awk that has trouble
|
||||
with CRLF line endings.
|
||||
|
||||
Version 1.6.0beta15 [March 2, 2012]
|
||||
Removed unused "current_text" members of png_struct and the png_free()
|
||||
of png_ptr->current_text from pngread.c
|
||||
Rewrote pngstest.c for substantial speed improvement.
|
||||
Fixed transparent pixel and 16-bit rgb tests in pngstest and removed a
|
||||
spurious check in pngwrite.c
|
||||
Added PNG_IMAGE_FLAG_FAST for the benefit of applications that store
|
||||
intermediate files, or intermediate in-memory data, while processing
|
||||
image data with the simplified API. The option makes the files larger
|
||||
but faster to write and read. pngstest now uses this by default; this
|
||||
can be disabled with the --slow option.
|
||||
Improved pngstest fine tuning of error numbers, new test file generator.
|
||||
The generator generates images that test the full range of sample values,
|
||||
allow the error numbers in pngstest to be tuned and checked. makepng
|
||||
also allows generation of images with extra chunks, although this is
|
||||
still work-in-progress.
|
||||
Added tests for invalid palette index while reading and writing (work in
|
||||
progress, the latter isn't finished).
|
||||
Fixed some bugs in ICC profile writing. The code should now accept
|
||||
all potentially valid ICC profiles and reject obviously invalid ones.
|
||||
It now uses png_error() to do so rather than casually writing a PNG
|
||||
without the necessary color data.
|
||||
Removed whitespace from the end of lines in all source files and scripts.
|
||||
Version 1.7.0beta05 [March 5, 2013]
|
||||
Avoid a possible memory leak in contrib/gregbook/readpng.c
|
||||
Changed user chunk callback API to respect global and per chunk defaults.
|
||||
Previously a return of 0 from a user chunk callback would result in the
|
||||
chunk being saved (if this was safe, even if the chunk was unsafe-to-copy);
|
||||
this change respects the defaults set by the application, so unknown chunks
|
||||
can be discarded by default and known-safe ones preserved.
|
||||
Corrected Android builds and corrected libpng.vers with symbol
|
||||
prefixing. This adds an API to set optimization options externally,
|
||||
providing an alternative and general solution for the non-portable
|
||||
run-time tests used by the ARM Neon code. It also makes those tests
|
||||
compile and link on Android. The order of settings vs options in
|
||||
pnglibconf.h is reversed to allow settings to depend on options and
|
||||
options can now set (or override) the defaults for settings.
|
||||
|
||||
Version 1.6.0beta16 [March 6, 2012]
|
||||
Relocated palette-index checking function from pngrutil.c to pngtrans.c
|
||||
Added palette-index checking while writing.
|
||||
Changed png_inflate() and calling routines to avoid overflow problems.
|
||||
This is an intermediate check-in that solves the immediate problems and
|
||||
introduces one performance improvement (avoiding a copy via png_ptr->zbuf.)
|
||||
Further changes will be made to make ICC profile handling more secure.
|
||||
Fixed build warnings (MSVC, GCC, GCC v3). Cygwin GCC with default options
|
||||
declares 'index' as a global, causing a warning if it is used as a local
|
||||
variable. GCC 64-bit warns about assigning a (size_t) (unsigned 64-bit)
|
||||
to an (int) (signed 32-bit). MSVC, however, warns about using the
|
||||
unary '-' operator on an unsigned value (even though it is well defined
|
||||
by ANSI-C to be ~x+1). The padding calculation was changed to use a
|
||||
different method. Removed the tests on png_ptr->pass.
|
||||
Added contrib/libtests/tarith.c to test internal arithmetic functions from
|
||||
png.c. This is a libpng maintainer program used to validate changes to the
|
||||
internal arithmetic functions.
|
||||
Made read 'inflate' handling like write 'deflate' handling. The read
|
||||
code now claims and releases png_ptr->zstream, like the write code.
|
||||
The bug whereby the progressive reader failed to release the zstream
|
||||
is now fixed, all initialization is delayed, and the code checks for
|
||||
changed parameters on deflate rather than always calling
|
||||
deflatedEnd/deflateInit.
|
||||
Validate the zTXt strings in pngvalid.
|
||||
Added code to validate the windowBits value passed to deflateInit2().
|
||||
If the call to deflateInit2() is wrong a png_warning will be issued
|
||||
(in fact this is harmless, but the PNG data produced may be sub-optimal).
|
||||
Version 1.7.0beta06 [March 13, 2013]
|
||||
Corrected simplified API default gamma for color-mapped output, added
|
||||
a flag to change default. In 1.6.0 when the simplified API was used
|
||||
to produce color-mapped output from an input image with no gamma
|
||||
information the gamma assumed for the input could be different from
|
||||
that assumed for non-color-mapped output. In particular 16-bit depth
|
||||
input files were assumed to be sRGB encoded, whereas in the 'direct'
|
||||
case they were assumed to have linear data. This was an error. The
|
||||
fix makes the simplified API treat all input files the same way and
|
||||
adds a new flag to the png_image::flags member to allow the
|
||||
application/user to specify that 16-bit files contain sRGB data
|
||||
rather than the default linear.
|
||||
Fixed bugs in the pngpixel and makepng test programs.
|
||||
Fixed CMakelists.txt to allow building a single variant of the library
|
||||
(Claudio Bley):
|
||||
Introduced a PNG_LIB_TARGETS variable that lists all activated library
|
||||
targets. It is an error if this variable ends up empty, ie. you have
|
||||
to build at least one library variant.
|
||||
Made the *_COPY targets only depend on library targets actually being build.
|
||||
Use PNG_LIB_TARGETS to unify a code path.
|
||||
Changed the CREATE_SYMLINK macro to expect the full path to a file as the
|
||||
first argument. When symlinking the filename component of that path is
|
||||
determined and used as the link target.
|
||||
Use copy_if_different in the CREATE_SYMLINK macro.
|
||||
Eliminated two warnings from the Intel C compiler. The warnings are
|
||||
technically valid, although a reasonable treatment of division would
|
||||
show it to be incorrect.
|
||||
|
||||
Version 1.6.0beta17 [March 10, 2012]
|
||||
Fixed PNG_LIBPNG_BUILD_BASE_TYPE definition.
|
||||
Reject all iCCP chunks after the first, even if the first one is invalid.
|
||||
Deflate/inflate was reworked to move common zlib calls into single
|
||||
functions [rw]util.c. A new shared keyword check routine was also added
|
||||
and the 'zbuf' is no longer allocated on progressive read. It is now
|
||||
possible to call png_inflate() incrementally.
|
||||
If benign errors are disabled use maximum window on ancilliary inflate.
|
||||
This works round a bug introduced in 1.5.4 where compressed ancillary
|
||||
chunks could end up with a too-small windowBits value in the deflate
|
||||
header.
|
||||
Version 1.7.0beta07 [April 14, 2013]
|
||||
Updated documentation of 1.5.x to 1.6.x changes in iCCP chunk handling.
|
||||
Fixed incorrect warning of excess deflate data. End condition - the
|
||||
warning would be produced if the end of the deflate stream wasn't read
|
||||
in the last row. The warning is harmless.
|
||||
Corrected the test on user transform changes on read. It was in the
|
||||
png_set of the transform function, but that doesn't matter unless the
|
||||
transform function changes the rowbuf size, and that is only valid if
|
||||
transform_info is called.
|
||||
Corrected a misplaced closing bracket in contrib/libtests/pngvalid.c
|
||||
(Flavio Medeiros).
|
||||
Corrected length written to uncompressed iTXt chunks (Samuli Suominen).
|
||||
|
||||
Version 1.6.0beta18 [March 16, 2012]
|
||||
Issue a png_benign_error() instead of png_warning() about bad palette index.
|
||||
In pngtest, treat benign errors as errors if "-strict" is present.
|
||||
Fixed an off-by-one error in the palette index checking function.
|
||||
Fixed a compiler warning under Cygwin (Windows-7, 32-bit system)
|
||||
Revised example.c to put text strings in a temporary character array
|
||||
instead of directly assigning string constants to png_textp members.
|
||||
This avoids compiler warnings when -Wwrite-strings is enabled.
|
||||
Added output flushing to aid debugging under Visual Studio. Unfortunately
|
||||
this is necessary because the VS2010 output window otherwise simply loses
|
||||
the error messages on error (they weren't flushed to the window before
|
||||
the process exited, apparently!)
|
||||
Added configuration support for benign errors and changed the read
|
||||
default. Also changed some warnings in the iCCP and sRGB handling
|
||||
from to benign errors. Configuration now makes read benign
|
||||
errors warnings and write benign errors to errors by default (thus
|
||||
changing the behavior on read). The simplified API always forces
|
||||
read benign errors to warnings (regardless of the system default, unless
|
||||
this is disabled in which case the simplified API can't be built.)
|
||||
Version 1.7.0beta08 [April 18, 2013]
|
||||
Added contrib/tools/fixitxt.c, to repair the erroneous iTXt chunk length
|
||||
written by libpng-1.6.0 and 1.6.1.
|
||||
Disallow storing sRGB information when the sRGB is not supported.
|
||||
|
||||
Version 1.6.0beta19 [March 18,2012]
|
||||
Work around for duplicate row start calls; added warning messages.
|
||||
This turns on PNG_FLAG_DETECT_UNINITIALIZED to detect app code that
|
||||
fails to call one of the 'start' routines (not enabled in libpng-1.5
|
||||
because it is technically an API change, since it did normally work
|
||||
before.) It also makes duplicate calls to png_read_start_row (an
|
||||
internal function called at the start of the image read) benign, as
|
||||
they were before changes to use png_inflate_claim. Somehow webkit is
|
||||
causing this to happen; this is probably a mis-feature in the zlib
|
||||
changes so this commit is only a work-round.
|
||||
Removed erroneous setting of DETECT_UNINITIALIZED and added more
|
||||
checks. The code now does a png_error if an attempt is made to do the
|
||||
row initialization twice; this is an application error and it has
|
||||
serious consequences because the transform data in png_struct is
|
||||
changed by each call.
|
||||
Added application error reporting and added chunk names to read
|
||||
benign errors; also added --strict to pngstest - not enabled
|
||||
yet because a warning is produced.
|
||||
Avoid the double gamma correction warning in the simplified API.
|
||||
This allows the --strict option to pass in the pngstest checks
|
||||
Version 1.7.0beta09 [April 24, 2013]
|
||||
Exposed PNG chunk types in png.h
|
||||
Modified png_uint_32 macros/code to make as few assumptions as possible
|
||||
Revised stack marking in arm/filter_neon.S and configure.ac
|
||||
Ensure that NEON filter stuff is completely disabled when switched 'off'.
|
||||
Previously the ARM NEON specific files were still built if the option
|
||||
was switched 'off' as opposed to being explicitly disabled.
|
||||
|
||||
Version 1.6.0beta20 [March 29, 2012]
|
||||
Changed chunk handler warnings into benign errors, incrementally load iCCP
|
||||
Added checksum-icc.c to contrib/tools
|
||||
Prevent PNG_EXPAND+PNG_SHIFT doing the shift twice.
|
||||
Recognize known sRGB ICC profiles while reading; prefer writing the
|
||||
iCCP profile over writing the sRGB chunk, controlled by the
|
||||
PNG_sRGB_PROFILE_CHECKS option.
|
||||
Revised png_set_text_2() to avoid potential memory corruption (fixes
|
||||
CVE-2011-3048, also known as CVE-2012-3425).
|
||||
Version 1.7.0beta10 [April 24, 2013]
|
||||
Attempt to fix the PNG_ARM_NEON configuration mess.
|
||||
|
||||
Version 1.6.0beta21 [April 27, 2012]
|
||||
Revised scripts/makefile.darwin: use system zlib; remove quotes around
|
||||
architecture list; add missing ppc architecture; add architecture options
|
||||
to shared library link; don't try to create a shared lib based on missing
|
||||
RELEASE variable.
|
||||
Enable png_set_check_for_invalid_index() for both read and write.
|
||||
Removed #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED in pngpriv.h around
|
||||
declaration of png_handle_unknown().
|
||||
Added -lssp_nonshared in a comment in scripts/makefile.freebsd
|
||||
and changed deprecated NOOBJ and NOPROFILE to NO_OBJ and NO_PROFILE.
|
||||
Version 1.7.0beta11 [April 26, 2013]
|
||||
Test for 'arm*', not just 'arm' in the host_cpu configure variable.
|
||||
|
||||
Version 1.6.0beta22 [May 23, 2012]
|
||||
Removed need for -Wno-cast-align with clang. clang correctly warns on
|
||||
alignment increasing pointer casts when -Wcast-align is passed. This
|
||||
fixes the cases that clang warns about either by eliminating the
|
||||
casts from png_bytep to png_uint_16p (pngread.c), or, for pngrutil.c
|
||||
where the cast is previously verified or pngstest.c where it is OK, by
|
||||
introducing new png_aligncast macros to do the cast in a way that clang
|
||||
accepts.
|
||||
Version 1.7.0beta12 [April 30, 2013]
|
||||
Added png_app_warning for out-of-range unknown chunk index in
|
||||
png_set_unknown_chunk_location().
|
||||
Expanded manual paragraph about writing private chunks.
|
||||
Avoid dereferencing NULL pointer possibly returned from
|
||||
png_create_write_struct() (Andrew Church).
|
||||
|
||||
Version 1.6.0beta23 [June 6, 2012]
|
||||
Revised CMakeLists.txt to not attempt to make a symlink under mingw.
|
||||
Made fixes for new optimization warnings from gcc 4.7.0. The compiler
|
||||
performs an optimization which is safe; however it then warns about it.
|
||||
Changing the type of 'palette_number' in pngvalid.c removes the warning.
|
||||
Do not depend upon a GCC feature macro being available for use in generating
|
||||
the linker mapfile symbol prefix.
|
||||
Improved performance of new do_check_palette_indexes() function (only
|
||||
update the value when it actually increases, move test for whether
|
||||
the check is wanted out of the function.
|
||||
Version 1.7.0beta13 [May 12, 2013]
|
||||
Revised contrib/pngminim/*/makefile to generate pnglibconf.h with the
|
||||
right zlib header files.
|
||||
Separated CPPFLAGS and CFLAGS in contrib/pngminim/*/makefile
|
||||
Updated contrib/pngminus/pnm2png.c (Paul Stewart):
|
||||
Check for EOF
|
||||
Ignore "#" delimited comments in input file to pnm2png.c.
|
||||
Fixed whitespace handling
|
||||
Added a call to png_set_packing()
|
||||
Initialize dimension values so if sscanf fails at least we have known
|
||||
invalid values.
|
||||
Calculate our own zlib windowBits when decoding rather than trusting the
|
||||
CMF bytes in the PNG datastream.
|
||||
Added an option to force maximum window size for inflating, which was
|
||||
the behavior of libpng15 and earlier.
|
||||
Added png-fix-itxt and png-fix-too-far-back to the built programs and
|
||||
removed warnings from the source code and timepng that are revealed as
|
||||
a result.
|
||||
Detect wrong libpng versions linked to png-fix-too-far-back, which currently
|
||||
only works with libpng versions that can be made to reliably fail when
|
||||
the deflate data contains an out-of-window reference. This means only
|
||||
1.6 and later.
|
||||
Attempt to detect configuration issues with png-fix-too-far-back, which
|
||||
requires both the correct libpng and the correct zlib to function
|
||||
correctly.
|
||||
Check ZLIB_VERNUM for mismatches, enclose #error in quotes
|
||||
Added information in the documentation about problems with and fixes for
|
||||
the bad CRC and bad iTXt chunk situations.
|
||||
|
||||
Version 1.6.0beta24 [June 7, 2012]
|
||||
Don't check palette indexes if num_palette is 0 (as it can be in MNG files).
|
||||
Version 1.7.0beta14 [June 8, 2013]
|
||||
Removed a redundant test in png_set_IHDR().
|
||||
Added set(CMAKE_CONFIGURATION_TYPES ...) to CMakeLists.txt (Andrew Hundt)
|
||||
Deleted set(CMAKE_BUILD_TYPE) block from CMakeLists.txt
|
||||
Enclose the prototypes for the simplified write API in #ifdef STDIO/#endif
|
||||
Make ARM NEON support work at compile time (not just configure time).
|
||||
This moves the test on __ARM_NEON__ into pngconf.h to avoid issues when
|
||||
using a compiler that compiles for multiple architectures at one time.
|
||||
Removed PNG_FILTER_OPTIMIZATIONS and PNG_ARM_NEON_SUPPORTED from
|
||||
pnglibconf.h, allowing more of the decisions to be made internally
|
||||
(pngpriv.h) during the compile. Without this, symbol prefixing is broken
|
||||
under certain circumstances on ARM platforms. Now only the API parts of
|
||||
the optimizations ('check' vs 'api') are exposed in the public header files
|
||||
except that the new setting PNG_ARM_NEON_OPT documents how libpng makes the
|
||||
decision about whether or not to use the optimizations.
|
||||
Protect symbol prefixing against CC/CPPFLAGS/CFLAGS useage.
|
||||
Previous iOS/Xcode fixes for the ARM NEON optimizations moved the test
|
||||
on __ARM_NEON__ from configure time to compile time. This breaks symbol
|
||||
prefixing because the definition of the special png_init_filter_functions
|
||||
call was hidden at configure time if the relevant compiler arguments are
|
||||
passed in CFLAGS as opposed to CC. This change attempts to avoid all
|
||||
the confusion that would result by declaring the init function even when
|
||||
it is not used, so that it will always get prefixed.
|
||||
|
||||
Version 1.6.0beta25 [June 16, 2012]
|
||||
Revised png_set_keep_unknown_chunks() so num_chunks < 0 means ignore all
|
||||
unknown chunks and all known chunks except for IHDR, PLTE, tRNS, IDAT,
|
||||
and IEND. Previously it only meant ignore all unknown chunks, the
|
||||
same as num_chunks == 0. Revised png_image_skip_unused_chunks() to
|
||||
provide a list of chunks to be processed instead of a list of chunks to
|
||||
ignore. Revised contrib/gregbook/readpng2.c accordingly.
|
||||
|
||||
Version 1.6.0beta26 [July 10, 2012]
|
||||
Removed scripts/makefile.cegcc from the *.zip and *.7z distributions; it
|
||||
depends on configure, which is not included in those archives.
|
||||
Moved scripts/chkfmt to contrib/tools.
|
||||
Changed "a+w" to "u+w" in Makefile.in to fix CVE-2012-3386.
|
||||
|
||||
Version 1.6.0beta27 [August 11, 2012]
|
||||
Do not compile PNG_DEPRECATED, PNG_ALLOC and PNG_PRIVATE when __GNUC__ < 3.
|
||||
Do not use __restrict when GNUC is <= 3.1
|
||||
Removed references to png_zalloc() and png_zfree() from the manual.
|
||||
Fixed configurations where floating point is completely disabled. Because
|
||||
of the changes to support symbol prefixing PNG_INTERNAL_FUNCTION declares
|
||||
floating point APIs during libpng builds even if they are completely
|
||||
disabled. This requires the png floating point types (png_double*) to be
|
||||
declared even though the functions are never actually defined. This
|
||||
change provides a dummy definition so that the declarations work, yet any
|
||||
implementation will fail to compile because of an incomplete type.
|
||||
Re-eliminated the use of strcpy() in pngtest.c. An unncessary use of
|
||||
strcpy() was accidentally re-introduced in libpng16; this change replaces
|
||||
it with strncpy().
|
||||
Eliminated use of png_sizeof(); use sizeof() instead.
|
||||
Use a consistent style for (sizeof type) and (sizeof (array))
|
||||
Cleanup of png_set_filler(). This function does very different things on
|
||||
read and write. In libpng 1.6 the two cases can be distinguished and
|
||||
considerable code cleanup, and extra error checking, is possible. This
|
||||
makes calls on the write side that have no effect be ignored with a
|
||||
png_app_error(), which can be disabled in the app using
|
||||
png_set_benign_errors(), and removes the spurious use of usr_channels
|
||||
on the read side.
|
||||
Insist on autotools 1.12.1 for git builds because there are security issues
|
||||
with 1.12 and insisting on anything less would allow 1.12 to be used.
|
||||
Removed info_ptr->signature[8] from WRITE-only builds.
|
||||
Add some conditions for compiling png_fixed(). This is a small function
|
||||
but it requires "-lm" on some platforms.
|
||||
Cause pngtest --strict to fail on any warning from libpng (not just errors)
|
||||
and cause it not to fail at the comparison step if libpng lacks support
|
||||
for writing chunks that it reads from the input (currently only implemented
|
||||
for compressed text chunks).
|
||||
Make all three "make check" test programs work without READ or WRITE support.
|
||||
Now "make check" will succeed even if libpng is compiled with -DPNG_NO_READ
|
||||
or -DPNG_NO_WRITE. The tests performed are reduced, but the basic reading
|
||||
and writing of a PNG file is always tested by one or more of the tests.
|
||||
Consistently use strlen(), memset(), memcpy(), and memcmp() instead of the
|
||||
png_strlen(), png_memset(), png_memcpy(), and png_memcmp() macros.
|
||||
Removed the png_sizeof(), png_strlen(), png_memset(), png_memcpy(), and
|
||||
png_memcmp() macros.
|
||||
Work around gcc 3.x and Microsoft Visual Studio 2010 complaints. Both object
|
||||
to the split initialization of num_chunks.
|
||||
|
||||
Version 1.6.0beta28 [August 29, 2012]
|
||||
Unknown handling fixes and clean up. This adds more correct option
|
||||
control of the unknown handling, corrects the pre-existing bug where
|
||||
the per-chunk 'keep' setting is ignored and makes it possible to skip
|
||||
IDAT chunks in the sequential reader (broken in earlier 1.6 versions).
|
||||
There is a new test program, test-unknown.c, which is a work in progress
|
||||
(not currently part of the test suite). Comments in the header files now
|
||||
explain how the unknown handling works.
|
||||
Allow fine grain control of unknown chunk APIs. This change allows
|
||||
png_set_keep_unknown_chunks() to be turned off if not required and causes
|
||||
both read and write to behave appropriately (on read this is only possible
|
||||
if the user callback is used to handle unknown chunks). The change
|
||||
also removes the support for storing unknown chunks in the info_struct
|
||||
if the only unknown handling enabled is via the callback, allowing libpng
|
||||
to be configured with callback reading and none of the unnecessary code.
|
||||
Corrected fix for unknown handling in pngtest. This reinstates the
|
||||
libpng handling of unknown chunks other than vpAg and sTER (including
|
||||
unsafe-to-copy chunks which were dropped before) and eliminates the
|
||||
repositioning of vpAg and sTER in pngtest.png by changing pngtest.png
|
||||
(so the chunks are where libpng would put them).
|
||||
Added "tunknown" test and corrected a logic error in png_handle_unknown()
|
||||
when SAVE support is absent. Moved the shell test scripts for
|
||||
contrib/libtests from the libpng top directory to contrib/libtests.
|
||||
png_handle_unknown() must always read or skip the chunk, if
|
||||
SAVE_UNKNOWN_CHUNKS is turned off *and* the application does not set
|
||||
a user callback an unknown chunk will not be read, leading to a read
|
||||
error, which was revealed by the "tunknown" test.
|
||||
Cleaned up and corrected ICC profile handling.
|
||||
contrib/libtests/makepng: corrected 'rgb' and 'gray' cases. profile_error
|
||||
messages could be truncated; made a correct buffer size calculation and
|
||||
adjusted pngerror.c appropriately. png_icc_check_* checking improved;
|
||||
changed the functions to receive the correct color type of the PNG on read
|
||||
or write and check that it matches the color space of the profile (despite
|
||||
what the comments said before, there is danger in assuming the app will
|
||||
cope correctly with an RGB profile on a grayscale image and, since it
|
||||
violates the PNG spec, allowing it is certain to produce inconsistent
|
||||
app behavior and might even cause app crashes.) Check that profiles
|
||||
contain the tags needed to process the PNG (tags all required by the ICC
|
||||
spec). Removed unused PNG_STATIC from pngpriv.h.
|
||||
|
||||
Version 1.6.0beta29 [September 4, 2012]
|
||||
Fixed the simplified API example programs and improved the error message
|
||||
if the version field is not set.
|
||||
Added contrib/examples/* to the *.zip and *.7z distributions.
|
||||
Updated simplified API synopses and description of the png_image structure
|
||||
in the manual.
|
||||
Made makepng and pngtest produce identical PNGs, add "--relaxed" option
|
||||
to pngtest. The "--relaxed" option turns off the benign errors that are
|
||||
enabled by default in pre-RC builds. makepng can now write ICC profiles
|
||||
where the length has not been extended to a multiple of 4, and pngtest
|
||||
now intercepts all libpng errors, allowing the previously-introduced
|
||||
"--strict test" on no warnings to actually work.
|
||||
Improved ICC profile handling including cHRM chunk generation and fixed
|
||||
Cygwin+MSVC build errors. The ICC profile handling now includes more
|
||||
checking. Several errors that caused rejection of the profile are now
|
||||
handled with a warning in such a way that the invalid profiles will be
|
||||
read by default in release (but not pre-RC) builds but will not be
|
||||
written by default. The easy part of handling the cHRM chunk is written,
|
||||
where the ICC profile contains the required data. The more difficult
|
||||
part plus guessing a gAMA value requires code to pass selected RGB values
|
||||
through the profile.
|
||||
|
||||
Version 1.6.0beta30 [October 24, 2012]
|
||||
Changed ICC profile matrix/vector types to not depend on array type rules.
|
||||
By the ANSI-C standard the new types should be identical to the previous
|
||||
versions, and all known versions of gcc tested with the previous versions
|
||||
except for GCC-4.2.1 work with this version. The change makes the ANSI-C
|
||||
rule that const applied to an array of elements applies instead to the
|
||||
elements in the array moot by explicitly applying const to the base
|
||||
elements of the png_icc_matrix and png_icc_vector types. The accidental
|
||||
(harmless) 'const' previously applied to the parameters of two of the
|
||||
functions have also been removed.
|
||||
Added a work around for GCC 4.2 optimization bug.
|
||||
Marked the broken (bad white point) original HP sRGB profiles correctly and
|
||||
correct comments.
|
||||
Added -DZ_SOLO to contrib/pngminim/*/makefile to work with zlib-1.2.7
|
||||
Use /MDd for vstudio debug builds. Also added pngunkown to the vstudio
|
||||
builds, fixed build errors and corrected a minor exit code error in
|
||||
pngvalid if the 'touch' file name is invalid.
|
||||
Add updated WARNING file to projects/vstudio from libpng 1.5/vstudio
|
||||
Fixed build when using #define PNG_NO_READ_GAMMA in png_do_compose() in
|
||||
pngrtran.c (Domani Hannes).
|
||||
|
||||
Version 1.6.0beta31 [November 1, 2012]
|
||||
Undid the erroneous change to vstudio/pngvalid build in libpng-1.6.0beta30.
|
||||
Made pngvalid so that it will build outside the libpng source tree.
|
||||
Made builds -DPNG_NO_READ_GAMMA compile (the unit tests still fail).
|
||||
Made PNG_NO_READ_GAMMA switch off interfaces that depend on READ_GAMMA.
|
||||
Prior to 1.6.0 switching off READ_GAMMA did unpredictable things to the
|
||||
interfaces that use it (specifically, png_do_background in 1.4 would
|
||||
simply display composite for grayscale images but do composition
|
||||
with the incorrect arithmetic for color ones). In 1.6 the semantic
|
||||
of -DPNG_NO_READ_GAMMA is changed to simply disable any interface that
|
||||
depends on it; this obliges people who set it to consider whether they
|
||||
really want it off if they happen to use any of the interfaces in
|
||||
question (typically most users who disable it won't).
|
||||
Fixed GUIDs in projects/vstudio. Some were duplicated or missing,
|
||||
resulting in VS2010 having to update the files.
|
||||
Removed non-working ICC profile support code that was mostly added to
|
||||
libpng-1.6.0beta29 and beta30. There was too much code for too little
|
||||
gain; implementing full ICC color correction may be desireable but is left
|
||||
up to applications.
|
||||
|
||||
Version 1.6.0beta32 [November 25, 2012]
|
||||
Fixed an intermittent SEGV in pngstest due to an uninitialized array element.
|
||||
Added the ability for contrib/libtests/makepng.c to make a PNG with just one
|
||||
color. This is useful for debugging pngstest color inaccuracy reports.
|
||||
Fixed error checking in the simplified write API (Olaf van der Spek)
|
||||
Made png_user_version_check() ok to use with libpng version 1.10.x and later.
|
||||
|
||||
Version 1.6.0beta33 [December 10, 2012]
|
||||
Fixed typo in png.c (PNG_SET_CHUNK_MALLOC_MAX should be PNG_CHUNK_MALLOC_MAX)
|
||||
that causes the MALLOC_MAX limit not to work (John Bowler)
|
||||
Change png_warning() to png_app_error() in pngwrite.c and comment the
|
||||
fall-through condition.
|
||||
Change png_warning() to png_app_warning() in png_write_tRNS().
|
||||
Version 1.7.0beta15 [June 18, 2013]
|
||||
Revised libpng.3 so that "doclift" can process it.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
|
||||
310
CHANGES
310
CHANGES
@@ -3672,7 +3672,8 @@ Version 1.5.6 [November 3, 2011]
|
||||
No changes.
|
||||
|
||||
Version 1.5.7beta01 [November 4, 2011]
|
||||
Added support for ARM processor (Mans Rullgard)
|
||||
Added support for ARM processor, when decoding all PNG up-filtered rows
|
||||
and any other-filtered rows with 3 or 4 bytes per pixel (Mans Rullgard).
|
||||
Fixed bug in pngvalid on early allocation failure; fixed type cast in
|
||||
pngmem.c; pngvalid would attempt to call png_error() if the allocation
|
||||
of a png_struct or png_info failed. This would probably have led to a
|
||||
@@ -4311,6 +4312,313 @@ Version 1.6.0beta33 [December 10, 2012]
|
||||
fall-through condition.
|
||||
Change png_warning() to png_app_warning() in png_write_tRNS().
|
||||
|
||||
Version 1.7.0alpha01 [December 15, 2012]
|
||||
Started 1.7.0 branch from libpng-1.6.0beta33.
|
||||
Made 8-bit compose and rgb_to_grayscale accuracy improvements. These
|
||||
changes cause 16-bit arithmetic to be used for 8-bit data in the gamma
|
||||
corrected compose and grayscale operations. The arithmetic errors have
|
||||
three sources all of which are fixed in this commit:
|
||||
1) 8-bit linear calculations produce massive errors for lower intensity
|
||||
values.
|
||||
2) The old 16-bit "16 to 8" gamma table code erroneously wrote the lowest
|
||||
output value into a table entry which corresponded to multiple output
|
||||
values (so where the value written should have been the closest to the
|
||||
transformed input value.)
|
||||
3) In a number of cases the code to access the 16-bit table did not round;
|
||||
it did a simple shift, which was wrong and made the side effects of (2)
|
||||
even worse.
|
||||
The new gamma code does not have the 16-to-8 problem at the cost of slightly
|
||||
more calculations and the algorithm used to minimize the number of
|
||||
calculations has been extended to all the 16-bit tables; it has advantages
|
||||
for any significant gamma correction.
|
||||
Rearranged png_struct, remove unused members, change png_set_filter handling
|
||||
png_struct members rearranged - partly to reorder to avoid packing, partly
|
||||
to put frequently accessed members at the start and partly to make
|
||||
the grouping more clear. png_set_filter code has been rewritten and the
|
||||
code shared with png_write_start_row moved to a common function. Comments
|
||||
in png.h have been made more clear. Minor fixes to
|
||||
contrib/libtests/timepng.c and some of the png_*_tRNS logic, including
|
||||
more error detection in png_set_tRNS.
|
||||
Cleaned up USER_LIMITS feature, removing members from png_struct when not
|
||||
required.
|
||||
Rearranged ARM-NEON optimizations to isolate the machine specific code to
|
||||
the hardware subdirectory, and add comments to pngrutil.c so that
|
||||
implementors of other optimizations will know what to do.
|
||||
Fixed cases of unquoted DESTDIR in Makefile.am.
|
||||
Rebuilt Makefile.in, configure, etc., with autoconf-2.69 and automake-1.12.5.
|
||||
|
||||
Version 1.7.0alpha02 [December 17, 2012]
|
||||
Removed functions that were deprecated in libpng-1.6.0:
|
||||
png_reset_zstream(), png_info_init_3(), png_data_freer() and its
|
||||
associated flags, png_malloc_default, and png_free_default.
|
||||
Removed some duplicated lines from contrib/tools/scale.c and png.c.
|
||||
Changed some instances of png_warning() to png_app_error().
|
||||
Updated some left over "1.6.0beta32" in code sources.
|
||||
Fixed a "png_structp" prototype (should be png_structrp) in arm_init.c
|
||||
Updated the version-number hack in pngvalid.c
|
||||
|
||||
Version 1.7.0alpha03 [December 19, 2012]
|
||||
Cleaned up and enhanced the configure option; libpng now correctly
|
||||
links and tests against zlib with a prefix; tests have been clarified; and
|
||||
irrelevant or obsolete things (as defined by the autotools man page) have
|
||||
been removed.
|
||||
Documented new PNG_ABORT behavior in the manual and commentary in pngerror.c
|
||||
Cleaned up whitespace in the synopsis portion of the manpage "libpng.3"
|
||||
Fixed previous support for Z_PREFIX in configure builds, corrected sCAL APIs;
|
||||
some of these use floating point arithmetic so they need to be disabled if
|
||||
floating point arithmetic is switched off. This is a quiet API change -
|
||||
previously it appeared that the APIs were supported if fixed point
|
||||
arithmetic was used internally, however they required certain APIs (floor,
|
||||
modf, frexp, atof) that are part of C floating point support. Changed
|
||||
png_fixed and the gamma code specific version of the same to avoid floor(),
|
||||
which may be a library function (not an intrinsic). Removed unused #if 0
|
||||
code.
|
||||
Disassembled the version number in scripts/options.awk (necessary for
|
||||
building on SunOs).
|
||||
|
||||
Version 1.7.0alpha04 [December 23, 2012]
|
||||
Added scripts/makefile.msys contributed by Christopher M. Wheeler
|
||||
Made default Zlib compression settings be configurable. This adds #defines to
|
||||
pnglibconf.h to control the defaults.
|
||||
Fixed Windows build issues, enabled ARM compilation. Various warnings issued
|
||||
by earlier versions of GCC fixed for Cygwin and Min/GW (which both use old
|
||||
GCCs.) ARM support is enabled by default in zlib.props (unsupported by
|
||||
Microsoft) and ARM compilation is made possible by deleting the check for
|
||||
x86. The test programs cannot be run because they are not signed.
|
||||
|
||||
Version 1.7.0alpha05 [December 24, 2012]
|
||||
Discontinued distributing libpng-1.x.x.tar.bz2.
|
||||
Discontinued distributing libpng-1.7.0-1.6.0-diff.txt and similar.
|
||||
|
||||
Version 1.7.0alpha06 [January 1, 2013]
|
||||
Fixed 'make distcheck' on SUN OS - libpng.so was not being removed
|
||||
|
||||
Version 1.7.0alpha07 [January 10, 2013]
|
||||
Fixed conceivable but difficult to repro overflow. Also added two test
|
||||
programs to generate and test a PNG which should have the problem.
|
||||
|
||||
Version 1.7.0alpha08 [January 17, 2013]
|
||||
Corrected previous attempt at overflow detection in png_set_unknown_chunks().
|
||||
|
||||
Version 1.7.0alpha09 [January 21, 2013]
|
||||
Pulled changes to multi-chunk handling from libpng-1.6.0beta40.
|
||||
|
||||
Version 1.7.0alpha10 [February 5, 2013]
|
||||
Make symbol prefixing work with the ARM neon optimizations. Also
|
||||
allow pngpriv.h to be included for preprocessor definitions only, so
|
||||
it can be used in non-C/C++ files.
|
||||
Added png_get_palette_max() function.
|
||||
Changed png_size_t to size_t throughout headers, make sRGB check numbers
|
||||
consistent.
|
||||
Fixed ARM support (Mans Rullgard).
|
||||
Removed stray out-of-order #endif and #ifdef (Mans Rullgard).
|
||||
Ported libpng 1.5 options.awk/dfn file handling to 1.7, fixed one bug.
|
||||
Rebuilt Makefile.in, configure, etc., with autoconf-2.69 and automake-1.13.
|
||||
Minor fixes to assembler changes, verified with a dummy .S file
|
||||
Removed cc -E workround, corrected png_get_palette_max API. Tested on
|
||||
SUN OS cc 5.9, which demonstrates the tokenization problem previously
|
||||
avoided by using /lib/cpp. Since all .dfn output is now protected
|
||||
in double quotes unless it is to be macro substituted the fix should work
|
||||
everywhere.
|
||||
|
||||
Version 1.7.0beta01 [February 15, 2013]
|
||||
Enable parallel tests and rearrange TESTS order to take advantage of
|
||||
the massive speed improvements use a make capable of parallel builds
|
||||
on a multi-CPU machine and pass the right arguments to make (-j10000
|
||||
for GNU make) to get the build to run in parallel.
|
||||
Fixed previous support for Z_PREFIX in configure builds, corrected
|
||||
sCAL APIs; some of these use floating point arithmetic so need to be
|
||||
disabled if floating point arithmetic is switched off. This is a quiet API
|
||||
change - previously it appeared that the APIs were supported if fixed point
|
||||
arithmetic was used internally, however they required certain APIs (floor,
|
||||
modf, frexp, atof) that are part of C floating point support. Changed
|
||||
png_fixed and the gamma code specific version of the same to avoid floor(),
|
||||
which may be a library function (not an intrinsic). Removed unused #if 0
|
||||
code.
|
||||
Fixed make distcheck to skip over the test result files. They were
|
||||
being included because the whole of the 'tests' directory is included,
|
||||
fixed to just include the actual test files and tests/pngstest. Also
|
||||
reverted the previous erroneous change to remove the ${srcdir} from the
|
||||
front of contrib, scripts, projects and added an explanation of what is
|
||||
going on to Makefile.am
|
||||
Fixed missing dependency in --prefix builds. The intermediate
|
||||
internal 'prefix.h' file can only be generated correctly after pnglibconf.h,
|
||||
however the dependency was not in Makefile.am. The symptoms are
|
||||
unpredictable depending on the order make chooses to build pngprefix.h and
|
||||
pnglibconf.h, often the error goes unnoticed because there is a system
|
||||
pnglibconf.h to use instead.
|
||||
Accept "," as a separator in pnglibconf.dfa and allow for
|
||||
continuation lines. This adds to the syntax of "option" and "chunk" lines,
|
||||
allowing the elements to be separated by a "," at the end of an element and
|
||||
interpreting a "," at end of line as a continuation - so the following line
|
||||
is read. The new syntax is optional and solely provided for readability.
|
||||
Enclosed the new png_get_palette_max in #ifdef PNG_GET_PALETTE_MAX_SUPPORTED
|
||||
block, and revised pnglibconf.h and pnglibconf.h.prebuilt accordingly.
|
||||
|
||||
Version 1.7.0beta02 [February 18, 2013]
|
||||
Fixed a race condition in the creation of the build 'scripts' directory
|
||||
while building with a parallel make.
|
||||
Use approved/supported Android method to check for NEON, use Linux/POSIX
|
||||
1003.1 API to check /proc/self/auxv avoiding buffer allocation and other
|
||||
library calls (ported from libpng15).
|
||||
Use parentheses more consistently in "#if defined(MACRO)" tests.
|
||||
Folded long lines.
|
||||
|
||||
Version 1.7.0beta03 [February 22, 2013]
|
||||
Reenabled code to allow zero length PLTE chunks for MNG.
|
||||
Fixed ALIGNED_MEMORY support.
|
||||
Allow run-time ARM NEON checking to be disabled. A new configure option:
|
||||
--enable-arm-neon=always will stop the run-time checks. New checks
|
||||
within arm/arm_init.c will cause the code not to be compiled unless
|
||||
__ARM_NEON__ is set. This should make it fail safe (if someone asks
|
||||
for it on then the build will fail if it can't be done.)
|
||||
Updated the INSTALL document.
|
||||
|
||||
Version 1.7.0beta04 [February 27, 2013]
|
||||
Revised INSTALL to recommend using CPPFLAGS instead of INCLUDES.
|
||||
Revised scripts/makefile.freebsd to respect ZLIBLIB and ZLIBINC.
|
||||
Revised scripts/dfn.awk to work with the buggy MSYS awk that has trouble
|
||||
with CRLF line endings.
|
||||
|
||||
Version 1.7.0beta05 [March 5, 2013]
|
||||
Avoid a possible memory leak in contrib/gregbook/readpng.c
|
||||
Changed user chunk callback API to respect global and per chunk defaults.
|
||||
Previously a return of 0 from a user chunk callback would result in the
|
||||
chunk being saved (if this was safe, even if the chunk was unsafe-to-copy);
|
||||
this change respects the defaults set by the application, so unknown chunks
|
||||
can be discarded by default and known-safe ones preserved.
|
||||
Corrected Android builds and corrected libpng.vers with symbol
|
||||
prefixing. This adds an API to set optimization options externally,
|
||||
providing an alternative and general solution for the non-portable
|
||||
run-time tests used by the ARM Neon code. It also makes those tests
|
||||
compile and link on Android. The order of settings vs options in
|
||||
pnglibconf.h is reversed to allow settings to depend on options and
|
||||
options can now set (or override) the defaults for settings.
|
||||
|
||||
Version 1.7.0beta06 [March 13, 2013]
|
||||
Corrected simplified API default gamma for color-mapped output, added
|
||||
a flag to change default. In 1.6.0 when the simplified API was used
|
||||
to produce color-mapped output from an input image with no gamma
|
||||
information the gamma assumed for the input could be different from
|
||||
that assumed for non-color-mapped output. In particular 16-bit depth
|
||||
input files were assumed to be sRGB encoded, whereas in the 'direct'
|
||||
case they were assumed to have linear data. This was an error. The
|
||||
fix makes the simplified API treat all input files the same way and
|
||||
adds a new flag to the png_image::flags member to allow the
|
||||
application/user to specify that 16-bit files contain sRGB data
|
||||
rather than the default linear.
|
||||
Fixed bugs in the pngpixel and makepng test programs.
|
||||
Fixed CMakelists.txt to allow building a single variant of the library
|
||||
(Claudio Bley):
|
||||
Introduced a PNG_LIB_TARGETS variable that lists all activated library
|
||||
targets. It is an error if this variable ends up empty, ie. you have
|
||||
to build at least one library variant.
|
||||
Made the *_COPY targets only depend on library targets actually being build.
|
||||
Use PNG_LIB_TARGETS to unify a code path.
|
||||
Changed the CREATE_SYMLINK macro to expect the full path to a file as the
|
||||
first argument. When symlinking the filename component of that path is
|
||||
determined and used as the link target.
|
||||
Use copy_if_different in the CREATE_SYMLINK macro.
|
||||
Eliminated two warnings from the Intel C compiler. The warnings are
|
||||
technically valid, although a reasonable treatment of division would
|
||||
show it to be incorrect.
|
||||
|
||||
Version 1.7.0beta07 [April 14, 2013]
|
||||
Updated documentation of 1.5.x to 1.6.x changes in iCCP chunk handling.
|
||||
Fixed incorrect warning of excess deflate data. End condition - the
|
||||
warning would be produced if the end of the deflate stream wasn't read
|
||||
in the last row. The warning is harmless.
|
||||
Corrected the test on user transform changes on read. It was in the
|
||||
png_set of the transform function, but that doesn't matter unless the
|
||||
transform function changes the rowbuf size, and that is only valid if
|
||||
transform_info is called.
|
||||
Corrected a misplaced closing bracket in contrib/libtests/pngvalid.c
|
||||
(Flavio Medeiros).
|
||||
Corrected length written to uncompressed iTXt chunks (Samuli Suominen).
|
||||
|
||||
Version 1.7.0beta08 [April 18, 2013]
|
||||
Added contrib/tools/fixitxt.c, to repair the erroneous iTXt chunk length
|
||||
written by libpng-1.6.0 and 1.6.1.
|
||||
Disallow storing sRGB information when the sRGB is not supported.
|
||||
|
||||
Version 1.7.0beta09 [April 24, 2013]
|
||||
Exposed PNG chunk types in png.h
|
||||
Modified png_uint_32 macros/code to make as few assumptions as possible
|
||||
about the hardware.
|
||||
Revised stack marking in arm/filter_neon.S and configure.ac.
|
||||
Ensure that NEON filter stuff is completely disabled when switched 'off'.
|
||||
Previously the ARM NEON specific files were still built if the option
|
||||
was switched 'off' as opposed to being explicitly disabled.
|
||||
|
||||
Version 1.7.0beta10 [April 24, 2013]
|
||||
Attempt to fix the PNG_ARM_NEON configuration mess.
|
||||
|
||||
Version 1.7.0beta11 [April 26, 2013]
|
||||
Test for 'arm*', not just 'arm' in the host_cpu configure variable.
|
||||
|
||||
Version 1.7.0beta12 [April 30, 2013]
|
||||
Added png_app_warning for out-of-range unknown chunk index in
|
||||
png_set_unknown_chunk_location().
|
||||
Expanded manual paragraph about writing private chunks.
|
||||
Avoid dereferencing NULL pointer possibly returned from
|
||||
png_create_write_struct() (Andrew Church).
|
||||
|
||||
Version 1.7.0beta13 [May 12, 2013]
|
||||
Revised contrib/pngminim/*/makefile to generate pnglibconf.h with the
|
||||
right zlib header files.
|
||||
Separated CPPFLAGS and CFLAGS in contrib/pngminim/*/makefile
|
||||
Updated contrib/pngminus/pnm2png.c (Paul Stewart):
|
||||
Check for EOF
|
||||
Ignore "#" delimited comments in input file to pnm2png.c.
|
||||
Fixed whitespace handling
|
||||
Added a call to png_set_packing()
|
||||
Initialize dimension values so if sscanf fails at least we have known
|
||||
invalid values.
|
||||
Calculate our own zlib windowBits when decoding rather than trusting the
|
||||
CMF bytes in the PNG datastream.
|
||||
Added an option to force maximum window size for inflating, which was
|
||||
the behavior of libpng15 and earlier.
|
||||
Added png-fix-itxt and png-fix-too-far-back to the built programs and
|
||||
removed warnings from the source code and timepng that are revealed as
|
||||
a result.
|
||||
Detect wrong libpng versions linked to png-fix-too-far-back, which currently
|
||||
only works with libpng versions that can be made to reliably fail when
|
||||
the deflate data contains an out-of-window reference. This means only
|
||||
1.6 and later.
|
||||
Attempt to detect configuration issues with png-fix-too-far-back, which
|
||||
requires both the correct libpng and the correct zlib to function
|
||||
correctly.
|
||||
Check ZLIB_VERNUM for mismatches, enclose #error in quotes
|
||||
Added information in the documentation about problems with and fixes for
|
||||
the bad CRC and bad iTXt chunk situations.
|
||||
|
||||
Version 1.7.0beta14 [June 8, 2013]
|
||||
Removed a redundant test in png_set_IHDR().
|
||||
Added set(CMAKE_CONFIGURATION_TYPES ...) to CMakeLists.txt (Andrew Hundt)
|
||||
Deleted set(CMAKE_BUILD_TYPE) block from CMakeLists.txt
|
||||
Enclose the prototypes for the simplified write API in #ifdef STDIO/#endif
|
||||
Make ARM NEON support work at compile time (not just configure time).
|
||||
This moves the test on __ARM_NEON__ into pngconf.h to avoid issues when
|
||||
using a compiler that compiles for multiple architectures at one time.
|
||||
Removed PNG_FILTER_OPTIMIZATIONS and PNG_ARM_NEON_SUPPORTED from
|
||||
pnglibconf.h, allowing more of the decisions to be made internally
|
||||
(pngpriv.h) during the compile. Without this, symbol prefixing is broken
|
||||
under certain circumstances on ARM platforms. Now only the API parts of
|
||||
the optimizations ('check' vs 'api') are exposed in the public header files
|
||||
except that the new setting PNG_ARM_NEON_OPT documents how libpng makes the
|
||||
decision about whether or not to use the optimizations.
|
||||
Protect symbol prefixing against CC/CPPFLAGS/CFLAGS useage.
|
||||
Previous iOS/Xcode fixes for the ARM NEON optimizations moved the test
|
||||
on __ARM_NEON__ from configure time to compile time. This breaks symbol
|
||||
prefixing because the definition of the special png_init_filter_functions
|
||||
call was hidden at configure time if the relevant compiler arguments are
|
||||
passed in CFLAGS as opposed to CC. This change attempts to avoid all
|
||||
the confusion that would result by declaring the init function even when
|
||||
it is not used, so that it will always get prefixed.
|
||||
|
||||
Version 1.7.0beta15 [June 18, 2013]
|
||||
Revised libpng.3 so that "doclift" can process it.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
|
||||
(subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# CMakeLists.txt
|
||||
|
||||
# Copyright (C) 2007-2011 Glenn Randers-Pehrson
|
||||
# Copyright (C) 2007-2013 Glenn Randers-Pehrson
|
||||
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
@@ -9,32 +9,13 @@
|
||||
cmake_minimum_required(VERSION 2.4.4)
|
||||
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
|
||||
|
||||
if(UNIX AND NOT DEFINED CMAKE_BUILD_TYPE)
|
||||
if(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION EQUAL 4)
|
||||
# workaround CMake 2.4.x bug
|
||||
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
|
||||
"Choose the type of build, options are:
|
||||
None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used)
|
||||
Debug
|
||||
Release
|
||||
RelWithDebInfo
|
||||
MinSizeRel.")
|
||||
else()
|
||||
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
|
||||
"Choose the type of build, options are:
|
||||
None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used)
|
||||
Debug
|
||||
Release
|
||||
RelWithDebInfo
|
||||
MinSizeRel.")
|
||||
endif()
|
||||
endif()
|
||||
set(CMAKE_CONFIGURATION_TYPES "Release;Debug;MinSizeRel;RelWithDebInfo")
|
||||
|
||||
project(libpng C)
|
||||
enable_testing()
|
||||
|
||||
set(PNGLIB_MAJOR 1)
|
||||
set(PNGLIB_MINOR 6)
|
||||
set(PNGLIB_MINOR 7)
|
||||
set(PNGLIB_RELEASE 0)
|
||||
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
|
||||
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
|
||||
@@ -139,8 +120,11 @@ endif()
|
||||
# NOW BUILD OUR TARGET
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR})
|
||||
|
||||
unset(PNG_LIB_TARGETS)
|
||||
|
||||
if(PNG_SHARED)
|
||||
add_library(${PNG_LIB_NAME} SHARED ${libpng_sources})
|
||||
set(PNG_LIB_TARGETS ${PNG_LIB_NAME})
|
||||
if(MSVC)
|
||||
# msvc does not append 'lib' - do it here to have consistent name
|
||||
set_target_properties(${PNG_LIB_NAME} PROPERTIES PREFIX "lib")
|
||||
@@ -153,6 +137,7 @@ if(PNG_STATIC)
|
||||
# does not work without changing name
|
||||
set(PNG_LIB_NAME_STATIC ${PNG_LIB_NAME}_static)
|
||||
add_library(${PNG_LIB_NAME_STATIC} STATIC ${libpng_sources})
|
||||
list(APPEND PNG_LIB_TARGETS ${PNG_LIB_NAME_STATIC})
|
||||
if(MSVC)
|
||||
# msvc does not append 'lib' - do it here to have consistent name
|
||||
set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES PREFIX "lib")
|
||||
@@ -160,6 +145,12 @@ if(PNG_STATIC)
|
||||
target_link_libraries(${PNG_LIB_NAME_STATIC} ${ZLIB_LIBRARY} ${M_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(NOT PNG_LIB_TARGETS)
|
||||
message(SEND_ERROR
|
||||
"No library variant selected to build. "
|
||||
"Please enable at least one of the following options: PNG_STATIC, PNG_SHARED")
|
||||
endif()
|
||||
|
||||
if(PNG_SHARED AND WIN32)
|
||||
set_target_properties(${PNG_LIB_NAME} PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
|
||||
endif()
|
||||
@@ -222,14 +213,15 @@ macro(CREATE_SYMLINK SRC_FILE DEST_FILE)
|
||||
if(WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
|
||||
DEPENDS ${PNG_LIB_NAME} ${PNG_LIB_NAME_STATIC}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_FILE}" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_FILE}" ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
|
||||
DEPENDS ${PNG_LIB_TARGETS}
|
||||
)
|
||||
ADD_CUSTOM_TARGET(${DEST_FILE}_COPY ALL DEPENDS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE})
|
||||
else(WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SRC_FILE} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SRC_FILE} ${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
get_filename_component(LINK_TARGET "${SRC_FILE}" NAME)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${LINK_TARGET}" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${LINK_TARGET}" ${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
|
||||
endif(WIN32 AND NOT CYGWIN AND NOT MSYS)
|
||||
endmacro()
|
||||
|
||||
@@ -260,9 +252,9 @@ endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
# SET UP LINKS
|
||||
if(PNG_SHARED)
|
||||
set_target_properties(${PNG_LIB_NAME} PROPERTIES
|
||||
# VERSION 16.${PNGLIB_RELEASE}.1.6.0beta33
|
||||
VERSION 16.${PNGLIB_RELEASE}.0
|
||||
SOVERSION 16
|
||||
# VERSION 17.${PNGLIB_RELEASE}.1.7.0beta15
|
||||
VERSION 17.${PNGLIB_RELEASE}.0
|
||||
SOVERSION 17
|
||||
CLEAN_DIRECT_OUTPUT 1)
|
||||
endif()
|
||||
if(PNG_STATIC)
|
||||
@@ -287,40 +279,33 @@ endif()
|
||||
|
||||
# INSTALL
|
||||
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
|
||||
if(PNG_SHARED)
|
||||
install(TARGETS ${PNG_LIB_NAME}
|
||||
${PNG_EXPORT_RULE}
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
install(TARGETS ${PNG_LIB_TARGETS}
|
||||
${PNG_EXPORT_RULE}
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
|
||||
# Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin
|
||||
if(PNG_SHARED)
|
||||
# Create a symlink for libpng.dll.a => libpng17.dll.a on Cygwin
|
||||
if(CYGWIN OR MINGW)
|
||||
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE})
|
||||
get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME)
|
||||
CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_IMPORT_LIBRARY_SUFFIX})
|
||||
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_IMPORT_LIBRARY_SUFFIX})
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif(CYGWIN OR MINGW)
|
||||
|
||||
if(NOT WIN32)
|
||||
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE})
|
||||
get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME)
|
||||
CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif(NOT WIN32)
|
||||
endif(PNG_SHARED)
|
||||
|
||||
if(PNG_STATIC)
|
||||
install(TARGETS ${PNG_LIB_NAME_STATIC}
|
||||
${PNG_EXPORT_RULE}
|
||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
if(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME_STATIC} LOCATION_${CMAKE_BUILD_TYPE})
|
||||
get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME)
|
||||
CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif(NOT WIN32 OR CYGWIN OR MINGW)
|
||||
|
||||
27
INSTALL
27
INSTALL
@@ -41,19 +41,33 @@ is not already on your system. zlib can usually be found
|
||||
wherever you got libpng. zlib can be placed in another directory,
|
||||
at the same level as libpng.
|
||||
|
||||
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
|
||||
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".
|
||||
|
||||
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
|
||||
to have access to the zlib.h and zconf.h include files that
|
||||
correspond to the version of zlib that's installed.
|
||||
|
||||
You can rename the directories that you downloaded (they
|
||||
might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.5"
|
||||
or "zlib125") so that you have directories called "zlib" and "libpng".
|
||||
might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.7"
|
||||
or "zlib127") so that you have directories called "zlib" and "libpng".
|
||||
|
||||
Your directory structure should look like this:
|
||||
|
||||
@@ -71,6 +85,7 @@ Your directory structure should look like this:
|
||||
depcomp, install-sh, mkinstalldirs, test-pngtest.sh
|
||||
contrib
|
||||
gregbook
|
||||
libtests
|
||||
pngminim
|
||||
pngminus
|
||||
pngsuite
|
||||
|
||||
6
LICENSE
6
LICENSE
@@ -10,8 +10,8 @@ this sentence.
|
||||
|
||||
This code is released under the libpng license.
|
||||
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.6.0beta33, December 10, 2012, are
|
||||
Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.7.0beta15, June 18, 2013, are
|
||||
Copyright (c) 2004, 2006-2013 Glenn Randers-Pehrson, and are
|
||||
distributed according to the same disclaimer and license as libpng-1.2.5
|
||||
with the following individual added to the list of Contributing Authors
|
||||
|
||||
@@ -108,4 +108,4 @@ certification mark of the Open Source Initiative.
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
glennrp at users.sourceforge.net
|
||||
December 10, 2012
|
||||
June 18, 2013
|
||||
|
||||
121
Makefile.am
121
Makefile.am
@@ -7,24 +7,52 @@ PNGLIB_BASENAME= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
|
||||
ACLOCAL_AMFLAGS = -I scripts
|
||||
|
||||
# test programs - run on make check, make distcheck
|
||||
TESTS_ENVIRONMENT= srcdir=$(srcdir)
|
||||
check_PROGRAMS= pngtest
|
||||
check_PROGRAMS= pngtest pngunknown pngstest pngvalid
|
||||
|
||||
# Utilities - installed
|
||||
bin_PROGRAMS= png-fix-too-far-back png-fix-itxt
|
||||
|
||||
pngtest_SOURCES = pngtest.c
|
||||
pngtest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
TESTS = test-pngtest.sh
|
||||
|
||||
# Only do the following if the contrib directory is present.
|
||||
check_PROGRAMS+= pngvalid pngstest pngunknown
|
||||
pngvalid_SOURCES = contrib/libtests/pngvalid.c
|
||||
pngstest_SOURCES = contrib/libtests/pngstest.c
|
||||
pngunknown_SOURCES = contrib/libtests/pngunknown.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
|
||||
TESTS += contrib/libtests/test-pngunknown.sh\
|
||||
contrib/libtests/test-pngvalid-simple.sh\
|
||||
contrib/libtests/test-pngvalid-full.sh\
|
||||
contrib/libtests/test-pngstest.sh
|
||||
|
||||
png_fix_too_far_back_SOURCES = contrib/tools/png-fix-too-far-back.c
|
||||
png_fix_too_far_back_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
|
||||
|
||||
png_fix_itxt_SOURCES = contrib/tools/png-fix-itxt.c
|
||||
|
||||
# Generally these are single line shell scripts to run a test with a particular
|
||||
# set of parameters:
|
||||
TESTS =\
|
||||
tests/pngtest\
|
||||
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-interlace-size\
|
||||
tests/pngvalid-progressive-interlace-standard\
|
||||
tests/pngvalid-progressive-interlace-transform\
|
||||
tests/pngvalid-progressive-standard tests/pngvalid-standard\
|
||||
tests/pngstest-0g01 tests/pngstest-0g02 tests/pngstest-0g04\
|
||||
tests/pngstest-0g08 tests/pngstest-0g16 tests/pngstest-2c08\
|
||||
tests/pngstest-2c16 tests/pngstest-3p01 tests/pngstest-3p02\
|
||||
tests/pngstest-3p04 tests/pngstest-3p08 tests/pngstest-4a08\
|
||||
tests/pngstest-4a16 tests/pngstest-6a08 tests/pngstest-6a16\
|
||||
tests/pngstest-error tests/pngunknown-IDAT\
|
||||
tests/pngunknown-discard tests/pngunknown-if-safe tests/pngunknown-sAPI\
|
||||
tests/pngunknown-sTER tests/pngunknown-save tests/pngunknown-vpAg
|
||||
|
||||
# These tests are expected, and required, to fail:
|
||||
XFAIL_TESTS = tests/pngstest-error
|
||||
|
||||
# man pages
|
||||
dist_man_MANS= libpng.3 libpngpf.3 png.5
|
||||
@@ -43,7 +71,8 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c\
|
||||
png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngusr.dfa
|
||||
|
||||
if PNG_ARM_NEON
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/filter_neon.S
|
||||
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/arm_init.c\
|
||||
arm/filter_neon.S
|
||||
endif
|
||||
|
||||
nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
|
||||
@@ -76,12 +105,14 @@ nodist_pkginclude_HEADERS= pnglibconf.h
|
||||
pkgconfigdir = @pkgconfigdir@
|
||||
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= \
|
||||
ANNOUNCE CHANGES INSTALL LICENSE README TODO \
|
||||
pngtest.png pngbar.png pngnow.png pngbar.jpg autogen.sh \
|
||||
${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \
|
||||
$(TESTS) \
|
||||
$(TESTS) $(XFAIL_TESTS) tests/pngstest \
|
||||
CMakeLists.txt example.c libpng-manual.txt
|
||||
|
||||
SCRIPT_CLEANFILES=scripts/*.out scripts/*.chk scripts/pnglibconf.dfn
|
||||
@@ -118,6 +149,9 @@ $(PNGLIB_BASENAME)-config: libpng-config
|
||||
scripts/sym.out scripts/vers.out: png.h pngconf.h pnglibconf.h
|
||||
scripts/prefix.out: png.h pngconf.h pnglibconf.out
|
||||
scripts/symbols.out: png.h pngconf.h $(srcdir)/scripts/pnglibconf.h.prebuilt
|
||||
scripts/intprefix.out: pnglibconf.h
|
||||
|
||||
pnglibconf.out: config.h
|
||||
|
||||
libpng.sym: scripts/sym.out
|
||||
rm -f $@
|
||||
@@ -130,7 +164,7 @@ 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
|
||||
pnglibconf.h: pnglibconf.out scripts/prefix.out scripts/macro.lst config.h
|
||||
rm -f $@
|
||||
$(AWK) 's==0 && NR>1{print prev}\
|
||||
s==0{prev=$$0}\
|
||||
@@ -156,14 +190,15 @@ endif
|
||||
$(srcdir)/scripts/pnglibconf.h.prebuilt:
|
||||
@echo "Attempting to build $@" >&2
|
||||
@echo "This is a machine generated file, but if you want to make" >&2
|
||||
@echo "a new one simply make 'scripts/pnglibconf.out' and copy that" >&2
|
||||
@echo "a new one simply make 'scripts/pnglibconf.out', copy that" >&2
|
||||
@echo "AND set PNG_ZLIB_VERNUM to 0 (you MUST do this)" >&2
|
||||
@exit 1
|
||||
|
||||
# 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.)
|
||||
contrib/libtests/pngstest.o contrib/libtests/pngvalid.o pngtest.o: pnglibconf.h
|
||||
contrib/libtests/pngunknown.o: pnglibconf.h
|
||||
pngstest.o pngvalid.o pngtest.o pngunknown.o timepng.o: pnglibconf.h
|
||||
png-fix-too-far-back.o png-fix-itxt.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
|
||||
@@ -178,16 +213,14 @@ SYMBOL_CFLAGS += -DPNG_PREFIX='@PNG_PREFIX@'
|
||||
endif
|
||||
|
||||
.dfn.out:
|
||||
rm -f $@ $*.c $*.tf[123]
|
||||
test -d scripts || mkdir scripts
|
||||
rm -f $@ $*.c $*.tf[12]
|
||||
test -d scripts || mkdir scripts || test -d scripts
|
||||
echo '#include "$<"' >$*.c
|
||||
$(DFNCPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)\
|
||||
$(CPPFLAGS) $(SYMBOL_CFLAGS) $*.c > $*.tf1
|
||||
$(SED) -n -e 's|^.*PNG_DEFN_MAGIC *-\(.*\)- *PNG_DEFN_END.*$$|\1|p'\
|
||||
$*.tf1 >$*.tf2
|
||||
$(SED) -e 's| *PNG_JOIN *||g' -e 's| *$$||' $*.tf2 >$*.tf3
|
||||
rm -f $*.c $*.tf[12]
|
||||
mv $*.tf3 $@
|
||||
$(AWK) -f "${srcdir}/scripts/dfn.awk" out="$*.tf2" $*.tf1 1>&2
|
||||
rm -f $*.c $*.tf1
|
||||
mv $*.tf2 $@
|
||||
|
||||
# The .dfn file for pnglibconf.h is machine generated
|
||||
pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h pngusr.dfa $(DFA_XTRA)
|
||||
@@ -236,22 +269,24 @@ dist-hook:
|
||||
|
||||
# install the .../include headers as links to the new ones
|
||||
install-data-hook:
|
||||
cd $(DESTDIR)$(includedir); rm -f png.h pngconf.h pnglibconf.h
|
||||
cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/png.h png.h
|
||||
cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/pngconf.h \
|
||||
cd '$(DESTDIR)$(includedir)'; rm -f png.h pngconf.h pnglibconf.h
|
||||
cd '$(DESTDIR)$(includedir)'; $(LN_S) $(PNGLIB_BASENAME)/png.h png.h
|
||||
cd '$(DESTDIR)$(includedir)'; $(LN_S) $(PNGLIB_BASENAME)/pngconf.h \
|
||||
pngconf.h
|
||||
cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/pnglibconf.h \
|
||||
cd '$(DESTDIR)$(includedir)'; $(LN_S) $(PNGLIB_BASENAME)/pnglibconf.h \
|
||||
pnglibconf.h
|
||||
cd $(DESTDIR)$(pkgconfigdir); rm -f libpng.pc
|
||||
cd $(DESTDIR)$(pkgconfigdir); $(LN_S) $(PNGLIB_BASENAME).pc libpng.pc
|
||||
cd '$(DESTDIR)$(pkgconfigdir)'; rm -f libpng.pc
|
||||
cd '$(DESTDIR)$(pkgconfigdir)'; $(LN_S) $(PNGLIB_BASENAME).pc libpng.pc
|
||||
|
||||
# do evil things to libpng to cause libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ to be used
|
||||
install-exec-hook:
|
||||
cd $(DESTDIR)$(bindir); rm -f libpng-config
|
||||
cd $(DESTDIR)$(bindir); $(LN_S) $(PNGLIB_BASENAME)-config libpng-config
|
||||
cd '$(DESTDIR)$(bindir)'; rm -f libpng-config
|
||||
cd '$(DESTDIR)$(bindir)';\
|
||||
$(LN_S) $(PNGLIB_BASENAME)-config libpng-config
|
||||
@set -x;\
|
||||
cd $(DESTDIR)$(libdir);\
|
||||
for ext in a la so so.@PNGLIB_MAJOR@@PNGLIB_MINOR@.@PNGLIB_RELEASE@ sl dylib dll.a; do\
|
||||
cd '$(DESTDIR)$(libdir)';\
|
||||
for ext in a la so so.@PNGLIB_MAJOR@@PNGLIB_MINOR@.@PNGLIB_RELEASE@\
|
||||
sl dylib dll.a; do\
|
||||
rm -f libpng.$$ext;\
|
||||
if test -f $(PNGLIB_BASENAME).$$ext; then\
|
||||
$(LN_S) $(PNGLIB_BASENAME).$$ext libpng.$$ext;\
|
||||
@@ -259,9 +294,13 @@ install-exec-hook:
|
||||
done
|
||||
|
||||
uninstall-hook:
|
||||
cd $(DESTDIR)$(includedir); rm -f png.h pngconf.h pnglibconf.h
|
||||
rm -f $(DESTDIR)$(pkgconfigdir)/libpng.pc
|
||||
rm -f $(DESTDIR)$(bindir)/libpng-config
|
||||
rm -f $(DESTDIR)$(libdir)/libpng.a
|
||||
rm -f $(DESTDIR)$(libdir)/libpng.la
|
||||
rm -f $(DESTDIR)$(libdir)/libpng.dll.a
|
||||
cd '$(DESTDIR)$(includedir)'; rm -f png.h pngconf.h pnglibconf.h
|
||||
rm -f '$(DESTDIR)$(pkgconfigdir)/libpng.pc'
|
||||
rm -f '$(DESTDIR)$(bindir)/libpng-config'
|
||||
rm -f '$(DESTDIR)$(libdir)/libpng.a'
|
||||
rm -f '$(DESTDIR)$(libdir)/libpng.la'
|
||||
rm -f '$(DESTDIR)$(libdir)/libpng.so'
|
||||
rm -f '$(DESTDIR)$(libdir)/libpng.so.@PNGLIB_MAJOR@@PNGLIB_MINOR@.@PNGLIB_RELEASE@'
|
||||
rm -f '$(DESTDIR)$(libdir)/libpng.sl'
|
||||
rm -f '$(DESTDIR)$(libdir)/libpng.dylib'
|
||||
rm -f '$(DESTDIR)$(libdir)/libpng.dll.a'
|
||||
|
||||
36
README
36
README
@@ -1,11 +1,11 @@
|
||||
README for libpng version 1.6.0beta33 - December 10, 2012 (shared library 16.0)
|
||||
README for libpng version 1.7.0beta15 - June 18, 2013 (shared library 17.0)
|
||||
See the note about version numbers near the top of png.h
|
||||
|
||||
See INSTALL for instructions on how to install libpng.
|
||||
|
||||
Libpng comes in several distribution formats. Get libpng-*.tar.gz,
|
||||
libpng-*.tar.xz or libpng-*.tar.bz2 if you want UNIX-style line endings
|
||||
in the text files, or lpng*.zip if you want DOS-style line endings.
|
||||
Libpng comes in several distribution formats. Get libpng-*.tar.gz or
|
||||
libpng-*.tar.xz or if you want UNIX-style line endings in the text files,
|
||||
or lpng*.7z or lpng*.zip if you want DOS-style line endings.
|
||||
|
||||
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
|
||||
@@ -77,17 +77,15 @@ compression library that is useful for more things than just PNG files.
|
||||
You can use zlib as a drop-in replacement for fread() and fwrite() if
|
||||
you are so inclined.
|
||||
|
||||
zlib should be available at the same place that libpng is, or at.
|
||||
ftp://ftp.info-zip.org/pub/infozip/zlib
|
||||
zlib should be available at the same place that libpng is, or at zlib.net.
|
||||
|
||||
You may also want a copy of the PNG specification. It is available
|
||||
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
|
||||
these at http://www.libpng.org/pub/png/documents/
|
||||
|
||||
This code is currently being archived at libpng.sf.net in the
|
||||
[DOWNLOAD] area, and on CompuServe, Lib 20 (PNG SUPPORT)
|
||||
at GO GRAPHSUP. If you can't find it in any of those places,
|
||||
e-mail me, and I'll help you find it.
|
||||
[DOWNLOAD] area, and at ftp://ftp.simplesystems.org. If you can't find it
|
||||
in any of those places, e-mail me, and I'll help you find it.
|
||||
|
||||
If you have any code changes, requests, problems, etc., please e-mail
|
||||
them to me. Also, I'd appreciate any make files or project files,
|
||||
@@ -123,7 +121,7 @@ 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 sixteen years now, and it is official and
|
||||
been discussing PNG for eighteen 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.
|
||||
@@ -167,23 +165,25 @@ Files in this distribution:
|
||||
pngwrite.c => High-level write functions
|
||||
pngwtran.c => Write data transformations
|
||||
pngwutil.c => Write utility functions
|
||||
arm => Contains optimized code for the ARM platform
|
||||
contrib => Contributions
|
||||
examples => Example programs
|
||||
gregbook => source code for PNG reading and writing, from
|
||||
Greg Roelofs' "PNG: The Definitive Guide",
|
||||
O'Reilly, 1999
|
||||
msvctest => Builds and runs pngtest using a MSVC workspace
|
||||
pngminus => Simple pnm2png and png2pnm programs
|
||||
pngsuite => Test images
|
||||
libtests => Test programs
|
||||
pngminim => Minimal decoder, encoder, and progressive decoder
|
||||
programs demonstrating use of pngusr.dfa
|
||||
pngminus => Simple pnm2png and png2pnm programs
|
||||
pngsuite => Test images
|
||||
tools => Various tools
|
||||
visupng => Contains a MSVC workspace for VisualPng
|
||||
projects => Contains project files and workspaces for
|
||||
building a DLL
|
||||
cbuilder5 => Contains a Borland workspace for building
|
||||
libpng and zlib
|
||||
visualc6 => Contains a Microsoft Visual C++ (MSVC)
|
||||
workspace for building libpng and zlib
|
||||
owatcom => Contains a WATCOM project for building libpng
|
||||
visualc71 => Contains a Microsoft Visual C++ (MSVC)
|
||||
workspace for building libpng and zlib
|
||||
xcode => Contains an Apple xcode
|
||||
vstudio => Contains a Microsoft Visual C++ (MSVC)
|
||||
workspace for building libpng and zlib
|
||||
scripts => Directory containing scripts for building libpng:
|
||||
(see scripts/README.txt for the list of scripts)
|
||||
|
||||
219
arm/arm_init.c
Normal file
219
arm/arm_init.c
Normal file
@@ -0,0 +1,219 @@
|
||||
|
||||
/* arm_init.c - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2013 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
* Last changed in libpng 1.5.17 [(PENDING RELEASE)]
|
||||
*
|
||||
* 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"
|
||||
|
||||
#if PNG_ARM_NEON_OPT > 0
|
||||
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED /* Do run-time checks */
|
||||
#include <signal.h> /* for sig_atomic_t */
|
||||
|
||||
#ifdef __ANDROID__
|
||||
/* Linux provides access to information about CPU capabilites via
|
||||
* /proc/self/auxv, however Android blocks this while still claiming to be
|
||||
* Linux. The Andoid NDK, however, provides appropriate support.
|
||||
*
|
||||
* Documentation: http://www.kandroid.org/ndk/docs/CPU-ARM-NEON.html
|
||||
*/
|
||||
#include <cpu-features.h>
|
||||
|
||||
static int
|
||||
png_have_neon(png_structp png_ptr)
|
||||
{
|
||||
/* This is a whole lot easier than the mess below, 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;
|
||||
}
|
||||
#elif defined(__linux__)
|
||||
/* The 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;
|
||||
}
|
||||
#else
|
||||
/* We don't know how to do a run-time check on this system */
|
||||
# error "no support for run-time ARM NEON checks"
|
||||
#endif /* OS checks */
|
||||
#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)
|
||||
{
|
||||
#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
|
||||
case PNG_OPTION_ON:
|
||||
/* Option turned on */
|
||||
break;
|
||||
|
||||
default: /* OFF or INVALID */
|
||||
return;
|
||||
}
|
||||
#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 */
|
||||
@@ -1,18 +1,27 @@
|
||||
|
||||
/* filter_neon.S - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2011 Glenn Randers-Pehrson
|
||||
* Copyright (c) 2013 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
* Last changed in libpng 1.5.17 [(PENDING RELEASE)]
|
||||
*
|
||||
* 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 also
|
||||
* includes the definition (or not) of PNG_ARM_NEON_OPT.
|
||||
*/
|
||||
#define PNG_VERSION_INFO_ONLY
|
||||
#include "../pngpriv.h"
|
||||
|
||||
#if defined(__linux__) && defined(__ELF__)
|
||||
.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
|
||||
#endif
|
||||
|
||||
#if PNG_ARM_NEON_OPT > 0
|
||||
|
||||
#ifdef __ELF__
|
||||
# define ELF
|
||||
#else
|
||||
@@ -223,3 +232,4 @@ func png_read_filter_row_paeth3_neon, export=1
|
||||
|
||||
pop {r4,pc}
|
||||
endfunc
|
||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||
|
||||
@@ -74,7 +74,7 @@ done
|
||||
#
|
||||
# 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"
|
||||
config.sub configure depcomp install-sh ltmain.sh missing test-driver"
|
||||
#
|
||||
# These are separate because 'maintainer-clean' does not remove them.
|
||||
libpng_libtool_files="scripts/libtool.m4 scripts/ltoptions.m4\
|
||||
|
||||
254
configure.ac
254
configure.ac
@@ -18,7 +18,7 @@ AC_PREREQ([2.68])
|
||||
|
||||
dnl Version number stuff here:
|
||||
|
||||
AC_INIT([libpng],[1.6.0beta33],[png-mng-implement@lists.sourceforge.net])
|
||||
AC_INIT([libpng],[1.7.0beta15],[png-mng-implement@lists.sourceforge.net])
|
||||
AC_CONFIG_MACRO_DIR([scripts])
|
||||
|
||||
# libpng does not follow GNU file name conventions (hence 'foreign')
|
||||
@@ -26,9 +26,11 @@ AC_CONFIG_MACRO_DIR([scripts])
|
||||
# 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
|
||||
AM_INIT_AUTOMAKE([1.12.2 foreign dist-xz dist-bzip2 color-tests silent-rules])
|
||||
# was:
|
||||
# AM_INIT_AUTOMAKE
|
||||
# 1.13 is required for parallel tests
|
||||
AM_INIT_AUTOMAKE([1.13 foreign dist-xz color-tests silent-rules])
|
||||
# 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
|
||||
|
||||
dnl configure.ac and Makefile.am expect automake 1.11.2 or a compatible later
|
||||
@@ -37,9 +39,9 @@ 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.0beta33
|
||||
PNGLIB_VERSION=1.7.0beta15
|
||||
PNGLIB_MAJOR=1
|
||||
PNGLIB_MINOR=6
|
||||
PNGLIB_MINOR=7
|
||||
PNGLIB_RELEASE=0
|
||||
|
||||
dnl End of version number stuff
|
||||
@@ -53,8 +55,7 @@ AC_PROG_CC
|
||||
AM_PROG_AS
|
||||
LT_PATH_LD
|
||||
AC_PROG_CPP
|
||||
AC_CHECK_TOOL(SED, sed, :)
|
||||
AC_CHECK_TOOL(AWK, awk, :)
|
||||
AC_PROG_AWK
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
AC_PROG_MAKE_SET
|
||||
@@ -64,30 +65,23 @@ dnl compatible later version may be used
|
||||
LT_INIT([win32-dll])
|
||||
LT_PREREQ([2.4.2])
|
||||
|
||||
# On Solaris 10 and 12 CPP gets set to cc -E, however this still
|
||||
# does some input parsing. We need strict ANSI-C style tokenization,
|
||||
# check this:
|
||||
AC_REQUIRE_CPP
|
||||
AC_MSG_CHECKING([for a C preprocessor that does not parse its input])
|
||||
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[1.1.1 16BIT]])],
|
||||
[DFNCPP="$CPP"],
|
||||
[ DFNCPP=""
|
||||
sav_CPP="$CPP"
|
||||
for CPP in "${CC-cc} -E" "${CC-cc} -E -traditional-cpp" "/lib/cpp" "cpp"
|
||||
do
|
||||
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[1.1.1 16BIT]])],
|
||||
[DFNCPP="$CPP"]
|
||||
[break],,)
|
||||
done
|
||||
CPP="$sav_CPP"
|
||||
])
|
||||
if test -n "$DFNCPP"; then
|
||||
AC_MSG_RESULT([$DFNCPP])
|
||||
AC_SUBST(DFNCPP)
|
||||
# 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([not found], 1)
|
||||
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
|
||||
@@ -115,31 +109,138 @@ AC_ARG_ENABLE(werror,
|
||||
|
||||
# Checks for header files.
|
||||
AC_HEADER_STDC
|
||||
AC_CHECK_HEADERS([malloc.h stdlib.h string.h strings.h])
|
||||
# Headers used in pngpriv.h:
|
||||
AC_CHECK_HEADERS([assert.h stdlib.h string.h float.h fp.h math.h m68881.h])
|
||||
# Additional headers used in pngconf.h:
|
||||
AC_CHECK_HEADERS([limits.h stddef.h stdio.h setjmp.h time.h])
|
||||
# Used by pngread.c (for the simplified API):
|
||||
AC_CHECK_HEADERS([errno.h])
|
||||
# The following are not required for the standard 'make' build of libpng:
|
||||
# Additional requirements of contrib/libtests/makepng.c:
|
||||
AC_CHECK_HEADERS([ctype.h])
|
||||
# Additional requirements of contrib/libtests/pngvalid.c:
|
||||
AC_CHECK_HEADERS([fenv.h])
|
||||
|
||||
# Checks for typedefs, structures, and compiler characteristics.
|
||||
AC_C_CONST
|
||||
AC_TYPE_SIZE_T
|
||||
AC_STRUCT_TM
|
||||
# Most of these have been removed from 1.7.0 because they checked for non-ANSI-C
|
||||
# behaviors and the result were, anyway, not used by earlier versions of libpng.
|
||||
AC_C_RESTRICT
|
||||
|
||||
# Checks for library functions.
|
||||
AC_FUNC_STRTOD
|
||||
AC_CHECK_FUNCS([memset], , AC_MSG_ERROR(memset not found in libc))
|
||||
AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_MSG_ERROR(cannot find pow)) )
|
||||
AC_ARG_WITH(zlib-prefix,
|
||||
AS_HELP_STRING([[[--with-zlib-prefix]]],
|
||||
[prefix that may have been used in installed zlib]),
|
||||
[ZPREFIX=${withval}],
|
||||
[ZPREFIX='z_'])
|
||||
AC_CHECK_LIB(z, zlibVersion, ,
|
||||
AC_CHECK_LIB(z, ${ZPREFIX}zlibVersion, , AC_MSG_ERROR(zlib not installed)))
|
||||
# Checks for library functions; these need to be in order, least demanding to
|
||||
# most because the -l directives are added to the head of the list at each
|
||||
# check.
|
||||
# ANSI-C functions: all are required but they don't have to be implemented in
|
||||
# libc, it is perfectly ok to configure with an extra, wrapper, library preset
|
||||
# in LIBS. NOTE: this list may not be complete
|
||||
AC_CHECK_FUNCS([memset memcpy strncpy],,
|
||||
AC_MSG_FAILURE([missing ANSI-C functions]))
|
||||
|
||||
# floor and ceil are required for FLOATING_POINT, but they can be turned off on
|
||||
# the configure command line (and they are independent.) Default is to 'on'
|
||||
AC_ARG_ENABLE([floating-point],[Enable floating point APIs],,
|
||||
[enable_floating_point=yes])
|
||||
AC_ARG_ENABLE([fixed-point],[Enable fixed point APIs],,
|
||||
[enable_fixed_point=yes])
|
||||
AC_ARG_ENABLE([floating-arithmetic],[Use floating point arithmetic internally],,
|
||||
[enable_floating_arithmetic=yes])
|
||||
|
||||
# Check for a requirement for math library support
|
||||
if test "$enable_floating_arithmetic" = yes
|
||||
then
|
||||
AC_SEARCH_LIBS([floor],[m],,
|
||||
[AC_MSG_WARN([not found])
|
||||
enable_floating_arithmetic=no])
|
||||
AC_SEARCH_LIBS([frexp],[m],,
|
||||
[AC_MSG_WARN([not found])
|
||||
enable_floating_arithmetic=no])
|
||||
AC_SEARCH_LIBS([modf],[m],,
|
||||
[AC_MSG_WARN([not found])
|
||||
enable_floating_arithmetic=no])
|
||||
AC_SEARCH_LIBS([atof],[m],,
|
||||
[AC_MSG_WARN([not found])
|
||||
enable_floating_arithmetic=no])
|
||||
AC_SEARCH_LIBS([pow],[m],,
|
||||
[AC_MSG_WARN([not found])
|
||||
enable_floating_arithmetic=no])
|
||||
fi
|
||||
|
||||
# Set the relevant defines if required (only if required), this will override
|
||||
# anything on the command line.
|
||||
if test "$enable_floating_point" != yes
|
||||
then
|
||||
AC_MSG_NOTICE([Floating point APIs disabled])
|
||||
AC_DEFINE([PNG_NO_FLOATING_POINT],[1],
|
||||
[No support for floating point APIs])
|
||||
fi
|
||||
if test "$enable_fixed_point" != yes
|
||||
then
|
||||
AC_MSG_NOTICE([Fixed point APIs disabled])
|
||||
AC_DEFINE([PNG_NO_FIXED_POINT],[1],
|
||||
[No support for fixed point APIs])
|
||||
fi
|
||||
if test "$enable_floating_arithmetic" != yes
|
||||
then
|
||||
AC_MSG_NOTICE([Fixed point arithmetic will be used])
|
||||
AC_DEFINE([PNG_NO_FLOATING_ARITHMETIC],[1],
|
||||
[No support for floating point arithmetic])
|
||||
fi
|
||||
|
||||
# The following is for pngvalid, to ensure it catches FP errors even on
|
||||
# platforms that don't enable FP exceptions, the function appears in the math
|
||||
# library (typically), it's not an error if it is not found.
|
||||
AC_CHECK_LIB([m], [feenableexcept])
|
||||
AC_CHECK_FUNCS([feenableexcept])
|
||||
AC_SEARCH_LIBS([feenableexcept],[m],AC_DEFINE([HAVE_FEENABLEEXCEPT],[1],
|
||||
[Define to 1 if the feenableexcept function is available]))
|
||||
# Required by pngvalid:
|
||||
AC_SEARCH_LIBS([ceil],[m])
|
||||
|
||||
# zlib checks and arguments;
|
||||
# package zlib: argument is the name of the library
|
||||
# zlib-header: the name of the header file
|
||||
# zlib-prefix: the prefix for library functions, if any
|
||||
AC_ARG_WITH([zlib],
|
||||
AS_HELP_STRING([[[--with-zlib=<name>]]],
|
||||
[base name of the zlib implementation (e.g. 'z')]),,
|
||||
[with_zlib='z'])
|
||||
|
||||
z_prefix=
|
||||
AC_ARG_WITH([zlib-prefix],
|
||||
AS_HELP_STRING([[[--with-zlib-prefix=<prefix>]]],
|
||||
[prefix for zlib API functions]),
|
||||
[if test "$withval" = "" -o "$withval" = yes; then
|
||||
with_zlib_prefix='z_'
|
||||
AC_DEFINE([PNG_ZLIB_PREFIX],[z_],[Standard zlib prefix])
|
||||
elif test "${withval}" != "no"; then
|
||||
AC_DEFINE_UNQUOTED([PNG_ZLIB_PREFIX],[${withval}],
|
||||
[User defined zlib prefix])
|
||||
else
|
||||
with_zlib_prefix=
|
||||
fi
|
||||
if test "$with_zlib_prefix" != ""; then
|
||||
AC_DEFINE([Z_PREFIX],[1],[Tell zlib.h to prefix function names])
|
||||
z_prefix="#define Z_PREFIX 1"
|
||||
fi])
|
||||
|
||||
AC_ARG_WITH([zlib-header],
|
||||
AS_HELP_STRING([[[--with-zlib-header='<file>' or '"file"']]],
|
||||
[C include argument to locate zlib header file, e.g. <zlib.h>, take
|
||||
care to put single quotes round this on the command line]),
|
||||
[AC_DEFINE_UNQUOTED([PNG_ZLIB_HEADER],[${withval}],[Zlib header file])],
|
||||
with_zlib_header='<zlib.h>')
|
||||
|
||||
# AC_CHECK_LIB isn't quite enough for this because we need the special header
|
||||
# file too.
|
||||
LIBS="-l${with_zlib} $LIBS"
|
||||
AC_MSG_CHECKING(
|
||||
[[Library '${with_zlib}' and #include ${with_zlib_header} for symbol '${with_zlib_prefix}zlibVersion']])
|
||||
AC_LINK_IFELSE(
|
||||
[AC_LANG_PROGRAM(
|
||||
[[
|
||||
${z_prefix}
|
||||
#include ${with_zlib_header}
|
||||
]],
|
||||
[[(void)${with_zlib_prefix}zlibVersion();]])],
|
||||
AC_MSG_RESULT([ok]),
|
||||
AC_MSG_FAILURE([not found]))
|
||||
|
||||
AC_MSG_CHECKING([if using Solaris linker])
|
||||
SLD=`$LD --version 2>&1 | grep Solaris`
|
||||
@@ -233,24 +334,59 @@ AC_ARG_WITH(libpng-prefix,
|
||||
fi])
|
||||
AM_CONDITIONAL([DO_PNG_PREFIX], [test "${with_libpng_prefix:-no}" != "no"])
|
||||
|
||||
# Because GCC by default assembles code with an executable stack, even though it
|
||||
# compiles C code with a non-executable stack, it is necessary to do a fixup
|
||||
# here (this may by GCC specific)
|
||||
AC_SUBST([AM_CCASFLAGS], [-Wa,--noexecstack])
|
||||
# HOST SPECIFIC OPTIONS
|
||||
# =====================
|
||||
#
|
||||
# ARM
|
||||
# ===
|
||||
#
|
||||
# ARM NEON (SIMD) support.
|
||||
|
||||
AC_ARG_ENABLE([arm-neon],
|
||||
AS_HELP_STRING([[[--enable-arm-neon]]], [Enable ARM NEON optimizations]),
|
||||
[if test "${enableval}" = "yes"; then
|
||||
AC_DEFINE([PNG_ARM_NEON], [1], [Enable ARM NEON optimizations])
|
||||
AC_DEFINE([PNG_ALIGNED_MEMORY_SUPPORTED], [1], [Align row buffers])
|
||||
fi])
|
||||
AM_CONDITIONAL([PNG_ARM_NEON], [test "${enable_arm_neon:-no}" = yes])
|
||||
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*) :;;
|
||||
*) test "$enable_arm_neon" != '';;
|
||||
esac])
|
||||
|
||||
AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
|
||||
|
||||
# Config files, substituting as above
|
||||
AC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in])
|
||||
AC_CONFIG_FILES([libpng-config:libpng-config.in],
|
||||
[chmod +x libpng-config])
|
||||
AC_CONFIG_FILES([Makefile libpng.pc])
|
||||
AC_CONFIG_FILES([libpng-config], [chmod +x libpng-config])
|
||||
|
||||
AC_OUTPUT
|
||||
|
||||
@@ -37,7 +37,7 @@ component(png_const_bytep row, png_uint_32 x, unsigned int c,
|
||||
* bytes wide. Since the row fitted into memory, however, the following must
|
||||
* work:
|
||||
*/
|
||||
png_uint_32 bit_offset_hi = bit_depth * ((x >> 6) * channels + c);
|
||||
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)(((PNG_CONST png_byte (*)[8])row) + bit_offset_hi);
|
||||
|
||||
@@ -23,9 +23,9 @@
|
||||
|
||||
# macros --------------------------------------------------------------------
|
||||
|
||||
PNGINC = -I/usr/local/include/libpng16
|
||||
PNGLIB = -L/usr/local/lib -lpng16 # dynamically linked against libpng
|
||||
#PNGLIB = /usr/local/lib/libpng16.a # statically linked against libpng
|
||||
PNGINC = -I/usr/local/include/libpng17
|
||||
PNGLIB = -L/usr/local/lib -lpng17 # dynamically linked against libpng
|
||||
#PNGLIB = /usr/local/lib/libpng17.a # statically linked against libpng
|
||||
# or:
|
||||
#PNGINC = -I../..
|
||||
#PNGLIB = -L../.. -lpng
|
||||
|
||||
@@ -26,14 +26,14 @@
|
||||
# macros --------------------------------------------------------------------
|
||||
|
||||
#PNGDIR = /usr/local/lib
|
||||
#PNGINC = -I/usr/local/include/libpng16
|
||||
#PNGLIBd = -L$(PNGDIR) -lpng16 # dynamically linked, installed libpng
|
||||
#PNGLIBs = $(PNGDIR)/libpng16.a # statically linked, installed libpng
|
||||
#PNGINC = -I/usr/local/include/libpng17
|
||||
#PNGLIBd = -L$(PNGDIR) -lpng17 # dynamically linked, installed libpng
|
||||
#PNGLIBs = $(PNGDIR)/libpng17.a # statically linked, installed libpng
|
||||
# or:
|
||||
PNGDIR = ../..# this one is for libpng-x.y.z/contrib/gregbook builds
|
||||
#PNGDIR = ../libpng
|
||||
PNGINC = -I$(PNGDIR)
|
||||
PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng16 # dynamically linked
|
||||
PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng17 # dynamically linked
|
||||
PNGLIBs = $(PNGDIR)/libpng.a # statically linked, local libpng
|
||||
|
||||
ZDIR = /usr/local/lib
|
||||
|
||||
@@ -215,6 +215,10 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
|
||||
* libpng function */
|
||||
|
||||
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);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
57
contrib/libtests/fakepng.c
Normal file
57
contrib/libtests/fakepng.c
Normal file
@@ -0,0 +1,57 @@
|
||||
/* Fake a PNG - just write it out directly. */
|
||||
#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);
|
||||
}
|
||||
@@ -83,7 +83,7 @@
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H)
|
||||
#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
@@ -440,7 +440,7 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
|
||||
/* Palette with fixed color: the image rows are all 0 and the image width
|
||||
* is 16.
|
||||
*/
|
||||
memset(row, rowbytes, 0);
|
||||
memset(row, 0, rowbytes);
|
||||
}
|
||||
|
||||
else if (colors[0] == channels_of_type(color_type))
|
||||
@@ -624,8 +624,8 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
|
||||
|
||||
gamma_table[0] = 0;
|
||||
|
||||
for (i=0; i<255; ++i)
|
||||
gamma_table[i] = (png_byte)floor(pow(i/255.,conv) * 255 + 127.5);
|
||||
for (i=1; i<255; ++i)
|
||||
gamma_table[i] = (png_byte)floor(pow(i/255.,conv) * 255 + .5);
|
||||
|
||||
gamma_table[255] = 255;
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
|
||||
#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H)
|
||||
#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
@@ -62,6 +62,12 @@
|
||||
# define aligncastconst(type, value) ((const void*)(value))
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* During parallel runs of pngstest each temporary file needs a unique name,
|
||||
* this is used to permit uniqueness using a command line argument which can be
|
||||
* up to 22 characters long.
|
||||
*/
|
||||
static char tmpf[23] = "TMP";
|
||||
|
||||
/* Generate random bytes. This uses a boring repeatable algorithm and it
|
||||
* is implemented here so that it gives the same set of numbers on every
|
||||
* architecture. It's a linear congruential generator (Knuth or Sedgewick
|
||||
@@ -309,6 +315,7 @@ compare_16bit(int v1, int v2, int error_limit, int multiple_algorithms)
|
||||
#define KEEP_GOING 32
|
||||
#define ACCUMULATE 64
|
||||
#define FAST_WRITE 128
|
||||
#define sRGB_16BIT 256
|
||||
|
||||
static void
|
||||
print_opts(png_uint_32 opts)
|
||||
@@ -329,6 +336,8 @@ print_opts(png_uint_32 opts)
|
||||
printf(" --accumulate");
|
||||
if (!(opts & FAST_WRITE)) /* --fast is currently the default */
|
||||
printf(" --slow");
|
||||
if (opts & sRGB_16BIT)
|
||||
printf(" --sRGB-16bit");
|
||||
}
|
||||
|
||||
#define FORMAT_NO_CHANGE 0x80000000 /* additional flag */
|
||||
@@ -3020,6 +3029,10 @@ read_file(Image *image, png_uint_32 format, png_const_colorp background)
|
||||
return logerror(image, "file init: ", image->file_name, "");
|
||||
}
|
||||
|
||||
/* This must be set after the begin_read call: */
|
||||
if (image->opts & sRGB_16BIT)
|
||||
image->image.flags |= PNG_IMAGE_FLAG_16BIT_sRGB;
|
||||
|
||||
/* Have an initialized image with all the data we need plus, maybe, an
|
||||
* allocated file (myfile) or buffer (mybuffer) that need to be freed.
|
||||
*/
|
||||
@@ -3198,7 +3211,7 @@ write_one_file(Image *output, Image *image, int convert_to_8bit)
|
||||
static int counter = 0;
|
||||
char name[32];
|
||||
|
||||
sprintf(name, "TMP%d.png", ++counter);
|
||||
sprintf(name, "%s%d.png", tmpf, ++counter);
|
||||
|
||||
if (png_image_write_to_file(&image->image, name, convert_to_8bit,
|
||||
image->buffer+16, (png_int_32)image->stride, image->colormap))
|
||||
@@ -3482,6 +3495,34 @@ main(int argc, char **argv)
|
||||
opts &= ~KEEP_GOING;
|
||||
else if (strcmp(arg, "--strict") == 0)
|
||||
opts |= STRICT;
|
||||
else if (strcmp(arg, "--sRGB-16bit") == 0)
|
||||
opts |= sRGB_16BIT;
|
||||
else if (strcmp(arg, "--linear-16bit") == 0)
|
||||
opts &= ~sRGB_16BIT;
|
||||
else if (strcmp(arg, "--tmpfile") == 0)
|
||||
{
|
||||
if (c+1 < argc)
|
||||
{
|
||||
if (strlen(argv[++c]) >= sizeof tmpf)
|
||||
{
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "%s: %s is too long for a temp file prefix\n",
|
||||
argv[0], argv[c]);
|
||||
exit(99);
|
||||
}
|
||||
|
||||
/* Safe: checked above */
|
||||
strcpy(tmpf, argv[c]);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "%s: %s requires a temporary file prefix\n",
|
||||
argv[0], arg);
|
||||
exit(99);
|
||||
}
|
||||
}
|
||||
else if (strcmp(arg, "--touch") == 0)
|
||||
{
|
||||
if (c+1 < argc)
|
||||
@@ -3492,7 +3533,7 @@ main(int argc, char **argv)
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "%s: %s requires a file name argument\n",
|
||||
argv[0], arg);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
}
|
||||
else if (arg[0] == '+')
|
||||
@@ -3500,7 +3541,7 @@ main(int argc, char **argv)
|
||||
png_uint_32 format = formatof(arg+1);
|
||||
|
||||
if (format > FORMAT_COUNT)
|
||||
exit(1);
|
||||
exit(99);
|
||||
|
||||
format_set(&formats, format);
|
||||
}
|
||||
@@ -3508,7 +3549,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "%s: unknown option: %s\n", argv[0], arg);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3557,7 +3598,7 @@ main(int argc, char **argv)
|
||||
buffer[4095] = 0;
|
||||
fprintf(stderr, "%s...%s: file name too long\n", buffer,
|
||||
buffer+(4096-32));
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3676,7 +3717,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "%s: write failed\n", touch);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3684,7 +3725,7 @@ main(int argc, char **argv)
|
||||
{
|
||||
fflush(stdout);
|
||||
fprintf(stderr, "%s: open failed\n", touch);
|
||||
exit(1);
|
||||
exit(99);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3695,6 +3736,7 @@ main(int argc, char **argv)
|
||||
int main(void)
|
||||
{
|
||||
fprintf(stderr, "pngstest: no read support in libpng, test skipped\n");
|
||||
return 0;
|
||||
/* So the test is skipped: */
|
||||
return 77;
|
||||
}
|
||||
#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */
|
||||
|
||||
@@ -75,42 +75,8 @@ typedef png_byte *png_const_bytep;
|
||||
# define png_const_structp png_structp
|
||||
#endif
|
||||
|
||||
|
||||
/* Copied from pngpriv.h */
|
||||
#define PNG_32b(b,s) ((png_uint_32)(b) << (s))
|
||||
#define PNG_CHUNK(b1,b2,b3,b4) \
|
||||
(PNG_32b(b1,24) | PNG_32b(b2,16) | PNG_32b(b3,8) | PNG_32b(b4,0))
|
||||
|
||||
#define png_IHDR PNG_CHUNK( 73, 72, 68, 82)
|
||||
#define png_IDAT PNG_CHUNK( 73, 68, 65, 84)
|
||||
#define png_IEND PNG_CHUNK( 73, 69, 78, 68)
|
||||
#define png_PLTE PNG_CHUNK( 80, 76, 84, 69)
|
||||
#define png_bKGD PNG_CHUNK( 98, 75, 71, 68)
|
||||
#define png_cHRM PNG_CHUNK( 99, 72, 82, 77)
|
||||
#define png_gAMA PNG_CHUNK(103, 65, 77, 65)
|
||||
#define png_hIST PNG_CHUNK(104, 73, 83, 84)
|
||||
#define png_iCCP PNG_CHUNK(105, 67, 67, 80)
|
||||
#define png_iTXt PNG_CHUNK(105, 84, 88, 116)
|
||||
#define png_oFFs PNG_CHUNK(111, 70, 70, 115)
|
||||
#define png_pCAL PNG_CHUNK(112, 67, 65, 76)
|
||||
#define png_sCAL PNG_CHUNK(115, 67, 65, 76)
|
||||
#define png_pHYs PNG_CHUNK(112, 72, 89, 115)
|
||||
#define png_sBIT PNG_CHUNK(115, 66, 73, 84)
|
||||
#define png_sPLT PNG_CHUNK(115, 80, 76, 84)
|
||||
#define png_sRGB PNG_CHUNK(115, 82, 71, 66)
|
||||
#define png_sTER PNG_CHUNK(115, 84, 69, 82)
|
||||
#define png_tEXt PNG_CHUNK(116, 69, 88, 116)
|
||||
#define png_tIME PNG_CHUNK(116, 73, 77, 69)
|
||||
#define png_tRNS PNG_CHUNK(116, 82, 78, 83)
|
||||
#define png_zTXt PNG_CHUNK(122, 84, 88, 116)
|
||||
#define png_vpAg PNG_CHUNK('v', 'p', 'A', 'g')
|
||||
|
||||
/* Test on flag values as defined in the spec (section 5.4): */
|
||||
#define PNG_CHUNK_ANCILLARY(c ) (1 & ((c) >> 29))
|
||||
#define PNG_CHUNK_CRITICAL(c) (!PNG_CHUNK_ANCILLARY(c))
|
||||
#define PNG_CHUNK_PRIVATE(c) (1 & ((c) >> 21))
|
||||
#define PNG_CHUNK_RESERVED(c) (1 & ((c) >> 13))
|
||||
#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >> 5))
|
||||
/* Types of chunks not know to libpng */
|
||||
#define png_vpAg PNG_U32(118, 112, 65, 103)
|
||||
|
||||
/* Chunk information */
|
||||
#define PNG_INFO_tEXt 0x10000000U
|
||||
@@ -139,23 +105,128 @@ static struct
|
||||
{ "PLTE", PNG_INFO_PLTE, png_PLTE, 0, 0, ABSENT, 0 },
|
||||
|
||||
/* Non-critical chunks that libpng handles */
|
||||
{ "bKGD", PNG_INFO_bKGD, png_bKGD, 0, 1, START, 0 },
|
||||
{ "cHRM", PNG_INFO_cHRM, png_cHRM, 0, 1, START, 0 },
|
||||
{ "gAMA", PNG_INFO_gAMA, png_gAMA, 0, 1, START, 0 },
|
||||
{ "hIST", PNG_INFO_hIST, png_hIST, 0, 1, ABSENT, 0 },
|
||||
{ "iCCP", PNG_INFO_iCCP, png_iCCP, 0, 1, ABSENT, 0 },
|
||||
{ "iTXt", PNG_INFO_iTXt, png_iTXt, 0, 1, ABSENT, 0 },
|
||||
{ "oFFs", PNG_INFO_oFFs, png_oFFs, 0, 1, START, 0 },
|
||||
{ "pCAL", PNG_INFO_pCAL, png_pCAL, 0, 1, START, 0 },
|
||||
{ "pHYs", PNG_INFO_pHYs, png_pHYs, 0, 1, START, 0 },
|
||||
{ "sBIT", PNG_INFO_sBIT, png_sBIT, 0, 1, START, 0 },
|
||||
{ "sCAL", PNG_INFO_sCAL, png_sCAL, 0, 1, START, 0 },
|
||||
{ "sPLT", PNG_INFO_sPLT, png_sPLT, 0, 1, ABSENT, 0 },
|
||||
{ "sRGB", PNG_INFO_sRGB, png_sRGB, 0, 1, START, 0 },
|
||||
{ "tEXt", PNG_INFO_tEXt, png_tEXt, 0, 1, START, 0 },
|
||||
{ "tIME", PNG_INFO_tIME, png_tIME, 0, 1, START, 0 },
|
||||
{ "tRNS", PNG_INFO_tRNS, png_tRNS, 0, 0, ABSENT, 0 },
|
||||
{ "zTXt", PNG_INFO_zTXt, png_zTXt, 0, 1, END, 0 },
|
||||
/* This is a mess but it seems to be the only way to do it - there is no way to
|
||||
* check for definition outside a #if.
|
||||
*/
|
||||
{ "bKGD", PNG_INFO_bKGD, png_bKGD,
|
||||
# ifdef PNG_READ_bKGD_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "cHRM", PNG_INFO_cHRM, png_cHRM,
|
||||
# ifdef PNG_READ_cHRM_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "gAMA", PNG_INFO_gAMA, png_gAMA,
|
||||
# ifdef PNG_READ_gAMA_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "hIST", PNG_INFO_hIST, png_hIST,
|
||||
# ifdef PNG_READ_hIST_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, ABSENT, 0 },
|
||||
{ "iCCP", PNG_INFO_iCCP, png_iCCP,
|
||||
# ifdef PNG_READ_iCCP_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, ABSENT, 0 },
|
||||
{ "iTXt", PNG_INFO_iTXt, png_iTXt,
|
||||
# ifdef PNG_READ_iTXt_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, ABSENT, 0 },
|
||||
{ "oFFs", PNG_INFO_oFFs, png_oFFs,
|
||||
# ifdef PNG_READ_oFFs_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "pCAL", PNG_INFO_pCAL, png_pCAL,
|
||||
# ifdef PNG_READ_pCAL_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "pHYs", PNG_INFO_pHYs, png_pHYs,
|
||||
# ifdef PNG_READ_pHYs_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "sBIT", PNG_INFO_sBIT, png_sBIT,
|
||||
# ifdef PNG_READ_sBIT_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "sCAL", PNG_INFO_sCAL, png_sCAL,
|
||||
# ifdef PNG_READ_sCAL_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "sPLT", PNG_INFO_sPLT, png_sPLT,
|
||||
# ifdef PNG_READ_sPLT_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, ABSENT, 0 },
|
||||
{ "sRGB", PNG_INFO_sRGB, png_sRGB,
|
||||
# ifdef PNG_READ_sRGB_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "tEXt", PNG_INFO_tEXt, png_tEXt,
|
||||
# ifdef PNG_READ_tEXt_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "tIME", PNG_INFO_tIME, png_tIME,
|
||||
# ifdef PNG_READ_tIME_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, START, 0 },
|
||||
{ "tRNS", PNG_INFO_tRNS, png_tRNS,
|
||||
# ifdef PNG_READ_tRNS_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
0, ABSENT, 0 },
|
||||
{ "zTXt", PNG_INFO_zTXt, png_zTXt,
|
||||
# ifdef PNG_READ_zTXt_SUPPORTED
|
||||
0,
|
||||
# else
|
||||
1,
|
||||
# endif
|
||||
1, END, 0 },
|
||||
|
||||
/* No libpng handling */
|
||||
{ "sTER", PNG_INFO_sTER, png_sTER, 1, 1, START, 0 },
|
||||
@@ -212,13 +283,13 @@ find_by_flag(png_uint_32 flag)
|
||||
static int
|
||||
ancillary(const char *name)
|
||||
{
|
||||
return PNG_CHUNK_ANCILLARY(PNG_CHUNK(name[0], name[1], name[2], name[3]));
|
||||
return PNG_CHUNK_ANCILLARY(PNG_U32(name[0], name[1], name[2], name[3]));
|
||||
}
|
||||
|
||||
static int
|
||||
ancillaryb(const png_byte *name)
|
||||
{
|
||||
return PNG_CHUNK_ANCILLARY(PNG_CHUNK(name[0], name[1], name[2], name[3]));
|
||||
return PNG_CHUNK_ANCILLARY(PNG_U32(name[0], name[1], name[2], name[3]));
|
||||
}
|
||||
|
||||
/* Type of an error_ptr */
|
||||
@@ -308,7 +379,7 @@ warning(png_structp png_ptr, const char *message)
|
||||
}
|
||||
|
||||
static png_uint_32
|
||||
get_valid(display *d, png_const_infop info_ptr)
|
||||
get_valid(display *d, png_infop info_ptr)
|
||||
{
|
||||
png_uint_32 flags = png_get_valid(d->png_ptr, info_ptr, (png_uint_32)~0);
|
||||
|
||||
@@ -340,7 +411,7 @@ get_valid(display *d, png_const_infop info_ptr)
|
||||
}
|
||||
|
||||
static png_uint_32
|
||||
get_unknown(display *d, int def, png_const_infop info_ptr)
|
||||
get_unknown(display *d, int def, png_infop info_ptr)
|
||||
{
|
||||
/* Create corresponding 'unknown' flags */
|
||||
png_uint_32 flags = 0;
|
||||
@@ -955,6 +1026,7 @@ main(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
" test ignored because libpng was not built with unknown chunk support\n");
|
||||
return 0;
|
||||
/* So the test is skipped: */
|
||||
return 77;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H)
|
||||
#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
@@ -39,8 +39,10 @@
|
||||
*/
|
||||
#ifdef PNG_FREESTANDING_TESTS
|
||||
# include <png.h>
|
||||
# include <zlib.h> /* For crc32 */
|
||||
#else
|
||||
# include "../../png.h"
|
||||
# include PNG_ZLIB_HEADER
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED /* else pngvalid can do nothing */
|
||||
@@ -88,8 +90,6 @@ typedef png_byte *png_const_bytep;
|
||||
# define png_const_structp png_structp
|
||||
#endif
|
||||
|
||||
#include <zlib.h> /* For crc32 */
|
||||
|
||||
#include <float.h> /* For floating point constants */
|
||||
#include <stdlib.h> /* For malloc */
|
||||
#include <string.h> /* For memcpy, memset */
|
||||
@@ -344,11 +344,16 @@ standard_name_from_id(char *buffer, size_t bufsize, size_t pos, png_uint_32 id)
|
||||
|
||||
static int
|
||||
next_format(png_bytep colour_type, png_bytep bit_depth,
|
||||
unsigned int* palette_number)
|
||||
unsigned int* palette_number, int no_low_depth_gray)
|
||||
{
|
||||
if (*bit_depth == 0)
|
||||
{
|
||||
*colour_type = 0, *bit_depth = 1, *palette_number = 0;
|
||||
*colour_type = 0;
|
||||
if (no_low_depth_gray)
|
||||
*bit_depth = 8;
|
||||
else
|
||||
*bit_depth = 1;
|
||||
*palette_number = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -1828,6 +1833,7 @@ typedef struct png_modifier
|
||||
double maxout16; /* Maximum output value error */
|
||||
double maxabs16; /* Absolute sample error 0..1 */
|
||||
double maxcalc16;/* Absolute sample error 0..1 */
|
||||
double maxcalcG; /* Absolute sample error 0..1 */
|
||||
double maxpc16; /* Percentage sample error 0..100% */
|
||||
|
||||
/* This is set by transforms that need to allow a higher limit, it is an
|
||||
@@ -1867,10 +1873,15 @@ typedef struct png_modifier
|
||||
/* Run the odd-sized image and interlace read/write tests? */
|
||||
unsigned int test_size :1;
|
||||
|
||||
/* Run tests on reading with a combiniation of transforms, */
|
||||
/* Run tests on reading with a combination of transforms, */
|
||||
unsigned int test_transform :1;
|
||||
|
||||
/* When to use the use_input_precision option: */
|
||||
/* When to use the use_input_precision option, this controls the gamma
|
||||
* validation code checks. If set any value that is within the transformed
|
||||
* range input-.5 to input+.5 will be accepted, otherwise the value must be
|
||||
* within the normal limits. It should not be necessary to set this; the
|
||||
* result should always be exact within the permitted error limits.
|
||||
*/
|
||||
unsigned int use_input_precision :1;
|
||||
unsigned int use_input_precision_sbit :1;
|
||||
unsigned int use_input_precision_16to8 :1;
|
||||
@@ -1880,8 +1891,8 @@ typedef struct png_modifier
|
||||
*/
|
||||
unsigned int calculations_use_input_precision :1;
|
||||
|
||||
/* If set assume that the calculations are done in 16 bits even if both input
|
||||
* and output are 8 bit or less.
|
||||
/* If set assume that the calculations are done in 16 bits even if the sample
|
||||
* depth is 8 bits.
|
||||
*/
|
||||
unsigned int assume_16_bit_calculations :1;
|
||||
|
||||
@@ -1936,6 +1947,7 @@ modifier_init(png_modifier *pm)
|
||||
pm->test_uses_encoding = 0;
|
||||
pm->maxout8 = pm->maxpc8 = pm->maxabs8 = pm->maxcalc8 = 0;
|
||||
pm->maxout16 = pm->maxpc16 = pm->maxabs16 = pm->maxcalc16 = 0;
|
||||
pm->maxcalcG = 0;
|
||||
pm->limit = 4E-3;
|
||||
pm->log8 = pm->log16 = 0; /* Means 'off' */
|
||||
pm->error_gray_2 = pm->error_gray_4 = pm->error_gray_8 = 0;
|
||||
@@ -1950,6 +1962,7 @@ modifier_init(png_modifier *pm)
|
||||
pm->use_input_precision_sbit = 0;
|
||||
pm->use_input_precision_16to8 = 0;
|
||||
pm->calculations_use_input_precision = 0;
|
||||
pm->assume_16_bit_calculations = 0;
|
||||
pm->test_gamma_threshold = 0;
|
||||
pm->test_gamma_transform = 0;
|
||||
pm->test_gamma_sbit = 0;
|
||||
@@ -1964,8 +1977,16 @@ modifier_init(png_modifier *pm)
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||
|
||||
/* This controls use of checks that explicitly know how libpng digitizes the
|
||||
* samples in calculations; setting this circumvents simple error limit checking
|
||||
* in the rgb_to_gray check, replacing it with an exact copy of the libpng 1.5
|
||||
* algorithm.
|
||||
*/
|
||||
#define DIGITIZE PNG_LIBPNG_VER < 10700
|
||||
|
||||
/* If pm->calculations_use_input_precision is set then operations will happen
|
||||
* with only 8 bit precision unless both the input and output bit depth are 16.
|
||||
* with the precision of the input, not the precision of the output depth.
|
||||
*
|
||||
* If pm->assume_16_bit_calculations is set then even 8 bit calculations use 16
|
||||
* bit precision. This only affects those of the following limits that pertain
|
||||
@@ -1973,8 +1994,8 @@ modifier_init(png_modifier *pm)
|
||||
* called directly.
|
||||
*/
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
static double digitize(PNG_CONST png_modifier *pm, double value,
|
||||
int sample_depth, int do_round)
|
||||
#if DIGITIZE
|
||||
static double digitize(double value, int depth, int do_round)
|
||||
{
|
||||
/* 'value' is in the range 0 to 1, the result is the same value rounded to a
|
||||
* multiple of the digitization factor - 8 or 16 bits depending on both the
|
||||
@@ -1982,14 +2003,14 @@ static double digitize(PNG_CONST png_modifier *pm, double value,
|
||||
* rounding and 'do_round' should be 1, if it is 0 the digitized value will
|
||||
* be truncated.
|
||||
*/
|
||||
PNG_CONST unsigned int digitization_factor =
|
||||
(pm->assume_16_bit_calculations || sample_depth == 16) ? 65535 : 255;
|
||||
PNG_CONST unsigned int digitization_factor = (1U << depth) -1;
|
||||
|
||||
/* Limiting the range is done as a convenience to the caller - it's easier to
|
||||
* do it once here than every time at the call site.
|
||||
*/
|
||||
if (value <= 0)
|
||||
value = 0;
|
||||
|
||||
else if (value >= 1)
|
||||
value = 1;
|
||||
|
||||
@@ -1998,31 +2019,30 @@ static double digitize(PNG_CONST png_modifier *pm, double value,
|
||||
return floor(value)/digitization_factor;
|
||||
}
|
||||
#endif
|
||||
#endif /* RGB_TO_GRAY */
|
||||
|
||||
#if (defined PNG_READ_GAMMA_SUPPORTED) ||\
|
||||
(defined PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
static double abserr(PNG_CONST png_modifier *pm, int in_depth, int out_depth)
|
||||
{
|
||||
/* Absolute error permitted in linear values - affected by the bit depth of
|
||||
* the calculations.
|
||||
*/
|
||||
if (pm->assume_16_bit_calculations || (out_depth == 16 && (in_depth == 16 ||
|
||||
!pm->calculations_use_input_precision)))
|
||||
if (pm->assume_16_bit_calculations ||
|
||||
(pm->calculations_use_input_precision ? in_depth : out_depth) == 16)
|
||||
return pm->maxabs16;
|
||||
else
|
||||
return pm->maxabs8;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
static double calcerr(PNG_CONST png_modifier *pm, int in_depth, int out_depth)
|
||||
{
|
||||
/* Error in the linear composition arithmetic - only relevant when
|
||||
* composition actually happens (0 < alpha < 1).
|
||||
*/
|
||||
if (pm->assume_16_bit_calculations || (out_depth == 16 && (in_depth == 16 ||
|
||||
!pm->calculations_use_input_precision)))
|
||||
if ((pm->calculations_use_input_precision ? in_depth : out_depth) == 16)
|
||||
return pm->maxcalc16;
|
||||
else if (pm->assume_16_bit_calculations)
|
||||
return pm->maxcalcG;
|
||||
else
|
||||
return pm->maxcalc8;
|
||||
}
|
||||
@@ -2032,8 +2052,8 @@ static double pcerr(PNG_CONST png_modifier *pm, int in_depth, int out_depth)
|
||||
/* Percentage error permitted in the linear values. Note that the specified
|
||||
* value is a percentage but this routine returns a simple number.
|
||||
*/
|
||||
if (pm->assume_16_bit_calculations || (out_depth == 16 && (in_depth == 16 ||
|
||||
!pm->calculations_use_input_precision)))
|
||||
if (pm->assume_16_bit_calculations ||
|
||||
(pm->calculations_use_input_precision ? in_depth : out_depth) == 16)
|
||||
return pm->maxpc16 * .01;
|
||||
else
|
||||
return pm->maxpc8 * .01;
|
||||
@@ -2065,8 +2085,7 @@ static double outerr(PNG_CONST png_modifier *pm, int in_depth, int out_depth)
|
||||
if (out_depth == 4)
|
||||
return .90644-.5;
|
||||
|
||||
if (out_depth == 16 && (in_depth == 16 ||
|
||||
!pm->calculations_use_input_precision))
|
||||
if ((pm->calculations_use_input_precision ? in_depth : out_depth) == 16)
|
||||
return pm->maxout16;
|
||||
|
||||
/* This is the case where the value was calculated at 8-bit precision then
|
||||
@@ -2099,8 +2118,7 @@ static double outlog(PNG_CONST png_modifier *pm, int in_depth, int out_depth)
|
||||
return pm->log8;
|
||||
}
|
||||
|
||||
if (out_depth == 16 && (in_depth == 16 ||
|
||||
!pm->calculations_use_input_precision))
|
||||
if ((pm->calculations_use_input_precision ? in_depth : out_depth) == 16)
|
||||
{
|
||||
if (pm->log16 == 0)
|
||||
return 65536;
|
||||
@@ -2125,8 +2143,8 @@ static double outlog(PNG_CONST png_modifier *pm, int in_depth, int out_depth)
|
||||
static int output_quantization_factor(PNG_CONST png_modifier *pm, int in_depth,
|
||||
int out_depth)
|
||||
{
|
||||
if (out_depth == 16 && in_depth != 16
|
||||
&& pm->calculations_use_input_precision)
|
||||
if (out_depth == 16 && in_depth != 16 &&
|
||||
pm->calculations_use_input_precision)
|
||||
return 257;
|
||||
else
|
||||
return 1;
|
||||
@@ -3357,7 +3375,7 @@ make_transform_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
|
||||
PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
# if (defined PNG_READ_zTXt_SUPPORTED) && (defined PNG_WRITE_zTXt_SUPPORTED)
|
||||
# if defined(PNG_READ_zTXt_SUPPORTED) && defined(PNG_WRITE_zTXt_SUPPORTED)
|
||||
# define TEXT_COMPRESSION PNG_TEXT_COMPRESSION_zTXt
|
||||
# else
|
||||
# define TEXT_COMPRESSION PNG_TEXT_COMPRESSION_NONE
|
||||
@@ -3473,7 +3491,7 @@ make_transform_images(png_store *ps)
|
||||
/* Use next_format to enumerate all the combinations we test, including
|
||||
* generating multiple low bit depth palette images.
|
||||
*/
|
||||
while (next_format(&colour_type, &bit_depth, &palette_number))
|
||||
while (next_format(&colour_type, &bit_depth, &palette_number, 0))
|
||||
{
|
||||
int interlace_type;
|
||||
|
||||
@@ -4599,9 +4617,13 @@ progressive_row(png_structp ppIn, png_bytep new_row, png_uint_32 y, int pass)
|
||||
}
|
||||
else
|
||||
png_progressive_combine_row(pp, row, new_row);
|
||||
} else if (dp->interlace_type == PNG_INTERLACE_ADAM7 &&
|
||||
PNG_ROW_IN_INTERLACE_PASS(y, pass) &&
|
||||
PNG_PASS_COLS(dp->w, pass) > 0)
|
||||
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
else if (dp->interlace_type == PNG_INTERLACE_ADAM7 &&
|
||||
PNG_ROW_IN_INTERLACE_PASS(y, pass) &&
|
||||
PNG_PASS_COLS(dp->w, pass) > 0)
|
||||
png_error(pp, "missing row in progressive de-interlacing");
|
||||
#endif /* PNG_READ_INTERLACING_SUPPORTED */
|
||||
}
|
||||
@@ -4754,7 +4776,7 @@ standard_check_text(png_const_structp pp, png_const_textp tp,
|
||||
|
||||
static void
|
||||
standard_text_validate(standard_display *dp, png_const_structp pp,
|
||||
png_const_infop pi)
|
||||
png_infop pi)
|
||||
{
|
||||
png_textp tp = NULL;
|
||||
png_uint_32 num_text = png_get_text(pp, pi, &tp, NULL);
|
||||
@@ -5784,12 +5806,9 @@ transform_image_validate(transform_display *dp, png_const_structp pp,
|
||||
|
||||
memset(out_palette, 0x5e, sizeof out_palette);
|
||||
|
||||
/* assume-8-bit-calculations means assume that if the input has 8 bit
|
||||
* (or less) samples and the output has 16 bit samples the calculations
|
||||
* will be done with 8 bit precision, not 16.
|
||||
*
|
||||
* TODO: fix this in libpng; png_set_expand_16 should cause 16 bit
|
||||
* calculations to be used throughout.
|
||||
/* use-input-precision means assume that if the input has 8 bit (or less)
|
||||
* samples and the output has 16 bit samples the calculations will be done
|
||||
* with 8 bit precision, not 16.
|
||||
*/
|
||||
if (in_ct == PNG_COLOR_TYPE_PALETTE || in_bd < 16)
|
||||
in_sample_depth = 8;
|
||||
@@ -5800,7 +5819,8 @@ transform_image_validate(transform_display *dp, png_const_structp pp,
|
||||
!dp->pm->calculations_use_input_precision)
|
||||
digitization_error = .5;
|
||||
|
||||
/* Else errors are at 8 bit precision, scale .5 in 8 bits to the 16 bits:
|
||||
/* Else calculations are at 8 bit precision, and the output actually
|
||||
* consists of scaled 8-bit values, so scale .5 in 8 bits to the 16 bits:
|
||||
*/
|
||||
else
|
||||
digitization_error = .5 * 257;
|
||||
@@ -6616,10 +6636,23 @@ image_transform_png_set_rgb_to_gray_ini(PNG_CONST image_transform *this,
|
||||
{
|
||||
if (that->this.bit_depth == 16 || pm->assume_16_bit_calculations)
|
||||
{
|
||||
/* The 16 bit case ends up producing a maximum error of about
|
||||
* +/-5 in 65535, allow for +/-8 with the given gamma.
|
||||
/* The computations have the form:
|
||||
*
|
||||
* r * rc + g * gc + b * bc
|
||||
*
|
||||
* Each component of which is +/-1/65535 from the gamma_to_1 table
|
||||
* lookup, resulting in a base error of +/-6. The gamma_from_1
|
||||
* conversion adds another +/-2 in the 16-bit case and
|
||||
* +/-(1<<(15-PNG_MAX_GAMMA_8)) in the 8-bit case.
|
||||
*/
|
||||
that->pm->limit += pow(8./65535, data.gamma);
|
||||
that->pm->limit += pow(
|
||||
# if PNG_MAX_GAMMA_8 < 14
|
||||
(that->this.bit_depth == 16 ? 8. :
|
||||
6. + (1<<(15-PNG_MAX_GAMMA_8)))
|
||||
# else
|
||||
8.
|
||||
# endif
|
||||
/65535, data.gamma);
|
||||
}
|
||||
|
||||
else
|
||||
@@ -6637,7 +6670,7 @@ image_transform_png_set_rgb_to_gray_ini(PNG_CONST image_transform *this,
|
||||
/* With no gamma correction a large error comes from the truncation of the
|
||||
* calculation in the 8 bit case, allow for that here.
|
||||
*/
|
||||
if (that->this.bit_depth != 16)
|
||||
if (that->this.bit_depth != 16 && !pm->assume_16_bit_calculations)
|
||||
that->pm->limit += 4E-3;
|
||||
}
|
||||
}
|
||||
@@ -6782,9 +6815,14 @@ image_transform_png_set_rgb_to_gray_mod(PNG_CONST image_transform *this,
|
||||
image_pixel_convert_PLTE(that);
|
||||
|
||||
/* Image now has RGB channels... */
|
||||
# if DIGITIZE
|
||||
{
|
||||
PNG_CONST png_modifier *pm = display->pm;
|
||||
PNG_CONST unsigned int sample_depth = that->sample_depth;
|
||||
const unsigned int sample_depth = that->sample_depth;
|
||||
const unsigned int calc_depth = (pm->assume_16_bit_calculations ? 16 :
|
||||
sample_depth);
|
||||
const unsigned int gamma_depth = (sample_depth == 16 ? 16 :
|
||||
(pm->assume_16_bit_calculations ? PNG_MAX_GAMMA_8 : sample_depth));
|
||||
int isgray;
|
||||
double r, g, b;
|
||||
double rlo, rhi, glo, ghi, blo, bhi, graylo, grayhi;
|
||||
@@ -6800,28 +6838,28 @@ image_transform_png_set_rgb_to_gray_mod(PNG_CONST image_transform *this,
|
||||
*/
|
||||
r = rlo = rhi = that->redf;
|
||||
rlo -= that->rede;
|
||||
rlo = digitize(pm, rlo, sample_depth, 1/*round*/);
|
||||
rlo = digitize(rlo, calc_depth, 1/*round*/);
|
||||
rhi += that->rede;
|
||||
rhi = digitize(pm, rhi, sample_depth, 1/*round*/);
|
||||
rhi = digitize(rhi, calc_depth, 1/*round*/);
|
||||
|
||||
g = glo = ghi = that->greenf;
|
||||
glo -= that->greene;
|
||||
glo = digitize(pm, glo, sample_depth, 1/*round*/);
|
||||
glo = digitize(glo, calc_depth, 1/*round*/);
|
||||
ghi += that->greene;
|
||||
ghi = digitize(pm, ghi, sample_depth, 1/*round*/);
|
||||
ghi = digitize(ghi, calc_depth, 1/*round*/);
|
||||
|
||||
b = blo = bhi = that->bluef;
|
||||
blo -= that->bluee;
|
||||
blo = digitize(pm, blo, sample_depth, 1/*round*/);
|
||||
blo = digitize(blo, calc_depth, 1/*round*/);
|
||||
bhi += that->greene;
|
||||
bhi = digitize(pm, bhi, sample_depth, 1/*round*/);
|
||||
bhi = digitize(bhi, calc_depth, 1/*round*/);
|
||||
|
||||
isgray = r==g && g==b;
|
||||
|
||||
if (data.gamma != 1)
|
||||
{
|
||||
PNG_CONST double power = 1/data.gamma;
|
||||
PNG_CONST double abse = abserr(pm, sample_depth, sample_depth);
|
||||
PNG_CONST double abse = calc_depth == 16 ? .5/65535 : .5/255;
|
||||
|
||||
/* 'abse' is the absolute error permitted in linear calculations. It
|
||||
* is used here to capture the error permitted in the handling
|
||||
@@ -6830,16 +6868,16 @@ image_transform_png_set_rgb_to_gray_mod(PNG_CONST image_transform *this,
|
||||
* where the real errors are introduced.
|
||||
*/
|
||||
r = pow(r, power);
|
||||
rlo = digitize(pm, pow(rlo, power)-abse, sample_depth, 1);
|
||||
rhi = digitize(pm, pow(rhi, power)+abse, sample_depth, 1);
|
||||
rlo = digitize(pow(rlo, power)-abse, calc_depth, 1);
|
||||
rhi = digitize(pow(rhi, power)+abse, calc_depth, 1);
|
||||
|
||||
g = pow(g, power);
|
||||
glo = digitize(pm, pow(glo, power)-abse, sample_depth, 1);
|
||||
ghi = digitize(pm, pow(ghi, power)+abse, sample_depth, 1);
|
||||
glo = digitize(pow(glo, power)-abse, calc_depth, 1);
|
||||
ghi = digitize(pow(ghi, power)+abse, calc_depth, 1);
|
||||
|
||||
b = pow(b, power);
|
||||
blo = digitize(pm, pow(blo, power)-abse, sample_depth, 1);
|
||||
bhi = digitize(pm, pow(bhi, power)+abse, sample_depth, 1);
|
||||
blo = digitize(pow(blo, power)-abse, calc_depth, 1);
|
||||
bhi = digitize(pow(bhi, power)+abse, calc_depth, 1);
|
||||
}
|
||||
|
||||
/* Now calculate the actual gray values. Although the error in the
|
||||
@@ -6856,18 +6894,18 @@ image_transform_png_set_rgb_to_gray_mod(PNG_CONST image_transform *this,
|
||||
b * data.blue_coefficient;
|
||||
|
||||
{
|
||||
PNG_CONST int do_round = data.gamma != 1 || sample_depth == 16;
|
||||
PNG_CONST int do_round = data.gamma != 1 || calc_depth == 16;
|
||||
PNG_CONST double ce = 1. / 32768;
|
||||
|
||||
graylo = digitize(pm, rlo * (data.red_coefficient-ce) +
|
||||
graylo = digitize(rlo * (data.red_coefficient-ce) +
|
||||
glo * (data.green_coefficient-ce) +
|
||||
blo * (data.blue_coefficient-ce), sample_depth, do_round);
|
||||
blo * (data.blue_coefficient-ce), gamma_depth, do_round);
|
||||
if (graylo <= 0)
|
||||
graylo = 0;
|
||||
|
||||
grayhi = digitize(pm, rhi * (data.red_coefficient+ce) +
|
||||
grayhi = digitize(rhi * (data.red_coefficient+ce) +
|
||||
ghi * (data.green_coefficient+ce) +
|
||||
bhi * (data.blue_coefficient+ce), sample_depth, do_round);
|
||||
bhi * (data.blue_coefficient+ce), gamma_depth, do_round);
|
||||
if (grayhi >= 1)
|
||||
grayhi = 1;
|
||||
}
|
||||
@@ -6878,8 +6916,8 @@ image_transform_png_set_rgb_to_gray_mod(PNG_CONST image_transform *this,
|
||||
PNG_CONST double power = data.gamma;
|
||||
|
||||
gray = pow(gray, power);
|
||||
graylo = digitize(pm, pow(graylo, power), sample_depth, 1);
|
||||
grayhi = digitize(pm, pow(grayhi, power), sample_depth, 1);
|
||||
graylo = digitize(pow(graylo, power), sample_depth, 1);
|
||||
grayhi = digitize(pow(grayhi, power), sample_depth, 1);
|
||||
}
|
||||
|
||||
/* Now the error can be calculated.
|
||||
@@ -6897,7 +6935,7 @@ image_transform_png_set_rgb_to_gray_mod(PNG_CONST image_transform *this,
|
||||
err = fabs(graylo-gray);
|
||||
|
||||
/* Check that this worked: */
|
||||
if (err > display->pm->limit)
|
||||
if (err > pm->limit)
|
||||
{
|
||||
size_t pos = 0;
|
||||
char buffer[128];
|
||||
@@ -6905,12 +6943,120 @@ image_transform_png_set_rgb_to_gray_mod(PNG_CONST image_transform *this,
|
||||
pos = safecat(buffer, sizeof buffer, pos, "rgb_to_gray error ");
|
||||
pos = safecatd(buffer, sizeof buffer, pos, err, 6);
|
||||
pos = safecat(buffer, sizeof buffer, pos, " exceeds limit ");
|
||||
pos = safecatd(buffer, sizeof buffer, pos,
|
||||
display->pm->limit, 6);
|
||||
pos = safecatd(buffer, sizeof buffer, pos, pm->limit, 6);
|
||||
png_error(pp, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
# else /* DIGITIZE */
|
||||
{
|
||||
double r = that->redf;
|
||||
double re = that->rede;
|
||||
double g = that->greenf;
|
||||
double ge = that->greene;
|
||||
double b = that->bluef;
|
||||
double be = that->bluee;
|
||||
|
||||
/* The true gray case involves no math. */
|
||||
if (r == g && r == b)
|
||||
{
|
||||
gray = r;
|
||||
err = re;
|
||||
if (err < ge) err = ge;
|
||||
if (err < be) err = be;
|
||||
}
|
||||
|
||||
else if (data.gamma == 1)
|
||||
{
|
||||
/* There is no need to do the conversions to and from linear space,
|
||||
* so the calculation should be a lot more accurate. There is a
|
||||
* built in 1/32768 error in the coefficients because they only have
|
||||
* 15 bits and are adjusted to make sure they add up to 32768, so
|
||||
* the result may have an additional error up to 1/32768. (Note
|
||||
* that adding the 1/32768 here avoids needing to increase the
|
||||
* global error limits to take this into account.)
|
||||
*/
|
||||
gray = r * data.red_coefficient + g * data.green_coefficient +
|
||||
b * data.blue_coefficient;
|
||||
err = re * data.red_coefficient + ge * data.green_coefficient +
|
||||
be * data.blue_coefficient + 1./32768 + gray * 5 * DBL_EPSILON;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* The calculation happens in linear space, and this produces much
|
||||
* wider errors in the encoded space. These are handled here by
|
||||
* factoring the errors in to the calculation. There are two table
|
||||
* lookups in the calculation and each introduces a quantization
|
||||
* error defined by the table size.
|
||||
*/
|
||||
PNG_CONST png_modifier *pm = display->pm;
|
||||
double in_qe = (that->sample_depth > 8 ? .5/65535 : .5/255);
|
||||
double out_qe = (that->sample_depth > 8 ? .5/65535 :
|
||||
(pm->assume_16_bit_calculations ? .5/(1<<PNG_MAX_GAMMA_8) :
|
||||
.5/255));
|
||||
double rhi, ghi, bhi, grayhi;
|
||||
double g1 = 1/data.gamma;
|
||||
|
||||
rhi = r + re + in_qe; if (rhi > 1) rhi = 1;
|
||||
r -= re + in_qe; if (r < 0) r = 0;
|
||||
ghi = g + ge + in_qe; if (ghi > 1) ghi = 1;
|
||||
g -= ge + in_qe; if (g < 0) g = 0;
|
||||
bhi = b + be + in_qe; if (bhi > 1) bhi = 1;
|
||||
b -= be + in_qe; if (b < 0) b = 0;
|
||||
|
||||
r = pow(r, g1)*(1-DBL_EPSILON); rhi = pow(rhi, g1)*(1+DBL_EPSILON);
|
||||
g = pow(g, g1)*(1-DBL_EPSILON); ghi = pow(ghi, g1)*(1+DBL_EPSILON);
|
||||
b = pow(b, g1)*(1-DBL_EPSILON); bhi = pow(bhi, g1)*(1+DBL_EPSILON);
|
||||
|
||||
/* Work out the lower and upper bounds for the gray value in the
|
||||
* encoded space, then work out an average and error. Remove the
|
||||
* previously added input quantization error at this point.
|
||||
*/
|
||||
gray = r * data.red_coefficient + g * data.green_coefficient +
|
||||
b * data.blue_coefficient - 1./32768 - out_qe;
|
||||
if (gray <= 0)
|
||||
gray = 0;
|
||||
else
|
||||
{
|
||||
gray *= (1 - 6 * DBL_EPSILON);
|
||||
gray = pow(gray, data.gamma) * (1-DBL_EPSILON);
|
||||
}
|
||||
|
||||
grayhi = rhi * data.red_coefficient + ghi * data.green_coefficient +
|
||||
bhi * data.blue_coefficient + 1./32768 + out_qe;
|
||||
grayhi *= (1 + 6 * DBL_EPSILON);
|
||||
if (grayhi >= 1)
|
||||
grayhi = 1;
|
||||
else
|
||||
grayhi = pow(grayhi, data.gamma) * (1+DBL_EPSILON);
|
||||
|
||||
err = (grayhi - gray) / 2;
|
||||
gray = (grayhi + gray) / 2;
|
||||
|
||||
if (err <= in_qe)
|
||||
err = gray * DBL_EPSILON;
|
||||
|
||||
else
|
||||
err -= in_qe;
|
||||
|
||||
/* Validate that the error is within limits (this has caused
|
||||
* problems before, it's much easier to detect them here.)
|
||||
*/
|
||||
if (err > pm->limit)
|
||||
{
|
||||
size_t pos = 0;
|
||||
char buffer[128];
|
||||
|
||||
pos = safecat(buffer, sizeof buffer, pos, "rgb_to_gray error ");
|
||||
pos = safecatd(buffer, sizeof buffer, pos, err, 6);
|
||||
pos = safecat(buffer, sizeof buffer, pos, " exceeds limit ");
|
||||
pos = safecatd(buffer, sizeof buffer, pos, pm->limit, 6);
|
||||
png_error(pp, buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
# endif /* !DIGITIZE */
|
||||
|
||||
that->bluef = that->greenf = that->redf = gray;
|
||||
that->bluee = that->greene = that->rede = err;
|
||||
@@ -6959,7 +7105,7 @@ IT(rgb_to_gray);
|
||||
* int background_gamma_code, int need_expand,
|
||||
* png_fixed_point background_gamma)
|
||||
*
|
||||
* As with rgb_to_gray this ignores the gamma (at present.)
|
||||
* This ignores the gamma (at present.)
|
||||
*/
|
||||
#define data ITDATA(background)
|
||||
static image_pixel data;
|
||||
@@ -6970,6 +7116,7 @@ image_transform_png_set_background_set(PNG_CONST image_transform *this,
|
||||
{
|
||||
png_byte colour_type, bit_depth;
|
||||
png_byte random_bytes[8]; /* 8 bytes - 64 bits - the biggest pixel */
|
||||
int expand;
|
||||
png_color_16 back;
|
||||
|
||||
/* We need a background colour, because we don't know exactly what transforms
|
||||
@@ -6987,10 +7134,14 @@ image_transform_png_set_background_set(PNG_CONST image_transform *this,
|
||||
{
|
||||
colour_type = PNG_COLOR_TYPE_RGB;
|
||||
bit_depth = 8;
|
||||
expand = 0; /* passing in an RGB not a pixel index */
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
bit_depth = that->this.bit_depth;
|
||||
expand = 1;
|
||||
}
|
||||
|
||||
image_pixel_init(&data, random_bytes, colour_type,
|
||||
bit_depth, 0/*x*/, 0/*unused: palette*/);
|
||||
@@ -7011,11 +7162,9 @@ image_transform_png_set_background_set(PNG_CONST image_transform *this,
|
||||
back.gray = (png_uint_16)data.red;
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_set_background(pp, &back, PNG_BACKGROUND_GAMMA_FILE, 1/*need expand*/,
|
||||
0);
|
||||
png_set_background(pp, &back, PNG_BACKGROUND_GAMMA_FILE, expand, 0);
|
||||
# else
|
||||
png_set_background_fixed(pp, &back, PNG_BACKGROUND_GAMMA_FILE,
|
||||
1/*need expand*/, 0);
|
||||
png_set_background_fixed(pp, &back, PNG_BACKGROUND_GAMMA_FILE, expand, 0);
|
||||
# endif
|
||||
|
||||
this->next->set(this->next, that, pp, pi);
|
||||
@@ -7347,7 +7496,7 @@ perform_transform_test(png_modifier *pm)
|
||||
png_byte bit_depth = 0;
|
||||
unsigned int palette_number = 0;
|
||||
|
||||
while (next_format(&colour_type, &bit_depth, &palette_number))
|
||||
while (next_format(&colour_type, &bit_depth, &palette_number, 0))
|
||||
{
|
||||
png_uint_32 counter = 0;
|
||||
size_t base_pos;
|
||||
@@ -8032,14 +8181,25 @@ gamma_component_validate(PNG_CONST char *name, PNG_CONST validate_info *vi,
|
||||
* passed. Don't do these additional tests here - just log the
|
||||
* original [es_lo..es_hi] values.
|
||||
*/
|
||||
if (pass == 0 && vi->use_input_precision)
|
||||
if (pass == 0 && vi->use_input_precision && vi->dp->sbit)
|
||||
{
|
||||
/* Ok, something is wrong - this actually happens in current libpng
|
||||
* 16-to-8 processing. Assume that the input value (id, adjusted
|
||||
* for sbit) can be anywhere between value-.5 and value+.5 - quite a
|
||||
* large range if sbit is low.
|
||||
*
|
||||
* NOTE: at present because the libpng gamma table stuff has been
|
||||
* changed to use a rounding algorithm to correct errors in 8-bit
|
||||
* calculations the precise sbit calculation (a shift) has been
|
||||
* lost. This can result in up to a +/-1 error in the presence of
|
||||
* an sbit less than the bit depth.
|
||||
*/
|
||||
double tmp = (isbit - .5)/sbit_max;
|
||||
# if PNG_LIBPNG_VER < 10700
|
||||
# define SBIT_ERROR .5
|
||||
# else
|
||||
# define SBIT_ERROR 1.
|
||||
# endif
|
||||
double tmp = (isbit - SBIT_ERROR)/sbit_max;
|
||||
|
||||
if (tmp <= 0)
|
||||
tmp = 0;
|
||||
@@ -8058,10 +8218,10 @@ gamma_component_validate(PNG_CONST char *name, PNG_CONST validate_info *vi,
|
||||
if (is_lo < 0)
|
||||
is_lo = 0;
|
||||
|
||||
tmp = (isbit + .5)/sbit_max;
|
||||
tmp = (isbit + SBIT_ERROR)/sbit_max;
|
||||
|
||||
if (tmp <= 0)
|
||||
tmp = 0;
|
||||
if (tmp >= 1)
|
||||
tmp = 1;
|
||||
|
||||
else if (alpha >= 0 && vi->file_inverse > 0 && tmp < 1)
|
||||
tmp = pow(tmp, vi->file_inverse);
|
||||
@@ -8378,7 +8538,7 @@ gamma_image_validate(gamma_display *dp, png_const_structp pp,
|
||||
* Because there is limited precision in the input it is arguable that
|
||||
* an acceptable result is any valid result from input-.5 to input+.5.
|
||||
* The basic tests below do not do this, however if 'use_input_precision'
|
||||
* is set a subsequent test is performed below.
|
||||
* is set a subsequent test is performed above.
|
||||
*/
|
||||
PNG_CONST unsigned int samples_per_pixel = (out_ct & 2U) ? 3U : 1U;
|
||||
int processing;
|
||||
@@ -8720,7 +8880,7 @@ perform_gamma_threshold_tests(png_modifier *pm)
|
||||
* fact this test is somewhat excessive since libpng doesn't make this
|
||||
* decision based on colour type or bit depth!
|
||||
*/
|
||||
while (next_format(&colour_type, &bit_depth, &palette_number))
|
||||
while (next_format(&colour_type, &bit_depth, &palette_number, 1/*gamma*/))
|
||||
if (palette_number == 0)
|
||||
{
|
||||
double test_gamma = 1.0;
|
||||
@@ -8781,7 +8941,7 @@ static void perform_gamma_transform_tests(png_modifier *pm)
|
||||
png_byte bit_depth = 0;
|
||||
unsigned int palette_number = 0;
|
||||
|
||||
while (next_format(&colour_type, &bit_depth, &palette_number))
|
||||
while (next_format(&colour_type, &bit_depth, &palette_number, 1/*gamma*/))
|
||||
{
|
||||
unsigned int i, j;
|
||||
|
||||
@@ -8811,7 +8971,7 @@ static void perform_gamma_sbit_tests(png_modifier *pm)
|
||||
png_byte colour_type = 0, bit_depth = 0;
|
||||
unsigned int npalette = 0;
|
||||
|
||||
while (next_format(&colour_type, &bit_depth, &npalette))
|
||||
while (next_format(&colour_type, &bit_depth, &npalette, 1/*gamma*/))
|
||||
if ((colour_type & PNG_COLOR_MASK_ALPHA) == 0 &&
|
||||
((colour_type == 3 && sbit < 8) ||
|
||||
(colour_type != 3 && sbit < bit_depth)))
|
||||
@@ -8846,6 +9006,7 @@ static void perform_gamma_scale16_tests(png_modifier *pm)
|
||||
# ifndef PNG_MAX_GAMMA_8
|
||||
# define PNG_MAX_GAMMA_8 11
|
||||
# endif
|
||||
# define SBIT_16_TO_8 PNG_MAX_GAMMA_8
|
||||
/* Include the alpha cases here. Note that sbit matches the internal value
|
||||
* used by the library - otherwise we will get spurious errors from the
|
||||
* internal sbit style approximation.
|
||||
@@ -8863,28 +9024,28 @@ static void perform_gamma_scale16_tests(png_modifier *pm)
|
||||
fabs(pm->gammas[j]/pm->gammas[i]-1) >= PNG_GAMMA_THRESHOLD)
|
||||
{
|
||||
gamma_transform_test(pm, 0, 16, 0, pm->interlace_type,
|
||||
1/pm->gammas[i], pm->gammas[j], PNG_MAX_GAMMA_8,
|
||||
1/pm->gammas[i], pm->gammas[j], SBIT_16_TO_8,
|
||||
pm->use_input_precision_16to8, 1 /*scale16*/);
|
||||
|
||||
if (fail(pm))
|
||||
return;
|
||||
|
||||
gamma_transform_test(pm, 2, 16, 0, pm->interlace_type,
|
||||
1/pm->gammas[i], pm->gammas[j], PNG_MAX_GAMMA_8,
|
||||
1/pm->gammas[i], pm->gammas[j], SBIT_16_TO_8,
|
||||
pm->use_input_precision_16to8, 1 /*scale16*/);
|
||||
|
||||
if (fail(pm))
|
||||
return;
|
||||
|
||||
gamma_transform_test(pm, 4, 16, 0, pm->interlace_type,
|
||||
1/pm->gammas[i], pm->gammas[j], PNG_MAX_GAMMA_8,
|
||||
1/pm->gammas[i], pm->gammas[j], SBIT_16_TO_8,
|
||||
pm->use_input_precision_16to8, 1 /*scale16*/);
|
||||
|
||||
if (fail(pm))
|
||||
return;
|
||||
|
||||
gamma_transform_test(pm, 6, 16, 0, pm->interlace_type,
|
||||
1/pm->gammas[i], pm->gammas[j], PNG_MAX_GAMMA_8,
|
||||
1/pm->gammas[i], pm->gammas[j], SBIT_16_TO_8,
|
||||
pm->use_input_precision_16to8, 1 /*scale16*/);
|
||||
|
||||
if (fail(pm))
|
||||
@@ -8895,8 +9056,8 @@ static void perform_gamma_scale16_tests(png_modifier *pm)
|
||||
}
|
||||
#endif /* 16 to 8 bit conversion */
|
||||
|
||||
#if defined PNG_READ_BACKGROUND_SUPPORTED ||\
|
||||
defined PNG_READ_ALPHA_MODE_SUPPORTED
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||
static void gamma_composition_test(png_modifier *pm,
|
||||
PNG_CONST png_byte colour_type, PNG_CONST png_byte bit_depth,
|
||||
PNG_CONST int palette_number,
|
||||
@@ -9030,7 +9191,7 @@ perform_gamma_composition_tests(png_modifier *pm, int do_background,
|
||||
/* Skip the non-alpha cases - there is no setting of a transparency colour at
|
||||
* present.
|
||||
*/
|
||||
while (next_format(&colour_type, &bit_depth, &palette_number))
|
||||
while (next_format(&colour_type, &bit_depth, &palette_number, 1/*gamma*/))
|
||||
if ((colour_type & PNG_COLOR_MASK_ALPHA) != 0)
|
||||
{
|
||||
unsigned int i, j;
|
||||
@@ -9052,31 +9213,46 @@ perform_gamma_composition_tests(png_modifier *pm, int do_background,
|
||||
static void
|
||||
init_gamma_errors(png_modifier *pm)
|
||||
{
|
||||
pm->error_gray_2 = pm->error_gray_4 = pm->error_gray_8 = 0;
|
||||
pm->error_color_8 = 0;
|
||||
pm->error_indexed = 0;
|
||||
pm->error_gray_16 = pm->error_color_16 = 0;
|
||||
/* Use -1 to catch tests that were not actually run */
|
||||
pm->error_gray_2 = pm->error_gray_4 = pm->error_gray_8 = -1.;
|
||||
pm->error_color_8 = -1.;
|
||||
pm->error_indexed = -1.;
|
||||
pm->error_gray_16 = pm->error_color_16 = -1.;
|
||||
}
|
||||
|
||||
static void
|
||||
summarize_gamma_errors(png_modifier *pm, png_const_charp who, int low_bit_depth)
|
||||
print_one(const char *leader, double err)
|
||||
{
|
||||
if (err != -1.)
|
||||
printf(" %s %.5f\n", leader, err);
|
||||
}
|
||||
|
||||
static void
|
||||
summarize_gamma_errors(png_modifier *pm, png_const_charp who, int low_bit_depth,
|
||||
int indexed)
|
||||
{
|
||||
fflush(stderr);
|
||||
|
||||
if (who)
|
||||
printf("Gamma correction with %s:\n", who);
|
||||
printf("\nGamma correction with %s:\n", who);
|
||||
|
||||
else
|
||||
printf("\nBasic gamma correction:\n");
|
||||
|
||||
if (low_bit_depth)
|
||||
{
|
||||
printf(" 2 bit gray: %.5f\n", pm->error_gray_2);
|
||||
printf(" 4 bit gray: %.5f\n", pm->error_gray_4);
|
||||
printf(" 8 bit gray: %.5f\n", pm->error_gray_8);
|
||||
printf(" 8 bit color: %.5f\n", pm->error_color_8);
|
||||
printf(" indexed: %.5f\n", pm->error_indexed);
|
||||
print_one(" 2 bit gray: ", pm->error_gray_2);
|
||||
print_one(" 4 bit gray: ", pm->error_gray_4);
|
||||
print_one(" 8 bit gray: ", pm->error_gray_8);
|
||||
print_one(" 8 bit color:", pm->error_color_8);
|
||||
if (indexed)
|
||||
print_one(" indexed: ", pm->error_indexed);
|
||||
}
|
||||
|
||||
#ifdef DO_16BIT
|
||||
printf(" 16 bit gray: %.5f\n", pm->error_gray_16);
|
||||
printf(" 16 bit color: %.5f\n", pm->error_color_16);
|
||||
#endif
|
||||
print_one("16 bit gray: ", pm->error_gray_16);
|
||||
print_one("16 bit color:", pm->error_color_16);
|
||||
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -9102,18 +9278,9 @@ perform_gamma_test(png_modifier *pm, int summary)
|
||||
/* Now some real transforms. */
|
||||
if (pm->test_gamma_transform)
|
||||
{
|
||||
init_gamma_errors(pm);
|
||||
/*TODO: remove this. Necessary because the current libpng
|
||||
* implementation works in 8 bits:
|
||||
*/
|
||||
if (pm->test_gamma_expand16)
|
||||
pm->calculations_use_input_precision = 1;
|
||||
perform_gamma_transform_tests(pm);
|
||||
if (!calculations_use_input_precision)
|
||||
pm->calculations_use_input_precision = 0;
|
||||
|
||||
if (summary)
|
||||
{
|
||||
fflush(stderr);
|
||||
printf("Gamma correction error summary\n\n");
|
||||
printf("The printed value is the maximum error in the pixel values\n");
|
||||
printf("calculated by the libpng gamma correction code. The error\n");
|
||||
@@ -9125,10 +9292,25 @@ perform_gamma_test(png_modifier *pm, int summary)
|
||||
printf("less than 1 for formats with fewer than 8 bits and a small\n");
|
||||
printf("number (typically less than 5) for the 16 bit formats.\n");
|
||||
printf("For performance reasons the value for 16 bit formats\n");
|
||||
printf("increases when the image file includes an sBIT chunk.\n\n");
|
||||
|
||||
summarize_gamma_errors(pm, 0/*who*/, 1);
|
||||
printf("increases when the image file includes an sBIT chunk.\n");
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
init_gamma_errors(pm);
|
||||
/*TODO: remove this. Necessary because the current libpng
|
||||
* implementation works in 8 bits:
|
||||
*/
|
||||
if (pm->test_gamma_expand16)
|
||||
pm->calculations_use_input_precision = 1;
|
||||
perform_gamma_transform_tests(pm);
|
||||
if (!calculations_use_input_precision)
|
||||
pm->calculations_use_input_precision = 0;
|
||||
|
||||
if (summary)
|
||||
summarize_gamma_errors(pm, 0/*who*/, 1/*low bit depth*/, 1/*indexed*/);
|
||||
|
||||
if (fail(pm))
|
||||
return;
|
||||
}
|
||||
|
||||
/* The sbit tests produce much larger errors: */
|
||||
@@ -9138,7 +9320,10 @@ perform_gamma_test(png_modifier *pm, int summary)
|
||||
perform_gamma_sbit_tests(pm);
|
||||
|
||||
if (summary)
|
||||
summarize_gamma_errors(pm, "sBIT", pm->sbitlow < 8U);
|
||||
summarize_gamma_errors(pm, "sBIT", pm->sbitlow < 8U, 1/*indexed*/);
|
||||
|
||||
if (fail(pm))
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef DO_16BIT /* Should be READ_16BIT_SUPPORTED */
|
||||
@@ -9150,10 +9335,15 @@ perform_gamma_test(png_modifier *pm, int summary)
|
||||
|
||||
if (summary)
|
||||
{
|
||||
printf("Gamma correction with 16 to 8 bit reduction:\n");
|
||||
fflush(stderr);
|
||||
printf("\nGamma correction with 16 to 8 bit reduction:\n");
|
||||
printf(" 16 bit gray: %.5f\n", pm->error_gray_16);
|
||||
printf(" 16 bit color: %.5f\n", pm->error_color_16);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
if (fail(pm))
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9177,7 +9367,10 @@ perform_gamma_test(png_modifier *pm, int summary)
|
||||
pm->maxout8 = maxout8;
|
||||
|
||||
if (summary)
|
||||
summarize_gamma_errors(pm, "background", 1);
|
||||
summarize_gamma_errors(pm, "background", 1, 0/*indexed*/);
|
||||
|
||||
if (fail(pm))
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -9202,7 +9395,10 @@ perform_gamma_test(png_modifier *pm, int summary)
|
||||
pm->calculations_use_input_precision = 0;
|
||||
|
||||
if (summary)
|
||||
summarize_gamma_errors(pm, "alpha mode", 1);
|
||||
summarize_gamma_errors(pm, "alpha mode", 1, 0/*indexed*/);
|
||||
|
||||
if (fail(pm))
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -9710,6 +9906,19 @@ int main(int argc, char **argv)
|
||||
/* Default to error on warning: */
|
||||
pm.this.treat_warnings_as_errors = 1;
|
||||
|
||||
/* Default assume_16_bit_calculations appropriately; this tells the checking
|
||||
* code that 16-bit arithmetic is used for 8-bit samples when it would make a
|
||||
* difference.
|
||||
*/
|
||||
pm.assume_16_bit_calculations = PNG_LIBPNG_VER >= 10700;
|
||||
|
||||
/* Currently 16 bit expansion happens at the end of the pipeline, so the
|
||||
* calculations are done in the input bit depth not the output.
|
||||
*
|
||||
* TODO: fix this
|
||||
*/
|
||||
pm.calculations_use_input_precision = 1U;
|
||||
|
||||
/* Store the test gammas */
|
||||
pm.gammas = gammas;
|
||||
pm.ngammas = (sizeof gammas) / (sizeof gammas[0]);
|
||||
@@ -9720,13 +9929,16 @@ int main(int argc, char **argv)
|
||||
pm.nencodings = (sizeof test_encodings) / (sizeof test_encodings[0]);
|
||||
|
||||
pm.sbitlow = 8U; /* because libpng doesn't do sBIT below 8! */
|
||||
|
||||
/* The following allows results to pass if they correspond to anything in the
|
||||
* transformed range [input-.5,input+.5]; this is is required because of the
|
||||
* way libpng treates the 16_TO_8 flag when building the gamma tables.
|
||||
* way libpng treates the 16_TO_8 flag when building the gamma tables in
|
||||
* releases up to 1.6.0.
|
||||
*
|
||||
* TODO: review this
|
||||
*/
|
||||
pm.use_input_precision_16to8 = 1U;
|
||||
pm.use_input_precision_sbit = 1U; /* because libpng now rounds sBIT */
|
||||
|
||||
/* Some default values (set the behavior for 'make check' here).
|
||||
* These values simply control the maximum error permitted in the gamma
|
||||
@@ -9737,11 +9949,12 @@ int main(int argc, char **argv)
|
||||
*/
|
||||
pm.maxout8 = .1; /* Arithmetic error in *encoded* value */
|
||||
pm.maxabs8 = .00005; /* 1/20000 */
|
||||
pm.maxcalc8 = .004; /* +/-1 in 8 bits for compose errors */
|
||||
pm.maxcalc8 = 1./255; /* +/-1 in 8 bits for compose errors */
|
||||
pm.maxpc8 = .499; /* I.e., .499% fractional error */
|
||||
pm.maxout16 = .499; /* Error in *encoded* value */
|
||||
pm.maxabs16 = .00005;/* 1/20000 */
|
||||
pm.maxcalc16 =.000015;/* +/-1 in 16 bits for compose errors */
|
||||
pm.maxcalc16 =1./65535;/* +/-1 in 16 bits for compose errors */
|
||||
pm.maxcalcG = 1./((1<<PNG_MAX_GAMMA_8)-1);
|
||||
|
||||
/* NOTE: this is a reasonable perceptual limit. We assume that humans can
|
||||
* perceive light level differences of 1% over a 100:1 range, so we need to
|
||||
@@ -9888,13 +10101,16 @@ int main(int argc, char **argv)
|
||||
pm.interlace_type = PNG_INTERLACE_ADAM7;
|
||||
|
||||
else if (strcmp(*argv, "--use-input-precision") == 0)
|
||||
pm.use_input_precision = 1;
|
||||
pm.use_input_precision = 1U;
|
||||
|
||||
else if (strcmp(*argv, "--use-calculation-precision") == 0)
|
||||
pm.use_input_precision = 0;
|
||||
|
||||
else if (strcmp(*argv, "--calculations-use-input-precision") == 0)
|
||||
pm.calculations_use_input_precision = 1;
|
||||
pm.calculations_use_input_precision = 1U;
|
||||
|
||||
else if (strcmp(*argv, "--assume-16-bit-calculations") == 0)
|
||||
pm.assume_16_bit_calculations = 1;
|
||||
pm.assume_16_bit_calculations = 1U;
|
||||
|
||||
else if (strcmp(*argv, "--calculations-follow-bit-depth") == 0)
|
||||
pm.calculations_use_input_precision =
|
||||
@@ -10135,6 +10351,7 @@ int main(int argc, char **argv)
|
||||
int main(void)
|
||||
{
|
||||
fprintf(stderr, "pngvalid: no write support in libpng, all tests skipped\n");
|
||||
return 0;
|
||||
/* So the test is skipped: */
|
||||
return 77;
|
||||
}
|
||||
#endif
|
||||
|
||||
104
contrib/libtests/readpng.c
Normal file
104
contrib/libtests/readpng.c
Normal file
@@ -0,0 +1,104 @@
|
||||
/* readpng.c
|
||||
*
|
||||
* Copyright (c) 2013 John Cunningham Bowler
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
*
|
||||
* 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);
|
||||
|
||||
{
|
||||
png_size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
|
||||
|
||||
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);
|
||||
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.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Run the simplified API tests
|
||||
err=0
|
||||
|
||||
echo >> pngtest-log.txt
|
||||
echo "============ pngstest.sh ==============" >> pngtest-log.txt
|
||||
|
||||
echo "Running test-pngstest.sh"
|
||||
for image in ${srcdir}/contrib/pngsuite/*.png
|
||||
do
|
||||
for opts in ""
|
||||
do
|
||||
if ./pngstest --strict --log "$@" $opts $image >>pngtest-log.txt 2>&1
|
||||
then
|
||||
echo " PASS: pngstest $opts $image"
|
||||
else
|
||||
echo " FAIL: pngstest $opts $image"
|
||||
err=1
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
exit $err
|
||||
@@ -1,38 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Run the unknown API tests
|
||||
err=0
|
||||
image="${srcdir}/pngtest.png"
|
||||
#
|
||||
# stream 4 is used for the output of the shell, pngtest-log.txt gets all the
|
||||
# normal program output.
|
||||
exec 4>&1 1>>pngtest-log.txt 2>&1
|
||||
|
||||
echo
|
||||
echo "============ test-pngunknown.sh =============="
|
||||
|
||||
echo "Running test-pngunknown.sh" >&4
|
||||
|
||||
for tests in \
|
||||
"discard default=discard"\
|
||||
"save default=save"\
|
||||
"if-safe default=if-safe"\
|
||||
"vpAg vpAg=if-safe"\
|
||||
"sTER sTER=if-safe"\
|
||||
"IDAT default=discard IDAT=save"\
|
||||
"sAPI bKGD=save cHRM=save gAMA=save all=discard iCCP=save sBIT=save sRGB=save"
|
||||
do
|
||||
set $tests
|
||||
test="$1"
|
||||
shift
|
||||
|
||||
if ./pngunknown "$@" "$image" 4>&-
|
||||
then
|
||||
echo " PASS: test-pngunknown $test" >&4
|
||||
else
|
||||
echo " FAIL: test-pngunknown $test" >&4
|
||||
err=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit $err
|
||||
@@ -1,21 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Run a sequence of gamma tests quietly
|
||||
err=0
|
||||
|
||||
echo >> pngtest-log.txt
|
||||
echo "============ pngvalid-full.sh ==============" >> pngtest-log.txt
|
||||
|
||||
echo "Running test-pngvalid-full.sh"
|
||||
for gamma in threshold transform sbit 16-to-8 background alpha-mode "transform --expand16" "background --expand16" "alpha-mode --expand16"
|
||||
do
|
||||
if ./pngvalid "$@" --gamma-$gamma >> pngtest-log.txt 2>&1
|
||||
then
|
||||
echo " PASS: pngvalid" "$@" "--gamma-$gamma"
|
||||
else
|
||||
echo " FAIL: pngvalid" "$@" "--gamma-$gamma"
|
||||
err=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit $err
|
||||
@@ -1,30 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Run a sequence of tests quietly, without the slow
|
||||
# gamma tests
|
||||
err=0
|
||||
|
||||
echo >> pngtest-log.txt
|
||||
echo "============ pngvalid-simple.sh ==============" >> pngtest-log.txt
|
||||
echo "Running test-pngvalid-simple.sh"
|
||||
# The options to test are:
|
||||
#
|
||||
# standard tests with and without progressive reading and interlace
|
||||
# size images with and without progressive reading
|
||||
# transform tests (standard, non-interlaced only)
|
||||
#
|
||||
for opts in "--standard" "--standard --progressive-read" \
|
||||
"--standard --interlace" "--standard --progressive-read --interlace" \
|
||||
"--size" "--size --progressive-read" \
|
||||
"--transform"
|
||||
do
|
||||
if ./pngvalid "$@" $opts >> pngtest-log.txt 2>&1
|
||||
then
|
||||
echo " PASS: pngvalid" "$@" $opts
|
||||
else
|
||||
echo " FAIL: pngvalid" "$@" $opts
|
||||
err=1
|
||||
fi
|
||||
done
|
||||
|
||||
exit $err
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H)
|
||||
#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
@@ -252,7 +252,7 @@ int main(int argc, char **argv)
|
||||
|
||||
while (fgets(filename, FILENAME_MAX+1, stdin))
|
||||
{
|
||||
int len = strlen(filename);
|
||||
size_t len = strlen(filename);
|
||||
|
||||
if (filename[len-1] == '\n')
|
||||
{
|
||||
|
||||
@@ -14,7 +14,8 @@ LD=$(CC)
|
||||
RM=rm -f
|
||||
COPY=cp
|
||||
|
||||
CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP -I. -O1
|
||||
CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
|
||||
CFLAGS=-O1
|
||||
|
||||
C=.c
|
||||
O=.o
|
||||
@@ -81,7 +82,7 @@ OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
|
||||
|
||||
# note: dependencies do not work on implicit rule lines
|
||||
.c$(O):
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
$(CC) $(CPPFLAGS) -c $(CFLAGS) $<
|
||||
|
||||
# dependencies
|
||||
|
||||
@@ -95,12 +96,12 @@ pngm2pnm$(E): $(OBJS)
|
||||
# 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\
|
||||
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
|
||||
$(PNGSRC)/scripts/pnglibconf.dfa \
|
||||
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
|
||||
$(RM) pnglibconf.h pnglibconf.dfn
|
||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\
|
||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
|
||||
DFA_XTRA="pngusr.dfa" $@
|
||||
|
||||
clean:
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
This demonstrates the use of PNG_USER_CONFIG and pngusr.h
|
||||
|
||||
The makefile builds a minimal write-only decoder with embedded libpng
|
||||
The makefile builds a minimal write-only encoder with embedded libpng
|
||||
and zlib.
|
||||
|
||||
Specify the location of the zlib source (1.2.1 or later) as ZLIBSRC
|
||||
|
||||
@@ -14,7 +14,8 @@ LD=$(CC)
|
||||
RM=rm -f
|
||||
COPY=cp
|
||||
|
||||
CFLAGS=-DPNG_USER_CONFIG -DZ_SOLO -DNO_GZIP -I. -O1
|
||||
CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
|
||||
CFLAGS=-O1
|
||||
|
||||
C=.c
|
||||
O=.o
|
||||
@@ -80,7 +81,7 @@ OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
|
||||
# implicit make rules -------------------------------------------------------
|
||||
|
||||
.c$(O):
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
$(CC) $(CPPFLAGS) -c $(CFLAGS) $<
|
||||
|
||||
# dependencies
|
||||
|
||||
@@ -94,12 +95,12 @@ pnm2pngm$(E): $(OBJS)
|
||||
# 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\
|
||||
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
|
||||
$(PNGSRC)/scripts/pnglibconf.dfa \
|
||||
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
|
||||
$(RM) pnglibconf.h pnglibconf.dfn
|
||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\
|
||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
|
||||
DFA_XTRA="pngusr.dfa" $@
|
||||
|
||||
clean:
|
||||
|
||||
@@ -30,7 +30,8 @@ XLIB = -L/usr/X11R6/lib -lX11
|
||||
#LIBS = $(XLIB)
|
||||
LIBS = $(XLIB) -lm #platforms that need libm
|
||||
|
||||
CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP -I. $(XINC) -O1
|
||||
CPPFLAGS=-I. $(XINC) -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
|
||||
CFLAGS=-O1
|
||||
|
||||
C=.c
|
||||
O=.o
|
||||
@@ -96,7 +97,7 @@ OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
|
||||
# implicit make rules -------------------------------------------------------
|
||||
|
||||
.c$(O):
|
||||
$(CC) -c $(CFLAGS) $<
|
||||
$(CC) $(CPPFLAGS) -c $(CFLAGS) $<
|
||||
|
||||
# dependencies
|
||||
|
||||
@@ -110,12 +111,12 @@ rpng2-x$(E): $(OBJS)
|
||||
# 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\
|
||||
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
|
||||
$(PNGSRC)/scripts/pnglibconf.dfa \
|
||||
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
|
||||
$(RM) pnglibconf.h pnglibconf.dfn
|
||||
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
|
||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\
|
||||
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
|
||||
DFA_XTRA="pngusr.dfa" $@
|
||||
|
||||
clean:
|
||||
|
||||
@@ -8,9 +8,9 @@ LD=$(CC)
|
||||
RM=rm -f
|
||||
|
||||
#PNGPATH = /usr/local
|
||||
#PNGINC = -I$(PNGPATH)/include/libpng16
|
||||
#PNGLIB = -L$(PNGPATH)/lib -lpng16
|
||||
#PNGLIBS = $(PNGPATH)/lib/libpng16.a
|
||||
#PNGINC = -I$(PNGPATH)/include/libpng17
|
||||
#PNGLIB = -L$(PNGPATH)/lib -lpng17
|
||||
#PNGLIBS = $(PNGPATH)/lib/libpng17.a
|
||||
PNGINC = -I../..
|
||||
PNGLIB = -L../.. -lpng
|
||||
PNGLIBS = ../../libpng.a
|
||||
|
||||
@@ -198,9 +198,9 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
char height_token[16];
|
||||
char maxval_token[16];
|
||||
int color_type;
|
||||
unsigned long ul_width, ul_alpha_width;
|
||||
unsigned long ul_height, ul_alpha_height;
|
||||
unsigned long ul_maxval;
|
||||
unsigned long ul_width=0, ul_alpha_width=0;
|
||||
unsigned long ul_height=0, ul_alpha_height=0;
|
||||
unsigned long ul_maxval=0;
|
||||
png_uint_32 width, alpha_width;
|
||||
png_uint_32 height, alpha_height;
|
||||
png_uint_32 maxval;
|
||||
@@ -210,6 +210,9 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
int alpha_present;
|
||||
int row, col;
|
||||
BOOL raw, alpha_raw = FALSE;
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
BOOL packed_bitmap = FALSE;
|
||||
#endif
|
||||
png_uint_32 tmp16;
|
||||
int i;
|
||||
|
||||
@@ -222,9 +225,21 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
}
|
||||
else if ((type_token[1] == '1') || (type_token[1] == '4'))
|
||||
{
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
raw = (type_token[1] == '4');
|
||||
color_type = PNG_COLOR_TYPE_GRAY;
|
||||
get_token(pnm_file, width_token);
|
||||
sscanf (width_token, "%lu", &ul_width);
|
||||
width = (png_uint_32) ul_width;
|
||||
get_token(pnm_file, height_token);
|
||||
sscanf (height_token, "%lu", &ul_height);
|
||||
height = (png_uint_32) ul_height;
|
||||
bit_depth = 1;
|
||||
packed_bitmap = TRUE;
|
||||
#else
|
||||
fprintf (stderr, "PNM2PNG built without PNG_WRITE_INVERT_SUPPORTED and \n");
|
||||
fprintf (stderr, "PNG_WRITE_PACK_SUPPORTED can't read PBM (P1,P4) files\n");
|
||||
#endif
|
||||
}
|
||||
else if ((type_token[1] == '2') || (type_token[1] == '5'))
|
||||
{
|
||||
@@ -343,8 +358,14 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
|
||||
alpha_present = (channels - 1) % 2;
|
||||
|
||||
/* row_bytes is the width x number of channels x (bit-depth / 8) */
|
||||
row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
if (packed_bitmap)
|
||||
/* row data is as many bytes as can fit width x channels x bit_depth */
|
||||
row_bytes = (width * channels * bit_depth + 7) / 8;
|
||||
else
|
||||
#endif
|
||||
/* row_bytes is the width x number of channels x (bit-depth / 8) */
|
||||
row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
|
||||
|
||||
if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL)
|
||||
return FALSE;
|
||||
@@ -354,40 +375,48 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
|
||||
for (row = 0; row < height; row++)
|
||||
{
|
||||
for (col = 0; col < width; col++)
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
if (packed_bitmap) {
|
||||
for (i = 0; i < row_bytes; i++)
|
||||
/* png supports this format natively so no conversion is needed */
|
||||
*pix_ptr++ = get_data (pnm_file, 8);
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
for (i = 0; i < (channels - alpha_present); i++)
|
||||
for (col = 0; col < width; col++)
|
||||
{
|
||||
if (raw)
|
||||
*pix_ptr++ = get_data (pnm_file, bit_depth);
|
||||
else
|
||||
if (bit_depth <= 8)
|
||||
*pix_ptr++ = get_value (pnm_file, bit_depth);
|
||||
for (i = 0; i < (channels - alpha_present); i++)
|
||||
{
|
||||
if (raw)
|
||||
*pix_ptr++ = get_data (pnm_file, bit_depth);
|
||||
else
|
||||
{
|
||||
tmp16 = get_value (pnm_file, bit_depth);
|
||||
*pix_ptr = (png_byte) ((tmp16 >> 8) & 0xFF);
|
||||
pix_ptr++;
|
||||
*pix_ptr = (png_byte) (tmp16 & 0xFF);
|
||||
pix_ptr++;
|
||||
}
|
||||
}
|
||||
if (bit_depth <= 8)
|
||||
*pix_ptr++ = get_value (pnm_file, bit_depth);
|
||||
else
|
||||
{
|
||||
tmp16 = get_value (pnm_file, bit_depth);
|
||||
*pix_ptr = (png_byte) ((tmp16 >> 8) & 0xFF);
|
||||
pix_ptr++;
|
||||
*pix_ptr = (png_byte) (tmp16 & 0xFF);
|
||||
pix_ptr++;
|
||||
}
|
||||
}
|
||||
|
||||
if (alpha) /* read alpha-channel from pgm file */
|
||||
{
|
||||
if (alpha_raw)
|
||||
*pix_ptr++ = get_data (alpha_file, alpha_depth);
|
||||
else
|
||||
if (alpha_depth <= 8)
|
||||
*pix_ptr++ = get_value (alpha_file, bit_depth);
|
||||
if (alpha) /* read alpha-channel from pgm file */
|
||||
{
|
||||
if (alpha_raw)
|
||||
*pix_ptr++ = get_data (alpha_file, alpha_depth);
|
||||
else
|
||||
{
|
||||
tmp16 = get_value (alpha_file, bit_depth);
|
||||
*pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF);
|
||||
*pix_ptr++ = (png_byte) (tmp16 & 0xFF);
|
||||
}
|
||||
} /* if alpha */
|
||||
|
||||
if (alpha_depth <= 8)
|
||||
*pix_ptr++ = get_value (alpha_file, bit_depth);
|
||||
else
|
||||
{
|
||||
tmp16 = get_value (alpha_file, bit_depth);
|
||||
*pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF);
|
||||
*pix_ptr++ = (png_byte) (tmp16 & 0xFF);
|
||||
}
|
||||
} /* if alpha */
|
||||
} /* if packed_bitmap */
|
||||
} /* end for col */
|
||||
} /* end for row */
|
||||
|
||||
@@ -404,6 +433,14 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
|
||||
if (packed_bitmap == TRUE)
|
||||
{
|
||||
png_set_packing (png_ptr);
|
||||
png_set_invert_mono (png_ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* setjmp() must be called in every function that calls a PNG-reading libpng function */
|
||||
if (setjmp (png_jmpbuf(png_ptr)))
|
||||
{
|
||||
@@ -460,19 +497,32 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
|
||||
void get_token(FILE *pnm_file, char *token)
|
||||
{
|
||||
int i = 0;
|
||||
int ret;
|
||||
|
||||
/* remove white-space */
|
||||
/* remove white-space and comment lines */
|
||||
do
|
||||
{
|
||||
token[i] = (unsigned char) fgetc (pnm_file);
|
||||
ret = fgetc(pnm_file);
|
||||
if (ret == '#') {
|
||||
/* the rest of this line is a comment */
|
||||
do
|
||||
{
|
||||
ret = fgetc(pnm_file);
|
||||
}
|
||||
while ((ret != '\n') && (ret != '\r') && (ret != EOF));
|
||||
}
|
||||
if (ret == EOF) break;
|
||||
token[i] = (unsigned char) ret;
|
||||
}
|
||||
while ((token[i] == '\n') || (token[i] == '\r') || (token[i] == ' '));
|
||||
|
||||
/* read string */
|
||||
do
|
||||
{
|
||||
ret = fgetc(pnm_file);
|
||||
if (ret == EOF) break;
|
||||
i++;
|
||||
token[i] = (unsigned char) fgetc (pnm_file);
|
||||
token[i] = (unsigned char) ret;
|
||||
}
|
||||
while ((token[i] != '\n') && (token[i] != '\r') && (token[i] != ' '));
|
||||
|
||||
|
||||
153
contrib/tools/png-fix-itxt.c
Normal file
153
contrib/tools/png-fix-itxt.c
Normal file
@@ -0,0 +1,153 @@
|
||||
|
||||
/* png-fix-itxt version 1.0.0
|
||||
*
|
||||
* Copyright 2013 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.3 [(PENDING RELEASE)]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
* Usage:
|
||||
*
|
||||
* png-fix-itxt.exe < bad.png > good.png
|
||||
*
|
||||
* Fixes a PNG file written with libpng-1.6.0 or 1.6.1 that has one or more
|
||||
* uncompressed iTXt chunks. Assumes that the actual length is greater
|
||||
* than or equal to the value in the length byte, and that the CRC is
|
||||
* correct for the actual length. This program hunts for the CRC and
|
||||
* adjusts the length byte accordingly. It is not an error to process a
|
||||
* PNG file that has no iTXt chunks or one that has valid iTXt chunks;
|
||||
* such files will simply be copied.
|
||||
*
|
||||
* Requires zlib (for crc32 and Z_NULL); build with
|
||||
*
|
||||
* gcc -O -o png-fix-itxt png-fix-itxt.c -lz
|
||||
*
|
||||
* If you need to handle iTXt chunks larger than 500000 kbytes you must
|
||||
* rebuild png-fix-itxt with a larger values of MAX_LENGTH (or a smaller value
|
||||
* if you know you will never encounter such huge iTXt chunks).
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <zlib.h>
|
||||
|
||||
#define MAX_LENGTH 500000
|
||||
|
||||
#define GETBREAK ((unsigned char)(inchar=getchar())); if (inchar == EOF) break
|
||||
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
unsigned int i;
|
||||
unsigned char buf[MAX_LENGTH];
|
||||
unsigned long crc;
|
||||
unsigned char c;
|
||||
int inchar;
|
||||
|
||||
/* Skip 8-byte signature */
|
||||
for (i=8; i; i--)
|
||||
{
|
||||
c=GETBREAK;
|
||||
putchar(c);
|
||||
}
|
||||
|
||||
if (inchar != EOF)
|
||||
for (;;)
|
||||
{
|
||||
/* Read the length */
|
||||
unsigned long length; /* must be 32 bits! */
|
||||
c=GETBREAK; buf[0] = c; length = c; length <<= 8;
|
||||
c=GETBREAK; buf[1] = c; length += c; length <<= 8;
|
||||
c=GETBREAK; buf[2] = c; length += c; length <<= 8;
|
||||
c=GETBREAK; buf[3] = c; length += c;
|
||||
|
||||
/* Read the chunkname */
|
||||
c=GETBREAK; buf[4] = c;
|
||||
c=GETBREAK; buf[5] = c;
|
||||
c=GETBREAK; buf[6] = c;
|
||||
c=GETBREAK; buf[7] = c;
|
||||
|
||||
|
||||
/* The iTXt chunk type expressed as integers is (105, 84, 88, 116) */
|
||||
if (buf[4] == 105 && buf[5] == 84 && buf[6] == 88 && buf[7] == 116)
|
||||
{
|
||||
if (length >= MAX_LENGTH-12)
|
||||
break; /* To do: handle this more gracefully */
|
||||
|
||||
/* Initialize the CRC */
|
||||
crc = crc32(0, Z_NULL, 0);
|
||||
|
||||
/* Copy the data bytes */
|
||||
for (i=8; i < length + 12; i++)
|
||||
{
|
||||
c=GETBREAK; buf[i] = c;
|
||||
}
|
||||
|
||||
/* Calculate the CRC */
|
||||
crc = crc32(crc, buf+4, (uInt)length+4);
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* Check the CRC */
|
||||
if (((crc >> 24) & 0xff) == buf[length+8] &&
|
||||
((crc >> 16) & 0xff) == buf[length+9] &&
|
||||
((crc >> 8) & 0xff) == buf[length+10] &&
|
||||
((crc ) & 0xff) == buf[length+11])
|
||||
break;
|
||||
|
||||
length++;
|
||||
|
||||
if (length >= MAX_LENGTH-12)
|
||||
break;
|
||||
|
||||
c=GETBREAK;
|
||||
buf[length+11]=c;
|
||||
|
||||
/* Update the CRC */
|
||||
crc = crc32(crc, buf+7+length, 1);
|
||||
}
|
||||
|
||||
/* Update length bytes */
|
||||
buf[0] = (unsigned char)((length << 24) & 0xff);
|
||||
buf[1] = (unsigned char)((length << 16) & 0xff);
|
||||
buf[2] = (unsigned char)((length << 8) & 0xff);
|
||||
buf[3] = (unsigned char)((length ) & 0xff);
|
||||
|
||||
/* Write the fixed iTXt chunk (length, name, data, crc) */
|
||||
for (i=0; i<length+12; i++)
|
||||
putchar(buf[i]);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* Copy bytes that were already read (length and chunk name) */
|
||||
for (i=0; i<8; i++)
|
||||
putchar(buf[i]);
|
||||
|
||||
/* Copy data bytes and CRC */
|
||||
for (i=8; i< length+12; i++)
|
||||
{
|
||||
c=GETBREAK;
|
||||
putchar(c);
|
||||
}
|
||||
|
||||
if (inchar == EOF)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
/* The IEND chunk type expressed as integers is (73, 69, 78, 68) */
|
||||
if (buf[4] == 73 && buf[5] == 69 && buf[6] == 78 && buf[7] == 68)
|
||||
break;
|
||||
}
|
||||
|
||||
if (inchar == EOF)
|
||||
break;
|
||||
|
||||
if (buf[4] == 73 && buf[5] == 69 && buf[6] == 78 && buf[7] == 68)
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
1263
contrib/tools/png-fix-too-far-back.c
Normal file
1263
contrib/tools/png-fix-too-far-back.c
Normal file
File diff suppressed because it is too large
Load Diff
238
contrib/tools/scale.c
Normal file
238
contrib/tools/scale.c
Normal file
@@ -0,0 +1,238 @@
|
||||
/* Given a target range and a source range work out an expression to scale from
|
||||
* the source to the target of the form:
|
||||
*
|
||||
* (number * mult + add)>>16
|
||||
*
|
||||
* The command arguments are:
|
||||
*
|
||||
* scale target source
|
||||
*
|
||||
* and the program works out a pair of numbers, mult and add, that evaluate:
|
||||
*
|
||||
* number * target
|
||||
* round( --------------- )
|
||||
* source
|
||||
*
|
||||
* exactly for number in the range 0..source
|
||||
*/
|
||||
#define _ISOC99_SOURCE 1
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
static double minerr;
|
||||
static unsigned long minmult, minadd, minshift;
|
||||
static long mindelta;
|
||||
|
||||
static int
|
||||
test(unsigned long target, unsigned long source, unsigned long mult,
|
||||
long add, unsigned long shift, long delta)
|
||||
{
|
||||
unsigned long i;
|
||||
double maxerr = 0;
|
||||
double rs = (double)target/source;
|
||||
|
||||
for (i=0; i<=source; ++i)
|
||||
{
|
||||
unsigned long t = i*mult+add;
|
||||
double err = fabs((t >> shift) - i*rs);
|
||||
|
||||
if (err > minerr)
|
||||
return 0;
|
||||
|
||||
if (err > maxerr)
|
||||
maxerr = err;
|
||||
}
|
||||
|
||||
if (maxerr < minerr)
|
||||
{
|
||||
minerr = maxerr;
|
||||
minmult = mult;
|
||||
minadd = add;
|
||||
minshift = shift;
|
||||
mindelta = delta;
|
||||
}
|
||||
|
||||
return maxerr < .5;
|
||||
}
|
||||
|
||||
static int
|
||||
dotest(unsigned long target, unsigned long source, unsigned long mult,
|
||||
long add, unsigned long shift, long delta, int print)
|
||||
{
|
||||
if (test(target, source, mult, add, shift, delta))
|
||||
{
|
||||
if (print & 4)
|
||||
printf(" {%11lu,%6ld /* >>%lu */ }, /* %lu/%lu */\n",
|
||||
mult, add, shift, target, source);
|
||||
|
||||
else if (print & 2)
|
||||
printf(" {%11lu,%6ld,%3lu }, /* %lu/%lu */\n",
|
||||
mult, add, shift, target, source);
|
||||
|
||||
else if (print)
|
||||
printf("number * %lu/%lu = (number * %lu + %ld) >> %lu [delta %ld]\n",
|
||||
target, source, mult, add, shift, delta);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
find(unsigned long target, unsigned long source, int print, int fixshift)
|
||||
{
|
||||
unsigned long shift = 0;
|
||||
unsigned long shiftlim = 0;
|
||||
|
||||
/* In the final math the sum is at most (source*mult+add) >> shift, so:
|
||||
*
|
||||
* source*mult+add < 1<<32
|
||||
* mult < (1<<32)/source
|
||||
*
|
||||
* but:
|
||||
*
|
||||
* mult = (target<<shift)/source
|
||||
*
|
||||
* so:
|
||||
*
|
||||
* (target<<shift) < (1<<32)
|
||||
*/
|
||||
if (fixshift < 0)
|
||||
while ((target<<shiftlim) < 0x80000000U) ++shiftlim;
|
||||
|
||||
else
|
||||
shift = shiftlim = (unsigned long)fixshift;
|
||||
|
||||
minerr = 1E8;
|
||||
|
||||
for (; shift<=shiftlim; ++shift)
|
||||
{
|
||||
unsigned long mult = ((target<<shift) + (source>>1)) / source;
|
||||
long delta;
|
||||
long limit = 1; /* seems to be sufficient */
|
||||
long add, start, end;
|
||||
|
||||
end = 1<<shift;
|
||||
start = -end;
|
||||
|
||||
for (add=start; add<=end; ++add)
|
||||
if (dotest(target,source,mult,add,shift,0,print))
|
||||
return 1;
|
||||
|
||||
for (delta=1; delta<=limit; ++delta)
|
||||
{
|
||||
# if 0
|
||||
fprintf(stderr, "%lu/%lu: shift %lu, delta %lu\n", target, source,
|
||||
shift, delta);
|
||||
# endif
|
||||
|
||||
for (add=start; add<=end; ++add)
|
||||
{
|
||||
if (dotest(target, source, mult-delta, add, shift, -delta, print))
|
||||
return 1;
|
||||
|
||||
if (dotest(target, source, mult+delta, add, shift, delta, print))
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (print & 4)
|
||||
printf(" {%11lu,%6ld /* >>%lu */ }, /* %lu/%lu ERROR: .5+%g*/\n",
|
||||
minmult, minadd, minshift, target, source, minerr-.5);
|
||||
|
||||
else if (print & 2)
|
||||
printf(" {%11lu,%6ld,%3lu }, /* %lu/%lu ERROR: .5+%g*/\n",
|
||||
minmult, minadd, minshift, target, source, minerr-.5);
|
||||
|
||||
else if (print)
|
||||
printf(
|
||||
"number * %lu/%lu ~= (number * %lu + %ld) >> %lu +/-.5+%g [delta %ld]\n",
|
||||
target, source, minmult, minadd, minshift, minerr-.5, mindelta);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
usage(const char *prog)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"usage: %s {--denominator|--maxshift|--code} target {source}\n"
|
||||
" For each 'source' prints 'mult' and 'add' such that:\n\n"
|
||||
" (number * mult + add) >> 16 = round(number*target/source)\n\n"
|
||||
" for all integer values of number in the range 0..source.\n\n"
|
||||
" --denominator: swap target and source (specify a single source first\n"
|
||||
" and follow with multiple targets.)\n"
|
||||
" --maxshift: find the lowest shift value that works for all the\n"
|
||||
" repeated 'source' values\n"
|
||||
" --code: output C code for array/structure initialization\n",
|
||||
prog);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, const char **argv)
|
||||
{
|
||||
int i, err = 0, maxshift = 0, firstsrc = 1, code = 0, denominator = 0;
|
||||
unsigned long target, shift = 0;
|
||||
|
||||
while (argc > 1)
|
||||
{
|
||||
if (strcmp(argv[firstsrc], "--maxshift") == 0)
|
||||
{
|
||||
maxshift = 1;
|
||||
++firstsrc;
|
||||
}
|
||||
|
||||
else if (strcmp(argv[firstsrc], "--code") == 0)
|
||||
{
|
||||
code = 1;
|
||||
++firstsrc;
|
||||
}
|
||||
|
||||
else if (strcmp(argv[firstsrc], "--denominator") == 0)
|
||||
{
|
||||
denominator = 1;
|
||||
++firstsrc;
|
||||
}
|
||||
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (argc < 2+firstsrc)
|
||||
usage(argv[0]);
|
||||
|
||||
target = strtoul(argv[firstsrc++], 0, 0);
|
||||
if (target == 0) usage(argv[0]);
|
||||
|
||||
for (i=firstsrc; i<argc; ++i)
|
||||
{
|
||||
unsigned long source = strtoul(argv[i], 0, 0);
|
||||
|
||||
if (source == 0) usage(argv[0]);
|
||||
|
||||
if (!find(denominator ? source : target, denominator ? target : source,
|
||||
maxshift ? 0 : 1+code, -1))
|
||||
err = 1;
|
||||
|
||||
if (minshift > shift) shift = minshift;
|
||||
}
|
||||
|
||||
if (maxshift) for (i=firstsrc; i<argc; ++i)
|
||||
{
|
||||
unsigned long source = strtoul(argv[i], 0, 0);
|
||||
|
||||
if (!find(denominator ? source : target, denominator ? target : source,
|
||||
code ? 4 : 1, shift))
|
||||
err = 1;
|
||||
}
|
||||
|
||||
/* Just an exit code - the printout above lists the problem */
|
||||
return err;
|
||||
}
|
||||
@@ -2,8 +2,8 @@
|
||||
#if 0 /* in case someone actually tries to compile this */
|
||||
|
||||
/* example.c - an example of using libpng
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Maintained 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.0 [February 14, 2013]
|
||||
* Maintained 1998-2013 Glenn Randers-Pehrson
|
||||
* Maintained 1996, 1997 Andreas Dilger)
|
||||
* Written 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
* To the extent possible under law, the authors have waived
|
||||
@@ -39,7 +39,7 @@
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <png.h>
|
||||
#include <zlib.h>
|
||||
#include PNG_ZLIB_HEADER /* this is the header libpng was built with */
|
||||
|
||||
int main(int argc, const char **argv)
|
||||
{
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
libpng version 1.6.0beta33 - December 10, 2012
|
||||
libpng version 1.7.0beta15 - June 18, 2013
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
<glennrp at users.sourceforge.net>
|
||||
Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
|
||||
This document is released under the libpng license.
|
||||
For conditions of distribution and use, see the disclaimer
|
||||
@@ -11,9 +11,9 @@ libpng-manual.txt - A description on how to use and modify libpng
|
||||
|
||||
Based on:
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.6.0beta33 - December 10, 2012
|
||||
libpng versions 0.97, January 1998, through 1.7.0beta15 - June 18, 2013
|
||||
Updated and distributed by Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
|
||||
libpng 1.0 beta 6 version 0.96 May 28, 1997
|
||||
Updated and distributed by Andreas Dilger
|
||||
@@ -42,17 +42,16 @@ libpng-manual.txt - A description on how to use and modify libpng
|
||||
X. Changes to Libpng from version 1.0.x/1.2.x to 1.4.x
|
||||
XI. Changes to Libpng from version 1.4.x to 1.5.x
|
||||
XII. Changes to Libpng from version 1.5.x to 1.6.x
|
||||
XIII. Detecting libpng
|
||||
XIV. Source code repository
|
||||
XV. Coding style
|
||||
XVI. Y2K Compliance in libpng
|
||||
XIII. Changes to Libpng from version 1.6.x to 1.7.x
|
||||
XIV. Detecting libpng
|
||||
XV. Source code repository
|
||||
XVI. Coding style
|
||||
XVII. Y2K Compliance in libpng
|
||||
|
||||
I. Introduction
|
||||
|
||||
This file describes how to use and modify the PNG reference library
|
||||
(known as libpng) for your own use. There are five sections to this
|
||||
file: introduction, structures, reading, writing, and modification and
|
||||
configuration notes for various special platforms. In addition to this
|
||||
(known as libpng) for your own use. In addition to this
|
||||
file, example.c is a good starting point for using the library, as
|
||||
it is heavily commented and should include everything most people
|
||||
will need. We assume that libpng is already installed; see the
|
||||
@@ -431,7 +430,7 @@ If you would rather avoid the complexity of setjmp/longjmp issues,
|
||||
you can compile libpng with PNG_NO_SETJMP, in which case
|
||||
errors will result in a call to PNG_ABORT() which defaults to abort().
|
||||
|
||||
You can #define PNG_ABORT() to a function that does something
|
||||
You can #define PNG_ABORT to a function or other C code that does something
|
||||
more useful than abort(), as long as your function does not
|
||||
return.
|
||||
|
||||
@@ -526,10 +525,15 @@ you can retrieve with
|
||||
|
||||
png_get_user_chunk_ptr(png_ptr);
|
||||
|
||||
If you call the png_set_read_user_chunk_fn() function, then all unknown
|
||||
chunks will be saved when read, in case your callback function will need
|
||||
one or more of them. This behavior can be changed with the
|
||||
png_set_keep_unknown_chunks() function, described below.
|
||||
If you call the png_set_read_user_chunk_fn() function, then all unknown chunks
|
||||
will be passed to your callback when read. You can cause known chunks to be
|
||||
passed in as well by using png_set_keep_unknown_chunks (see below) - this will
|
||||
prevent the normal libpng handling of those known chunks.
|
||||
|
||||
If your callback returns 0 the default unknown handling will be used (see
|
||||
below). This is new behavior in libpng 1.7, prior to 1.7 it was not possible to
|
||||
discard a chunk; PNG_HANDLE_CHUNK_IF_SAFE was forced. Libpng 1.6.0 issues a
|
||||
warning when this was done.
|
||||
|
||||
At this point, you can set up a callback function that will be
|
||||
called after each row has been read, which you can use to control
|
||||
@@ -636,7 +640,7 @@ callback function:
|
||||
|
||||
/* also ignore unused known chunks: */
|
||||
png_set_keep_unknown_chunks(read_ptr, 1, unused_chunks,
|
||||
(int)sizeof(unused_chunks)/5);
|
||||
(int)(sizeof unused_chunks)/5);
|
||||
#endif
|
||||
|
||||
User limits
|
||||
@@ -675,9 +679,6 @@ where 0x7fffffffL means unlimited. You can retrieve this limit with
|
||||
|
||||
chunk_cache_max = png_get_chunk_cache_max(png_ptr);
|
||||
|
||||
This limit also applies to the number of buffers that can be allocated
|
||||
by png_decompress_chunk() while decompressing iTXt, zTXt, and iCCP chunks.
|
||||
|
||||
You can also set a limit on the amount of memory that a compressed chunk
|
||||
other than IDAT can occupy, with
|
||||
|
||||
@@ -991,7 +992,7 @@ where row_pointers is an array of pointers to the pixel data for each row:
|
||||
If you know your image size and pixel size ahead of time, you can allocate
|
||||
row_pointers prior to calling png_read_png() with
|
||||
|
||||
if (height > PNG_UINT_32_MAX/png_sizeof(png_byte))
|
||||
if (height > PNG_UINT_32_MAX/(sizeof (png_byte))
|
||||
png_error (png_ptr,
|
||||
"Image is too tall to process in memory");
|
||||
|
||||
@@ -1000,7 +1001,7 @@ row_pointers prior to calling png_read_png() with
|
||||
"Image is too wide to process in memory");
|
||||
|
||||
row_pointers = png_malloc(png_ptr,
|
||||
height*png_sizeof(png_bytep));
|
||||
height*(sizeof (png_bytep)));
|
||||
|
||||
for (int i=0; i<height, i++)
|
||||
row_pointers[i]=NULL; /* security precaution */
|
||||
@@ -2561,9 +2562,9 @@ section below for more information on the libpng error handling.
|
||||
|
||||
If you would rather avoid the complexity of setjmp/longjmp issues,
|
||||
you can compile libpng with PNG_NO_SETJMP, in which case
|
||||
errors will result in a call to PNG_ABORT() which defaults to abort().
|
||||
errors will result in a call to PNG_ABORT which defaults to abort().
|
||||
|
||||
You can #define PNG_ABORT() to a function that does something
|
||||
You can #define PNG_ABORT to a function or other C code that does something
|
||||
more useful than abort(), as long as your function does not
|
||||
return.
|
||||
|
||||
@@ -3083,19 +3084,40 @@ tEXt chunk use RFC 1123 format dates (e.g. "22 May 1997 18:07:10 GMT"),
|
||||
although this isn't a requirement. Unlike the tIME chunk, the
|
||||
"Creation Time" tEXt chunk is not expected to be automatically changed
|
||||
by the software. To facilitate the use of RFC 1123 dates, a function
|
||||
png_convert_to_rfc1123_buffer(buffer, png_timep) is provided to convert
|
||||
from PNG time to an RFC 1123 format string. The caller must provide
|
||||
png_convert_to_rfc1123_buffer(png_ptr, buffer, png_timep) is provided to
|
||||
convert from PNG time to an RFC 1123 format string. The caller must provide
|
||||
a writeable buffer of at least 29 bytes.
|
||||
|
||||
Writing unknown chunks
|
||||
|
||||
You can use the png_set_unknown_chunks function to queue up chunks
|
||||
for writing. You give it a chunk name, raw data, and a size; that's
|
||||
all there is to it. The chunks will be written by the next following
|
||||
png_write_info_before_PLTE, png_write_info, or png_write_end function.
|
||||
Any chunks previously read into the info structure's unknown-chunk
|
||||
list will also be written out in a sequence that satisfies the PNG
|
||||
specification's ordering rules.
|
||||
You can use the png_set_unknown_chunks function to queue up private chunks
|
||||
for writing. You give it a chunk name, location, raw data, and a size. You
|
||||
also must use png_set_keep_unknown_chunks() to ensure that libpng will
|
||||
handle them. That's all there is to it. The chunks will be written by the
|
||||
next following png_write_info_before_PLTE, png_write_info, or png_write_end
|
||||
function, depending upon the specified location. Any chunks previously
|
||||
read into the info structure's unknown-chunk list will also be written out
|
||||
in a sequence that satisfies the PNG specification's ordering rules.
|
||||
|
||||
Here is an example of writing two private chunks, prVt and miNE:
|
||||
|
||||
#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Set unknown chunk data */
|
||||
png_unknown_chunk unk_chunk[2];
|
||||
strcpy((char *) unk_chunk[0].name, "prVt";
|
||||
unk_chunk[0].data = (unsigned char *) "PRIVATE DATA";
|
||||
unk_chunk[0].size = strlen(unk_chunk[0].data)+1;
|
||||
unk_chunk[0].location = PNG_HAVE_IHDR;
|
||||
strcpy((char *) unk_chunk[1].name, "miNE";
|
||||
unk_chunk[1].data = (unsigned char *) "MY CHUNK DATA";
|
||||
unk_chunk[1].size = strlen(unk_chunk[0].data)+1;
|
||||
unk_chunk[1].location = PNG_AFTER_IDAT;
|
||||
png_set_unknown_chunks(write_ptr, write_info_ptr,
|
||||
unk_chunk, 2);
|
||||
/* Needed because miNE is not safe-to-copy */
|
||||
png_set_keep_unknown_chunks(png, PNG_HANDLE_CHUNK_ALWAYS,
|
||||
(png_bytep) "miNE", 1);
|
||||
#endif
|
||||
|
||||
The high-level write interface
|
||||
|
||||
@@ -3942,7 +3964,7 @@ Error handling in libpng is done through png_error() and png_warning().
|
||||
Errors handled through png_error() are fatal, meaning that png_error()
|
||||
should never return to its caller. Currently, this is handled via
|
||||
setjmp() and longjmp() (unless you have compiled libpng with
|
||||
PNG_NO_SETJMP, in which case it is handled via PNG_ABORT()),
|
||||
PNG_NO_SETJMP, in which case it is handled via PNG_ABORT),
|
||||
but you could change this to do things like exit() if you should wish,
|
||||
as long as your function does not return.
|
||||
|
||||
@@ -3984,6 +4006,15 @@ compiler documentation for more details. For an alternative approach, you
|
||||
may wish to use the "cexcept" facility (see http://cexcept.sourceforge.net),
|
||||
which is illustrated in pngvalid.c and in contrib/visupng.
|
||||
|
||||
Beginning in libpng-1.4.0, the png_set_benign_errors() API became available.
|
||||
You can use this to handle certain errors (normally handled as errors)
|
||||
as warnings.
|
||||
|
||||
png_set_benign_errors (png_ptr, int allowed);
|
||||
|
||||
allowed: 0: (default) treat png_benign_error() an error.
|
||||
1: treat png_benign_error() as a warning.
|
||||
|
||||
Custom chunks
|
||||
|
||||
If you need to read or write custom chunks, you may need to get deeper
|
||||
@@ -4254,7 +4285,7 @@ the message, "message" is the formatted string to be printed,
|
||||
and p1 and p2 are parameters that are to be embedded in the string
|
||||
according to printf-style formatting directives. For example,
|
||||
|
||||
png_debug1(2, "foo=%d\n", foo);
|
||||
png_debug1(2, "foo=%d", foo);
|
||||
|
||||
is expanded to
|
||||
|
||||
@@ -4593,6 +4624,18 @@ If the error is ignored, or if png_benign_error() treats it as a warning,
|
||||
any invalid pixels are decoded as opaque black by the decoder and written
|
||||
as-is by the encoder.
|
||||
|
||||
Retrieving the maximum palette index found was added at libpng-1.5.15.
|
||||
This statement must appear after png_read_png() or png_read_image() while
|
||||
reading, and after png_write_png() or png_write_image() while writing.
|
||||
|
||||
int max_palette = png_get_palette_max(png_ptr, info_ptr);
|
||||
|
||||
This will return the maximum palette index found in the image, or "-1" if
|
||||
the palette was not checked, or "0" if no palette was found. Note that this
|
||||
does not account for any palette index used by ancillary chunks such as the
|
||||
bKGD chunk; you must check those separately to determine the maximum
|
||||
palette index actually used.
|
||||
|
||||
A. Changes that affect users of libpng
|
||||
|
||||
There are no substantial API changes between the non-deprecated parts of
|
||||
@@ -4922,18 +4965,20 @@ symbols, using the PNG_PREFIX macro.
|
||||
|
||||
We no longer include string.h in png.h. The include statement has been moved
|
||||
to pngpriv.h, where it is not accessible by applications. Applications that
|
||||
need access to information in string.h must add an '#include "string.h"'
|
||||
need access to information in string.h must add an '#include <string.h>'
|
||||
directive. It does not matter whether this is placed prior to or after
|
||||
the '"#include png.h"' directive.
|
||||
the '#include "png.h"' directive.
|
||||
|
||||
The following API are now DEPRECATED:
|
||||
png_info_init_3()
|
||||
png_convert_to_rfc1123() which has been replaced
|
||||
with png_convert_to_rfc1123_buffer()
|
||||
png_data_freer()
|
||||
png_malloc_default()
|
||||
png_free_default()
|
||||
png_reset_zstream()
|
||||
|
||||
The following has been removed:
|
||||
The following have been removed:
|
||||
png_get_io_chunk_name(), which has been replaced
|
||||
with png_get_io_chunk_type(). The new
|
||||
function returns a 32-bit integer instead of
|
||||
@@ -4951,7 +4996,14 @@ where "rp" indicates a "restricted pointer".
|
||||
Error detection in some chunks has improved; in particular the iCCP chunk
|
||||
reader now does pretty complete validation of the basic format. Some bad
|
||||
profiles that were previously accepted are now rejected, in particular the
|
||||
very old broken Microsoft/HP sRGB profile.
|
||||
very old broken Microsoft/HP sRGB profile. The PNG spec requirement that
|
||||
only grayscale profiles may appear in images with color type 0 or 4 and that
|
||||
even if the image only contains gray pixels, only RGB profiles may appear
|
||||
in images with color type 2, 3, or 6, is now enforced. The sRGB chunk
|
||||
is allowed to appear in images with any color type.
|
||||
|
||||
The library now issues an error if the application attempts to set a
|
||||
transform after it calls png_read_update_info().
|
||||
|
||||
The library now issues a warning if both background processing and RGB to
|
||||
gray are used when gamma correction happens. As with previous versions of
|
||||
@@ -4965,7 +5017,59 @@ This adds more correct option control of the unknown handling, corrects
|
||||
a pre-existing bug where the per-chunk 'keep' setting is ignored, and makes
|
||||
it possible to skip IDAT chunks in the sequential reader.
|
||||
|
||||
XIII. Detecting libpng
|
||||
The machine-generated configure files are no longer included in branches
|
||||
libpng16 and later of the GIT repository. They continue to be included
|
||||
in the tarball releases, however.
|
||||
|
||||
Libpng-1.6.0 and later use the CMF bytes at the beginning of the IDAT stream
|
||||
to set the size of the sliding window for reading instead of using the default
|
||||
32-kbyte sliding window size. It was discovered that there are hundreds of PNG
|
||||
files in the wild that have incorrect CMF bytes that cause libpng to now issue
|
||||
a "too far back" error and reject the file. Libpng-1.6.3 provides a way to
|
||||
revert to the libpng-1.5.x behavior (ignoring the CMF bytes and using a
|
||||
32-kbyte sliding window), and provides a tool
|
||||
(contrib/tools/png-fix-too-far-back) for optimizing the CMF bytes
|
||||
correctly.
|
||||
|
||||
Libpng-1.6.0 and libpng-1.6.1 wrote uncompressed iTXt chunks with the wrong
|
||||
length, which resulted in PNG files that cannot be read beyond the bad iTXt
|
||||
chunk. This error was fixed in libpng-1.6.3, and a tool (called
|
||||
contrib/tools/png-fix-itxt) has been added to the libpng distribution.
|
||||
|
||||
XIII. Changes to Libpng from version 1.6.x to 1.7.x
|
||||
|
||||
Some functions that were deprecated in libpng-1.6.0 were removed:
|
||||
png_reset_zstream(),
|
||||
png_info_init_3(),
|
||||
png_data_freer() and its associated flags,
|
||||
png_malloc_default(),
|
||||
and png_free_default().
|
||||
|
||||
The PNG_ABORT() macro was changed to PNG_ABORT, and the default is now
|
||||
"abort()" for all platforms (previously it was "ExitProcess(0)" on
|
||||
Windows platforms). Starting with libpng-1.7.0 you have to define
|
||||
PNG_ABORT instead of PNG_ABORT(), and you must include a terminating
|
||||
semicolon in your definition, e.g.,
|
||||
|
||||
#if PNGCRUSH_LIBPNG_VER >= 10700
|
||||
# ifdef _WINDOWS_
|
||||
# define PNG_ABORT ExitProcess(0);
|
||||
# else
|
||||
# define PNG_ABORT abort();
|
||||
# endif
|
||||
#else
|
||||
# ifdef _WINDOWS_
|
||||
# define PNG_ABORT() ExitProcess(0)
|
||||
# else
|
||||
# define PNG_ABORT() abort()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
The 8-bit compose and rgb_to_grayscale operations were made more accurate.
|
||||
While these did not introduce API incompatibility, there may be differences
|
||||
in unit test results.
|
||||
|
||||
XIV. Detecting libpng
|
||||
|
||||
The png_get_io_ptr() function has been present since libpng-0.88, has never
|
||||
changed, and is unaffected by conditional compilation macros. It is the
|
||||
@@ -4981,11 +5085,11 @@ control. The git repository was built from old libpng-x.y.z.tar.gz files
|
||||
going back to version 0.70. You can access the git repository (read only)
|
||||
at
|
||||
|
||||
git://libpng.git.sourceforge.net/gitroot/libpng
|
||||
git://git.code.sf.net/p/libpng/code
|
||||
|
||||
or you can browse it via "gitweb" at
|
||||
or you can browse it with a web browser by selecting the "code" button at
|
||||
|
||||
http://libpng.git.sourceforge.net/git/gitweb.cgi?p=libpng
|
||||
https://sourceforge.net/projects/libpng
|
||||
|
||||
Patches can be sent to glennrp at users.sourceforge.net or to
|
||||
png-mng-implement at lists.sourceforge.net or you can upload them to
|
||||
@@ -4998,7 +5102,7 @@ simple verbal discriptions of bug fixes, reported either to the
|
||||
SourceForge bug tracker, to the png-mng-implement at lists.sf.net
|
||||
mailing list, or directly to glennrp.
|
||||
|
||||
XV. Coding style
|
||||
XVI. Coding style
|
||||
|
||||
Our coding style is similar to the "Allman" style, with curly
|
||||
braces on separate lines:
|
||||
@@ -5124,15 +5228,15 @@ Lines do not exceed 80 characters.
|
||||
|
||||
Other rules can be inferred by inspecting the libpng source.
|
||||
|
||||
XVI. Y2K Compliance in libpng
|
||||
XVII. Y2K Compliance in libpng
|
||||
|
||||
December 10, 2012
|
||||
June 18, 2013
|
||||
|
||||
Since the PNG Development group is an ad-hoc body, we can't make
|
||||
an official declaration.
|
||||
|
||||
This is your unofficial assurance that libpng from version 0.71 and
|
||||
upward through 1.6.0beta33 are Y2K compliant. It is my belief that earlier
|
||||
upward through 1.7.0beta15 are Y2K compliant. It is my belief that earlier
|
||||
versions were also Y2K compliant.
|
||||
|
||||
Libpng only has two year fields. One is a 2-byte unsigned integer
|
||||
|
||||
16
libpngpf.3
16
libpngpf.3
@@ -1,21 +1,11 @@
|
||||
.TH LIBPNGPF 3 "December 10, 2012"
|
||||
.TH LIBPNGPF 3 "June 18, 2013"
|
||||
.SH NAME
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.0beta33
|
||||
libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta15
|
||||
(private functions)
|
||||
.SH SYNOPSIS
|
||||
\fB#include \fI"pngpriv.h"
|
||||
|
||||
\fI\fB
|
||||
|
||||
\fBAs of libpng version \fP\fI1.5.1\fP\fB, this section is no longer \fP\fImaintained\fP\fB, now \fIthat
|
||||
|
||||
\fBthe private function prototypes are hidden in pngpriv.h and not \fIaccessible
|
||||
|
||||
\fBto applications. Look in pngpriv.h for the prototypes and a short \fIdescription
|
||||
|
||||
\fBof each \fIfunction.
|
||||
|
||||
\fI\fB
|
||||
\fBAs of libpng version \fP\fI1.5.1\fP\fB, this section is no longer \fP\fImaintained\fP\fB, now that the private function prototypes are hidden in pngpriv.h and not accessible to applications. Look in pngpriv.h for the prototypes and a short description of each \fIfunction.
|
||||
|
||||
.SH DESCRIPTION
|
||||
The functions previously listed here are used privately by libpng and are not
|
||||
|
||||
5
png.5
5
png.5
@@ -1,4 +1,4 @@
|
||||
.TH PNG 5 "December 10, 2012"
|
||||
.TH PNG 5 "June 18, 2013"
|
||||
.SH NAME
|
||||
png \- Portable Network Graphics (PNG) format
|
||||
.SH DESCRIPTION
|
||||
@@ -24,6 +24,7 @@ PNG specification (second edition), November 2003:
|
||||
.IP
|
||||
.br
|
||||
<http://www.w3.org/TR/2003/REC-PNG-20031110/
|
||||
.LP
|
||||
PNG 1.2 specification, July 1999:
|
||||
.IP
|
||||
.br
|
||||
@@ -58,7 +59,7 @@ Thomas Boutell and others (png-list).
|
||||
|
||||
.SH COPYRIGHT NOTICE
|
||||
.LP
|
||||
This man page is Copyright (c) 1998-2006 Glenn Randers-Pehrson. See png.h
|
||||
This man page is Copyright (c) 1998-2012 Glenn Randers-Pehrson. See png.h
|
||||
for conditions of use and distribution.
|
||||
.LP
|
||||
The PNG Specification (Second Edition) is
|
||||
|
||||
456
png.h
456
png.h
@@ -1,8 +1,8 @@
|
||||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng version 1.6.0beta33 - December 10, 2012
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* libpng version 1.7.0beta15 - June 18, 2013
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -11,7 +11,7 @@
|
||||
* Authors and maintainers:
|
||||
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
||||
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||
* libpng versions 0.97, January 1998, through 1.6.0beta33 - December 10, 2012: Glenn
|
||||
* libpng versions 0.97, January 1998, through 1.7.0beta15 - June 18, 2013: Glenn
|
||||
* See also "Contributing Authors", below.
|
||||
*
|
||||
* Note about libpng version numbers:
|
||||
@@ -166,7 +166,9 @@
|
||||
* 1.5.7beta01-05 15 10507 15.so.15.7[.0]
|
||||
* 1.5.7rc01-03 15 10507 15.so.15.7[.0]
|
||||
* 1.5.7 15 10507 15.so.15.7[.0]
|
||||
* 1.6.0beta01-32 16 10600 16.so.16.0[.0]
|
||||
* 1.6.0beta01-37 16 10600 16.so.16.0[.0]
|
||||
* 1.7.0alpha01-10 17 10700 17.so.17.0[.0]
|
||||
* 1.7.0beta01-15 17 10700 17.so.17.0[.0]
|
||||
*
|
||||
* Henceforth the source version will match the shared-library major
|
||||
* and minor numbers; the shared-library major version number will be
|
||||
@@ -198,8 +200,8 @@
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
*
|
||||
* libpng versions 1.2.6, August 15, 2004, through 1.6.0beta33, December 10, 2012, are
|
||||
* Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are
|
||||
* libpng versions 1.2.6, August 15, 2004, through 1.7.0beta15, June 18, 2013, are
|
||||
* Copyright (c) 2004, 2006-2013 Glenn Randers-Pehrson, and are
|
||||
* distributed according to the same disclaimer and license as libpng-1.2.5
|
||||
* with the following individual added to the list of Contributing Authors:
|
||||
*
|
||||
@@ -310,13 +312,13 @@
|
||||
* Y2K compliance in libpng:
|
||||
* =========================
|
||||
*
|
||||
* December 10, 2012
|
||||
* June 18, 2013
|
||||
*
|
||||
* Since the PNG Development group is an ad-hoc body, we can't make
|
||||
* an official declaration.
|
||||
*
|
||||
* This is your unofficial assurance that libpng from version 0.71 and
|
||||
* upward through 1.6.0beta33 are Y2K compliant. It is my belief that
|
||||
* upward through 1.7.0beta15 are Y2K compliant. It is my belief that
|
||||
* earlier versions were also Y2K compliant.
|
||||
*
|
||||
* Libpng only has two year fields. One is a 2-byte unsigned integer
|
||||
@@ -376,23 +378,23 @@
|
||||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.6.0beta33"
|
||||
#define PNG_LIBPNG_VER_STRING "1.7.0beta15"
|
||||
#define PNG_HEADER_VERSION_STRING \
|
||||
" libpng version 1.6.0beta33 - December 10, 2012\n"
|
||||
" libpng version 1.7.0beta15 - June 18, 2013\n"
|
||||
|
||||
#define PNG_LIBPNG_VER_SONUM 16
|
||||
#define PNG_LIBPNG_VER_DLLNUM 16
|
||||
#define PNG_LIBPNG_VER_SONUM 17
|
||||
#define PNG_LIBPNG_VER_DLLNUM 17
|
||||
|
||||
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
|
||||
#define PNG_LIBPNG_VER_MAJOR 1
|
||||
#define PNG_LIBPNG_VER_MINOR 6
|
||||
#define PNG_LIBPNG_VER_MINOR 7
|
||||
#define PNG_LIBPNG_VER_RELEASE 0
|
||||
|
||||
/* This should match the numeric part of the final component of
|
||||
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
|
||||
*/
|
||||
|
||||
#define PNG_LIBPNG_VER_BUILD 33
|
||||
#define PNG_LIBPNG_VER_BUILD 15
|
||||
|
||||
/* Release Status */
|
||||
#define PNG_LIBPNG_BUILD_ALPHA 1
|
||||
@@ -417,7 +419,7 @@
|
||||
* version 1.0.0 was mis-numbered 100 instead of 10000). From
|
||||
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
|
||||
*/
|
||||
#define PNG_LIBPNG_VER 10600 /* 1.6.0 */
|
||||
#define PNG_LIBPNG_VER 10700 /* 1.7.0 */
|
||||
|
||||
/* Library configuration: these options cannot be changed after
|
||||
* the library has been built.
|
||||
@@ -462,11 +464,6 @@
|
||||
|
||||
#ifndef PNG_VERSION_INFO_ONLY
|
||||
|
||||
/* Inhibit C++ name-mangling for libpng functions but not for system calls. */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* Version information for C files, stored in png.c. This had better match
|
||||
* the version above.
|
||||
*/
|
||||
@@ -474,17 +471,129 @@ extern "C" {
|
||||
|
||||
/* This file is arranged in several sections:
|
||||
*
|
||||
* 1. Any configuration options that can be specified by for the application
|
||||
* 1. ISO-PNG constants and definitions; values defined by PNG and not specific
|
||||
* to the libpng API.
|
||||
* 2. Any configuration options that can be specified by for the application
|
||||
* code when it is built. (Build time configuration is in pnglibconf.h)
|
||||
* 2. Type definitions (base types are defined in pngconf.h), structure
|
||||
* 3. Type definitions (base types are defined in pngconf.h), structure
|
||||
* definitions.
|
||||
* 3. Exported library functions.
|
||||
* 4. Simplified API.
|
||||
* 4. Exported library functions.
|
||||
* 5. Simplified API.
|
||||
*
|
||||
* The library source code has additional files (principally pngpriv.h) that
|
||||
* allow configuration of the library.
|
||||
*/
|
||||
/* Section 1: run time configuration
|
||||
|
||||
/* Section 1: ISO PNG constants and macros. */
|
||||
|
||||
/* ISO-PNG defines byte encodings for 16 and 32-bit unsigned values and 32-bit
|
||||
* signed values. The macros PNG_U16, PNG_U32 and PNG_S32 return values of type
|
||||
* (png_uint_16), (png_uint_32) and (png_int_32) which are target machine
|
||||
* specific representations of these values, using the types defined in
|
||||
* pngconf.h. The macros take two or four byte values in the order in which
|
||||
* they would occur in a PNG stream.
|
||||
*
|
||||
* These macros must return compile time constants if passed constant values -
|
||||
* machine specific implementations are not permitted. These macros are used by
|
||||
* default in the API functions/macros png_get_uint_16, png_get_uint_32,
|
||||
* png_get_uint_31 and png_get_int_32 declared below: these functions or macros
|
||||
* are the correct places for machine specific implementations (such as hardware
|
||||
* specific instructions.)
|
||||
*
|
||||
* The macros defined here are generic and intended to give maximum flexibility
|
||||
* in implementation to the compiler; only PNG_S32 contains a sequence point,
|
||||
* there are no side effects and the expressions used permit the maximum
|
||||
* parallelization (relevant because the four bytes may be loaded in parallel.)
|
||||
*/
|
||||
#define PNG_u2(b1, b2) (((unsigned int)(b1) << 8) + (b2))
|
||||
|
||||
#define PNG_U16(b1, b2) ((png_uint_16)PNG_u2(b1, b2))
|
||||
#define PNG_U32(b1, b2, b3, b4)\
|
||||
(((png_uint_32)PNG_u2(b1, b2) << 16) + PNG_u2(b3, b4))
|
||||
|
||||
/* ISO-PNG states that signed 32-bit values are stored in two's complement
|
||||
* format. There is no guarantee that (png_int_32) is exactly 32 bits, so the
|
||||
* following macro tests for a negative number and generates the machine format
|
||||
* directly by portable arithmetic operations. The cost is that the argument
|
||||
* 'b1' is evaluated twice.
|
||||
*/
|
||||
#define PNG_S32(b1, b2, b3, b4) ((b1) & 0x80\
|
||||
? -(png_int_32)((PNG_U32(b1, b2, b3, b4) ^ 0xffffffff) + 1)\
|
||||
: (png_int_32)PNG_U32(b1, b2, b3, b4))
|
||||
|
||||
/* Constants for known chunk types.
|
||||
*
|
||||
* MAINTAINERS: If you need to add a chunk, define the name here.
|
||||
* For historical reasons these constants have the form png_<name>; i.e.
|
||||
* the prefix is lower case. Please use decimal values as the parameters to
|
||||
* match the ISO PNG specification and to avoid relying on the C locale
|
||||
* interpretation of character values.
|
||||
*
|
||||
* Notice that PNG_U32 is used to define a 32-bit value for the 4 byte chunk
|
||||
* type. In fact the specification does not express chunk types this way,
|
||||
* however using a 32-bit value means that the chunk type can be read from the
|
||||
* stream using exactly the same code as used for a 32-bit unsigned value and
|
||||
* can be examined far more efficiently (using one arithmetic compare).
|
||||
*
|
||||
* Prior to 1.5.6 the chunk type constants were expressed as C strings. The
|
||||
* libpng API still uses strings for 'unknown' chunks and a macro,
|
||||
* PNG_STRING_FROM_CHUNK, allows a string to be generated if required. Notice
|
||||
* that for portable code numeric values must still be used; the string "IHDR"
|
||||
* is not portable and neither is PNG_U32('I', 'H', 'D', 'R').
|
||||
*
|
||||
* In 1.7.0 the definitions were made public in png.h to avoid having to
|
||||
* duplicate the same definitions in application code.
|
||||
*/
|
||||
#define png_IHDR PNG_U32( 73, 72, 68, 82)
|
||||
#define png_IDAT PNG_U32( 73, 68, 65, 84)
|
||||
#define png_IEND PNG_U32( 73, 69, 78, 68)
|
||||
#define png_PLTE PNG_U32( 80, 76, 84, 69)
|
||||
#define png_bKGD PNG_U32( 98, 75, 71, 68)
|
||||
#define png_cHRM PNG_U32( 99, 72, 82, 77)
|
||||
#define png_gAMA PNG_U32(103, 65, 77, 65)
|
||||
#define png_hIST PNG_U32(104, 73, 83, 84)
|
||||
#define png_iCCP PNG_U32(105, 67, 67, 80)
|
||||
#define png_iTXt PNG_U32(105, 84, 88, 116)
|
||||
#define png_oFFs PNG_U32(111, 70, 70, 115)
|
||||
#define png_pCAL PNG_U32(112, 67, 65, 76)
|
||||
#define png_sCAL PNG_U32(115, 67, 65, 76)
|
||||
#define png_pHYs PNG_U32(112, 72, 89, 115)
|
||||
#define png_sBIT PNG_U32(115, 66, 73, 84)
|
||||
#define png_sPLT PNG_U32(115, 80, 76, 84)
|
||||
#define png_sRGB PNG_U32(115, 82, 71, 66)
|
||||
#define png_sTER PNG_U32(115, 84, 69, 82)
|
||||
#define png_tEXt PNG_U32(116, 69, 88, 116)
|
||||
#define png_tIME PNG_U32(116, 73, 77, 69)
|
||||
#define png_tRNS PNG_U32(116, 82, 78, 83)
|
||||
#define png_zTXt PNG_U32(122, 84, 88, 116)
|
||||
|
||||
/* The following will work on (signed char*) strings, whereas the PNG_U32 macro
|
||||
* used directory would fail on top-bit-set values because of the sign
|
||||
* extension.
|
||||
*/
|
||||
#define PNG_CHUNK_FROM_STRING(s)\
|
||||
PNG_U32(0xff&(s)[0], 0xff&(s)[1], 0xff&(s)[2], 0xff&(s)[3])
|
||||
|
||||
/* This uses (char), not (png_byte) to avoid warnings on systems where (char) is
|
||||
* signed and the argument is a (char[]) This macro will fail miserably on
|
||||
* systems where (char) is more than 8 bits.
|
||||
*/
|
||||
#define PNG_STRING_FROM_CHUNK(s,c)\
|
||||
(void)(((char*)(s))[0]=(char)((c)>>24), ((char*)(s))[1]=(char)((c)>>16),\
|
||||
((char*)(s))[2]=(char)((c)>>8), ((char*)(s))[3]=(char)((c)))
|
||||
|
||||
/* Do the same but terminate with a null character. */
|
||||
#define PNG_CSTRING_FROM_CHUNK(s,c)\
|
||||
(void)(PNG_STRING_FROM_CHUNK(s,c), ((char*)(s))[4] = 0)
|
||||
|
||||
/* Test on flag values as defined in the spec (section 5.4): */
|
||||
#define PNG_CHUNK_ANCILLARY(c) (1 & ((c) >> 29))
|
||||
#define PNG_CHUNK_CRITICAL(c) (!PNG_CHUNK_ANCILLARY(c))
|
||||
#define PNG_CHUNK_PRIVATE(c) (1 & ((c) >> 21))
|
||||
#define PNG_CHUNK_RESERVED(c) (1 & ((c) >> 13))
|
||||
#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >> 5))
|
||||
|
||||
/* Section 2: run time configuration
|
||||
* See pnglibconf.h for build time configuration
|
||||
*
|
||||
* Run time configuration allows the application to choose between
|
||||
@@ -514,7 +623,12 @@ extern "C" {
|
||||
* Otherwise the calls are mapped to png_error.
|
||||
*/
|
||||
|
||||
/* Section 2: type definitions, including structures and compile time
|
||||
/* Inhibit C++ name-mangling for libpng functions but not for system calls. */
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/* Section 3: type definitions, including structures and compile time
|
||||
* constants.
|
||||
* See pngconf.h for base types that vary by machine/system
|
||||
*/
|
||||
@@ -522,7 +636,7 @@ extern "C" {
|
||||
/* This triggers a compiler error in png.c, if png.c and png.h
|
||||
* do not agree upon the version number.
|
||||
*/
|
||||
typedef char* png_libpng_version_1_6_0beta33;
|
||||
typedef char* png_libpng_version_1_7_0beta15;
|
||||
|
||||
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
|
||||
*
|
||||
@@ -663,8 +777,8 @@ typedef struct png_text_struct
|
||||
png_charp key; /* keyword, 1-79 character description of "text" */
|
||||
png_charp text; /* comment, may be an empty string (ie "")
|
||||
or a NULL pointer */
|
||||
png_size_t text_length; /* length of the text string */
|
||||
png_size_t itxt_length; /* length of the itxt string */
|
||||
size_t text_length; /* length of the text string */
|
||||
size_t itxt_length; /* length of the itxt string */
|
||||
png_charp lang; /* language code, 0-79 characters
|
||||
or a NULL pointer */
|
||||
png_charp lang_key; /* keyword translated UTF-8 string, 0 or more
|
||||
@@ -716,7 +830,7 @@ typedef struct png_unknown_chunk_t
|
||||
{
|
||||
png_byte name[5]; /* Textual chunk name with '\0' terminator */
|
||||
png_byte *data; /* Data, should not be modified on read! */
|
||||
png_size_t size;
|
||||
size_t size;
|
||||
|
||||
/* On write 'location' must be set using the flag values listed below.
|
||||
* Notice that on read it is set by libpng however the values stored have
|
||||
@@ -741,7 +855,7 @@ typedef png_unknown_chunk * * png_unknown_chunkpp;
|
||||
/* Maximum positive integer used in PNG is (2^31)-1 */
|
||||
#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL)
|
||||
#define PNG_UINT_32_MAX ((png_uint_32)(-1))
|
||||
#define PNG_SIZE_MAX ((png_size_t)(-1))
|
||||
#define PNG_SIZE_MAX ((size_t)(-1))
|
||||
|
||||
/* These are constants for fixed point values encoded in the
|
||||
* PNG specification manner (x100000)
|
||||
@@ -846,7 +960,7 @@ typedef png_unknown_chunk * * png_unknown_chunkpp;
|
||||
typedef struct png_row_info_struct
|
||||
{
|
||||
png_uint_32 width; /* width of row */
|
||||
png_size_t rowbytes; /* number of bytes in row */
|
||||
size_t rowbytes; /* number of bytes in row */
|
||||
png_byte color_type; /* color type of row */
|
||||
png_byte bit_depth; /* bit depth of row */
|
||||
png_byte channels; /* number of channels (1, 2, 3, or 4) */
|
||||
@@ -865,7 +979,7 @@ typedef png_row_info * * png_row_infopp;
|
||||
* expected to return the read data in the buffer.
|
||||
*/
|
||||
typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp));
|
||||
typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t));
|
||||
typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, size_t));
|
||||
typedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp));
|
||||
typedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32,
|
||||
int));
|
||||
@@ -958,7 +1072,7 @@ typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp,
|
||||
png_alloc_size_t));
|
||||
typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp));
|
||||
|
||||
/* Section 3: exported functions
|
||||
/* Section 4: exported functions
|
||||
* Here are the function definitions most commonly used. This is not
|
||||
* the place to find out how to use libpng. See libpng-manual.txt for the
|
||||
* full explanation, see example.c for the summary. This just provides
|
||||
@@ -1000,8 +1114,8 @@ PNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes));
|
||||
* signature, and non-zero otherwise. Having num_to_check == 0 or
|
||||
* start > 7 will always fail (ie return non-zero).
|
||||
*/
|
||||
PNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, png_size_t start,
|
||||
png_size_t num_to_check));
|
||||
PNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, size_t start,
|
||||
size_t num_to_check));
|
||||
|
||||
/* Simple signature checking function. This is the same as calling
|
||||
* png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).
|
||||
@@ -1020,11 +1134,11 @@ PNG_EXPORTA(5, png_structp, png_create_write_struct,
|
||||
png_error_ptr warn_fn),
|
||||
PNG_ALLOCATED);
|
||||
|
||||
PNG_EXPORT(6, png_size_t, png_get_compression_buffer_size,
|
||||
PNG_EXPORT(6, size_t, png_get_compression_buffer_size,
|
||||
(png_const_structrp png_ptr));
|
||||
|
||||
PNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structrp png_ptr,
|
||||
png_size_t size));
|
||||
size_t size));
|
||||
|
||||
/* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp
|
||||
* match up.
|
||||
@@ -1054,8 +1168,8 @@ PNG_EXPORTA(9, void, png_longjmp, (png_const_structrp png_ptr, int val),
|
||||
PNG_NORETURN);
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* Reset the compression stream */
|
||||
PNG_EXPORTA(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED);
|
||||
/* Reset the compression stream -- Removed from libpng-1.7.0 */
|
||||
PNG_REMOVED(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED)
|
||||
#endif
|
||||
|
||||
/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */
|
||||
@@ -1077,7 +1191,7 @@ PNG_EXPORT(13, void, png_write_sig, (png_structrp png_ptr));
|
||||
|
||||
/* Write a PNG chunk - size, type, (optional) data, CRC. */
|
||||
PNG_EXPORT(14, void, png_write_chunk, (png_structrp png_ptr, png_const_bytep
|
||||
chunk_name, png_const_bytep data, png_size_t length));
|
||||
chunk_name, png_const_bytep data, size_t length));
|
||||
|
||||
/* Write the start of a PNG chunk - length and chunk name. */
|
||||
PNG_EXPORT(15, void, png_write_chunk_start, (png_structrp png_ptr,
|
||||
@@ -1085,7 +1199,7 @@ PNG_EXPORT(15, void, png_write_chunk_start, (png_structrp png_ptr,
|
||||
|
||||
/* Write the data of a PNG chunk started with png_write_chunk_start(). */
|
||||
PNG_EXPORT(16, void, png_write_chunk_data, (png_structrp png_ptr,
|
||||
png_const_bytep data, png_size_t length));
|
||||
png_const_bytep data, size_t length));
|
||||
|
||||
/* Finish a chunk started with png_write_chunk_start() (includes CRC). */
|
||||
PNG_EXPORT(17, void, png_write_chunk_end, (png_structrp png_ptr));
|
||||
@@ -1094,12 +1208,9 @@ PNG_EXPORT(17, void, png_write_chunk_end, (png_structrp png_ptr));
|
||||
PNG_EXPORTA(18, png_infop, png_create_info_struct, (png_const_structrp png_ptr),
|
||||
PNG_ALLOCATED);
|
||||
|
||||
/* DEPRECATED: this function allowed init structures to be created using the
|
||||
* default allocation method (typically malloc). Use is deprecated in 1.6.0 and
|
||||
* the API will be removed in the future.
|
||||
*/
|
||||
PNG_EXPORTA(19, void, png_info_init_3, (png_infopp info_ptr,
|
||||
png_size_t png_info_struct_size), PNG_DEPRECATED);
|
||||
/* Removed from libpng-1.7.0 */
|
||||
PNG_REMOVED(19, void, png_info_init_3, (png_infopp info_ptr,
|
||||
size_t png_info_struct_size), PNG_DEPRECATED)
|
||||
|
||||
/* Writes all the PNG information before the image. */
|
||||
PNG_EXPORT(20, void, png_write_info_before_PLTE,
|
||||
@@ -1116,13 +1227,10 @@ PNG_EXPORT(22, void, png_read_info,
|
||||
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
||||
/* Convert to a US string format: there is no localization support in this
|
||||
* routine. The original implementation used a 29 character buffer in
|
||||
* png_struct, this will be removed in future versions.
|
||||
* png_struct, this has been removed (in libpng 1.7.0).
|
||||
*/
|
||||
#if PNG_LIBPNG_VER < 10700
|
||||
/* To do: remove this from libpng17 (and from libpng17/png.c and pngstruct.h) */
|
||||
PNG_EXPORTA(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr,
|
||||
png_const_timep ptime),PNG_DEPRECATED);
|
||||
#endif
|
||||
PNG_REMOVED(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr,
|
||||
png_const_timep ptime),PNG_DEPRECATED)
|
||||
PNG_EXPORT(241, int, png_convert_to_rfc1123_buffer, (char out[29],
|
||||
png_const_timep ptime));
|
||||
#endif
|
||||
@@ -1619,22 +1727,8 @@ PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action,
|
||||
PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,
|
||||
int filters));
|
||||
|
||||
/* Flags for png_set_filter() to say which filters to use. The flags
|
||||
* are chosen so that they don't conflict with real filter types
|
||||
* below, in case they are supplied instead of the #defined constants.
|
||||
* These values should NOT be changed.
|
||||
*/
|
||||
#define PNG_NO_FILTERS 0x00
|
||||
#define PNG_FILTER_NONE 0x08
|
||||
#define PNG_FILTER_SUB 0x10
|
||||
#define PNG_FILTER_UP 0x20
|
||||
#define PNG_FILTER_AVG 0x40
|
||||
#define PNG_FILTER_PAETH 0x80
|
||||
#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \
|
||||
PNG_FILTER_AVG | PNG_FILTER_PAETH)
|
||||
|
||||
/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now.
|
||||
* These defines should NOT be changed.
|
||||
* These defines match the values in the PNG specification.
|
||||
*/
|
||||
#define PNG_FILTER_VALUE_NONE 0
|
||||
#define PNG_FILTER_VALUE_SUB 1
|
||||
@@ -1643,6 +1737,26 @@ PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,
|
||||
#define PNG_FILTER_VALUE_PAETH 4
|
||||
#define PNG_FILTER_VALUE_LAST 5
|
||||
|
||||
/* The above values are valid arguments to png_set_filter() if only a single
|
||||
* filter is to be used. If multiple filters are to be allowed (the default is
|
||||
* to allow any of them) then a combination of the following masks must be used
|
||||
* and the low three bits of the argument to png_set_filter must be 0.
|
||||
*
|
||||
* The resultant argument fits in a single byte.
|
||||
*/
|
||||
#define PNG_FILTER_NONE (0x08 << PNG_FILTER_VALUE_NONE)
|
||||
#define PNG_FILTER_SUB (0x08 << PNG_FILTER_VALUE_SUB)
|
||||
#define PNG_FILTER_UP (0x08 << PNG_FILTER_VALUE_UP)
|
||||
#define PNG_FILTER_AVG (0x08 << PNG_FILTER_VALUE_AVG)
|
||||
#define PNG_FILTER_PAETH (0x08 << PNG_FILTER_VALUE_PAETH)
|
||||
|
||||
/* Then two convenience values. PNG_NO_FILTERS is the same as
|
||||
* PNG_FILTER_VALUE_NONE, but this is harmless because they mean the same thing.
|
||||
*/
|
||||
#define PNG_NO_FILTERS 0x00
|
||||
#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \
|
||||
PNG_FILTER_AVG | PNG_FILTER_PAETH)
|
||||
|
||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* EXPERIMENTAL */
|
||||
/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_
|
||||
* defines, either the default (minimum-sum-of-absolute-differences), or
|
||||
@@ -1835,7 +1949,7 @@ PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
/* This callback is called only for *unknown* chunks, if
|
||||
/* This callback is called only for *unknown* chunks. If
|
||||
* PNG_HANDLE_AS_UNKNOWN_SUPPORTED is set then it is possible to set known
|
||||
* chunks to be treated as unknown, however in this case the callback must do
|
||||
* any processing required by the chunk (e.g. by calling the appropriate
|
||||
@@ -1847,11 +1961,13 @@ PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp));
|
||||
* The integer return from the callback function is interpreted thus:
|
||||
*
|
||||
* negative: An error occured, png_chunk_error will be called.
|
||||
* zero: The chunk was not handled, the chunk will be discarded unless
|
||||
* png_set_keep_unknown_chunks has been used to set a 'keep' behavior
|
||||
* for this particular chunk, in which case that will be used. A
|
||||
* critical chunk will cause an error at this point unless it is to be
|
||||
* saved.
|
||||
* zero: The chunk was not handled, the default unknown handling is used
|
||||
* (even if this was a chunk that would otherwise be known.)
|
||||
* NOTE: prior to libpng 1.7 handling values of
|
||||
* PNG_HANDLE_CHUNK_AS_DEFAULT and PNG_HANDLE_CHUNK_NEVER were
|
||||
* converted to PNG_HANDLE_CHUNK_IF_SAFE (libpng 1.6.0 warns if this
|
||||
* happens) so it was not possible to discard unknown chunk data if a
|
||||
* user callback was installed.
|
||||
* positive: The chunk was handled, libpng will ignore/discard it.
|
||||
*/
|
||||
PNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structrp png_ptr,
|
||||
@@ -1876,7 +1992,7 @@ PNG_EXPORT(91, png_voidp, png_get_progressive_ptr,
|
||||
|
||||
/* Function to be called when data becomes available */
|
||||
PNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_bytep buffer, png_size_t buffer_size));
|
||||
png_inforp info_ptr, png_bytep buffer, size_t buffer_size));
|
||||
|
||||
/* A function which may be called *only* within png_process_data to stop the
|
||||
* processing of any more data. The function returns the number of bytes
|
||||
@@ -1885,7 +2001,7 @@ PNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr,
|
||||
* 'save' is set to true the routine will first save all the pending data and
|
||||
* will always return 0.
|
||||
*/
|
||||
PNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structrp, int save));
|
||||
PNG_EXPORT(219, size_t, png_process_data_pause, (png_structrp, int save));
|
||||
|
||||
/* A function which may be called *only* outside (after) a call to
|
||||
* png_process_data. It returns the number of bytes of data to skip in the
|
||||
@@ -1928,16 +2044,13 @@ PNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr,
|
||||
* in, it does not change the state for other png_info structures.
|
||||
*
|
||||
* It is unlikely that this function works correctly as of 1.6.0 and using it
|
||||
* may result either in memory leaks or double free of allocated data.
|
||||
* may result either in memory leaks or double free of allocated data. It was
|
||||
* removed in libpng 1.7.0.
|
||||
*/
|
||||
PNG_EXPORTA(99, void, png_data_freer, (png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, int freer, png_uint_32 mask), PNG_DEPRECATED);
|
||||
PNG_REMOVED(99, void, png_data_freer, (png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, int freer, png_uint_32 mask), PNG_DEPRECATED)
|
||||
|
||||
/* Assignments for png_data_freer */
|
||||
#define PNG_DESTROY_WILL_FREE_DATA 1
|
||||
#define PNG_SET_WILL_FREE_DATA 1
|
||||
#define PNG_USER_WILL_FREE_DATA 2
|
||||
/* Flags for png_ptr->free_me and info_ptr->free_me */
|
||||
/* Flags for png_free_data */
|
||||
#define PNG_FREE_HIST 0x0008
|
||||
#define PNG_FREE_ICCP 0x0010
|
||||
#define PNG_FREE_SPLT 0x0020
|
||||
@@ -1955,10 +2068,14 @@ PNG_EXPORTA(99, void, png_data_freer, (png_const_structrp png_ptr,
|
||||
#define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr,
|
||||
png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED);
|
||||
PNG_EXPORTA(101, void, png_free_default, (png_const_structrp png_ptr,
|
||||
png_voidp ptr), PNG_DEPRECATED);
|
||||
/* These were deprecated in libpng 1.6.0 and have been removed from libpng
|
||||
* 1.7.0; the functionality should be accessed by calling malloc or free
|
||||
* directly or, if png_error handling is required, calling png_malloc.
|
||||
*/
|
||||
PNG_REMOVED(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr,
|
||||
png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED)
|
||||
PNG_REMOVED(101, void, png_free_default, (png_const_structrp png_ptr,
|
||||
png_voidp ptr), PNG_DEPRECATED)
|
||||
#endif
|
||||
|
||||
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
||||
@@ -2026,7 +2143,7 @@ PNG_EXPORT(110, png_uint_32, png_get_valid, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr, png_uint_32 flag));
|
||||
|
||||
/* Returns number of bytes needed to hold a transformed row. */
|
||||
PNG_EXPORT(111, png_size_t, png_get_rowbytes, (png_const_structrp png_ptr,
|
||||
PNG_EXPORT(111, size_t, png_get_rowbytes, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr));
|
||||
|
||||
#ifdef PNG_INFO_IMAGE_SUPPORTED
|
||||
@@ -2182,7 +2299,7 @@ PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr,
|
||||
|
||||
#ifdef PNG_hIST_SUPPORTED
|
||||
PNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr, png_uint_16p *hist));
|
||||
png_inforp info_ptr, png_uint_16p *hist));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_hIST_SUPPORTED
|
||||
@@ -2214,7 +2331,7 @@ PNG_EXPORT(146, void, png_set_oFFs, (png_const_structrp png_ptr,
|
||||
|
||||
#ifdef PNG_pCAL_SUPPORTED
|
||||
PNG_EXPORT(147, png_uint_32, png_get_pCAL, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr, png_charp *purpose, png_int_32 *X0,
|
||||
png_inforp info_ptr, png_charp *purpose, png_int_32 *X0,
|
||||
png_int_32 *X1, int *type, int *nparams, png_charp *units,
|
||||
png_charpp *params));
|
||||
#endif
|
||||
@@ -2237,7 +2354,7 @@ PNG_EXPORT(150, void, png_set_pHYs, (png_const_structrp png_ptr,
|
||||
#endif
|
||||
|
||||
PNG_EXPORT(151, png_uint_32, png_get_PLTE, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr, png_colorp *palette, int *num_palette));
|
||||
png_inforp info_ptr, png_colorp *palette, int *num_palette));
|
||||
|
||||
PNG_EXPORT(152, void, png_set_PLTE, (png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_const_colorp palette, int num_palette));
|
||||
@@ -2266,7 +2383,7 @@ PNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_const_structrp png_ptr,
|
||||
|
||||
#ifdef PNG_iCCP_SUPPORTED
|
||||
PNG_EXPORT(158, png_uint_32, png_get_iCCP, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr, png_charpp name, int *compression_type,
|
||||
png_inforp info_ptr, png_charpp name, int *compression_type,
|
||||
png_bytepp profile, png_uint_32 *proflen));
|
||||
#endif
|
||||
|
||||
@@ -2277,19 +2394,19 @@ PNG_EXPORT(159, void, png_set_iCCP, (png_const_structrp png_ptr,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sPLT_SUPPORTED
|
||||
PNG_EXPORT(160, png_uint_32, png_get_sPLT, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr, png_sPLT_tpp entries));
|
||||
PNG_EXPORT(160, int, png_get_sPLT, (png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, png_sPLT_tpp entries));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sPLT_SUPPORTED
|
||||
PNG_EXPORT(161, void, png_set_sPLT, (png_const_structrp png_ptr,
|
||||
PNG_EXPORT(161, void, png_set_sPLT, (png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_const_sPLT_tp entries, int nentries));
|
||||
#endif
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
/* png_get_text also returns the number of text chunks in *num_text */
|
||||
PNG_EXPORT(162, png_uint_32, png_get_text, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr, png_textp *text_ptr, int *num_text));
|
||||
PNG_EXPORT(162, int, png_get_text, (png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, png_textp *text_ptr, int *num_text));
|
||||
#endif
|
||||
|
||||
/* Note while png_set_text() will accept a structure whose text,
|
||||
@@ -2300,7 +2417,7 @@ PNG_EXPORT(162, png_uint_32, png_get_text, (png_const_structrp png_ptr,
|
||||
*/
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
PNG_EXPORT(163, void, png_set_text, (png_const_structrp png_ptr,
|
||||
PNG_EXPORT(163, void, png_set_text, (png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_const_textp text_ptr, int num_text));
|
||||
#endif
|
||||
|
||||
@@ -2327,15 +2444,14 @@ PNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sCAL_SUPPORTED
|
||||
PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr, int *unit, double *width, double *height))
|
||||
#if (defined PNG_FLOATING_ARITHMETIC_SUPPORTED) || \
|
||||
(defined PNG_FLOATING_POINT_SUPPORTED)
|
||||
/* NOTE: this API is currently implemented using floating point arithmetic,
|
||||
* consequently it can only be used on systems with floating point support.
|
||||
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
/* NOTE: these API are currently implemented using floating point arithmetic,
|
||||
* consequently they can only be used on systems with floating point support.
|
||||
* In any case the range of values supported by png_fixed_point is small and it
|
||||
* is highly recommended that png_get_sCAL_s be used instead.
|
||||
*/
|
||||
PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr, int *unit, double *width, double *height))
|
||||
PNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed,
|
||||
(png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit,
|
||||
png_fixed_point *width, png_fixed_point *height))
|
||||
@@ -2344,8 +2460,13 @@ PNG_EXPORT(169, png_uint_32, png_get_sCAL_s,
|
||||
(png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit,
|
||||
png_charpp swidth, png_charpp sheight));
|
||||
|
||||
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
/* This also requires internal floating point arithmetic support - i.e. it
|
||||
* requires a full math library, not just floating point handling.
|
||||
*/
|
||||
PNG_FP_EXPORT(170, void, png_set_sCAL, (png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, int unit, double width, double height))
|
||||
#endif
|
||||
PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, int unit, png_fixed_point width,
|
||||
png_fixed_point height))
|
||||
@@ -2361,16 +2482,21 @@ PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr,
|
||||
* NOTE: prior to 1.6.0 the handling specified for particular chunks on read was
|
||||
* ignored and the default was used, the per-chunk setting only had an effect on
|
||||
* write. If you wish to have chunk-specific handling on read in code that must
|
||||
* work on earlier versions you must use a user chunk callback to specify the
|
||||
* work on earlier versions you must use a user chunk callback to implement the
|
||||
* desired handling (keep or discard.)
|
||||
*
|
||||
* NOTE: prior to 1.7.0 when a user callback returned '0', indicating that the
|
||||
* chunk had not been handled, libpng would preserve it regardless of the
|
||||
* default or per-chunk settings. For compatibility with earlier versions
|
||||
* simply return '1' (handled) from the callback to discard the chunk.
|
||||
*
|
||||
* The 'keep' parameter is a PNG_HANDLE_CHUNK_ value as listed below. The
|
||||
* parameter is interpreted as follows:
|
||||
*
|
||||
* READ:
|
||||
* PNG_HANDLE_CHUNK_AS_DEFAULT:
|
||||
* Known chunks: do normal libpng processing, do not keep the chunk (but
|
||||
* set the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
|
||||
* see the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
|
||||
* Unknown chunks: for a specific chunk use the global default, when used
|
||||
* as the default discard the chunk data.
|
||||
* PNG_HANDLE_CHUNK_NEVER:
|
||||
@@ -2456,7 +2582,7 @@ PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr,
|
||||
PNG_EXPORT(174, void, png_set_unknown_chunks, (png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_const_unknown_chunkp unknowns,
|
||||
int num_unknowns));
|
||||
/* NOTE: prior to 1.6.0 this routine set the 'location' field of the added
|
||||
@@ -2472,7 +2598,7 @@ PNG_EXPORT(175, void, png_set_unknown_chunk_location,
|
||||
(png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location));
|
||||
|
||||
PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr, png_unknown_chunkpp entries));
|
||||
png_inforp info_ptr, png_unknown_chunkpp entries));
|
||||
#endif
|
||||
|
||||
/* Png_free_data() will turn off the "valid" flag for anything it frees.
|
||||
@@ -2726,27 +2852,18 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
|
||||
|
||||
#ifdef PNG_USE_READ_MACROS
|
||||
/* Inline macros to do direct reads of bytes from the input buffer.
|
||||
* The png_get_int_32() routine assumes we are using two's complement
|
||||
* format for negative values, which is almost certainly true.
|
||||
*/
|
||||
# define PNG_B(ptr, offset) (((png_const_bytep)(ptr))[offset])
|
||||
# define PNG_get_uint_32(buf) \
|
||||
(((png_uint_32)(*(buf)) << 24) + \
|
||||
((png_uint_32)(*((buf) + 1)) << 16) + \
|
||||
((png_uint_32)(*((buf) + 2)) << 8) + \
|
||||
((png_uint_32)(*((buf) + 3))))
|
||||
PNG_U32(PNG_B(buf,0), PNG_B(buf,1), PNG_B(buf,2), PNG_B(buf,3))
|
||||
|
||||
/* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
|
||||
* function) incorrectly returned a value of type png_uint_32.
|
||||
*/
|
||||
# define PNG_get_uint_16(buf) \
|
||||
((png_uint_16) \
|
||||
(((unsigned int)(*(buf)) << 8) + \
|
||||
((unsigned int)(*((buf) + 1)))))
|
||||
# define PNG_get_uint_16(buf) PNG_U16(PNG_B(buf,0), PNG_B(buf,1))
|
||||
|
||||
# define PNG_get_int_32(buf) \
|
||||
((png_int_32)((*(buf) & 0x80) \
|
||||
? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffffL) + 1)) \
|
||||
: (png_int_32)png_get_uint_32(buf)))
|
||||
PNG_S32(PNG_B(buf,0), PNG_B(buf,1), PNG_B(buf,2), PNG_B(buf,3))
|
||||
|
||||
/* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h,
|
||||
* but defining a macro name prefixed with PNG_PREFIX.
|
||||
@@ -2765,8 +2882,63 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
PNG_EXPORT(242, void, png_set_check_for_invalid_index,
|
||||
(png_structrp png_ptr, int allowed));
|
||||
# ifdef PNG_GET_PALETTE_MAX_SUPPORTED
|
||||
PNG_EXPORT(243, int, png_get_palette_max, (png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr));
|
||||
# endif
|
||||
#endif /* CHECK_FOR_INVALID_INDEX */
|
||||
|
||||
/*******************************************************************************
|
||||
* SIMPLIFIED API
|
||||
* IMPLEMENTATION OPTIONS
|
||||
*******************************************************************************
|
||||
*
|
||||
* Support for arbitrary implementation-specific optimizations. The API allows
|
||||
* particular options to be turned on or off. 'Option' is the number of the
|
||||
* option and 'onoff' is 0 (off) or non-0 (on). The value returned is given
|
||||
* by the PNG_OPTION_ defines below.
|
||||
*
|
||||
* HARDWARE: normally hardware capabilites, such as the Intel SSE instructions,
|
||||
* are detected at run time, however sometimes it may be impossible
|
||||
* to do this in user mode, in which case it is necessary to discover
|
||||
* the capabilities in an OS specific way. Such capabilities are
|
||||
* listed here when libpng has support for them and must be turned
|
||||
* ON by the application if present.
|
||||
*
|
||||
* SOFTWARE: sometimes software optimizations actually result in performance
|
||||
* decrease on some architectures or systems, or with some sets of
|
||||
* PNG images. 'Software' options allow such optimizations to be
|
||||
* selected at run time.
|
||||
*/
|
||||
#ifdef PNG_SET_OPTION_SUPPORTED
|
||||
#ifdef PNG_ARM_NEON_API_SUPPORTED
|
||||
# define PNG_ARM_NEON 0 /* HARDWARE: ARM Neon SIMD instructions supported */
|
||||
#endif
|
||||
#define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */
|
||||
#define PNG_OPTION_NEXT 4 /* Next option - numbers must be even */
|
||||
|
||||
/* Return values: NOTE: there are four values and 'off' is *not* zero */
|
||||
#define PNG_OPTION_UNSET 0 /* Unset - defaults to off */
|
||||
#define PNG_OPTION_INVALID 1 /* Option number out of range */
|
||||
#define PNG_OPTION_OFF 2
|
||||
#define PNG_OPTION_ON 3
|
||||
|
||||
PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,
|
||||
int onoff));
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* END OF HARDWARE OPTIONS
|
||||
******************************************************************************/
|
||||
|
||||
/* Maintainer: Put new public prototypes here ^, in libpng.3, and project
|
||||
* defs
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Section 5: SIMPLIFIED API
|
||||
*******************************************************************************
|
||||
*
|
||||
* Please read the documentation in libpng-manual.txt (TODO: write said
|
||||
@@ -3086,6 +3258,24 @@ typedef struct
|
||||
* slight speed gain.
|
||||
*/
|
||||
|
||||
#define PNG_IMAGE_FLAG_16BIT_sRGB 0x04
|
||||
/* On read if the image is a 16-bit per component image and there is no gAMA
|
||||
* or sRGB chunk assume that the components are sRGB encoded. Notice that
|
||||
* images output by the simplified API always have gamma information; setting
|
||||
* this flag only affects the interpretation of 16-bit images from an
|
||||
* external source. It is recommended that the application expose this flag
|
||||
* to the user; the user can normally easily recognize the difference between
|
||||
* linear and sRGB encoding. This flag has no effect on write - the data
|
||||
* passed to the write APIs must have the correct encoding (as defined
|
||||
* above.)
|
||||
*
|
||||
* If the flag is not set (the default) input 16-bit per component data is
|
||||
* assumed to be linear.
|
||||
*
|
||||
* NOTE: the flag can only be set after the png_image_begin_read_ call,
|
||||
* because that call initializes the 'flags' field.
|
||||
*/
|
||||
|
||||
#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
|
||||
/* READ APIs
|
||||
* ---------
|
||||
@@ -3106,7 +3296,7 @@ PNG_EXPORT(235, int, png_image_begin_read_from_stdio, (png_imagep image,
|
||||
#endif /* PNG_STDIO_SUPPORTED */
|
||||
|
||||
PNG_EXPORT(236, int, png_image_begin_read_from_memory, (png_imagep image,
|
||||
png_const_voidp memory, png_size_t size));
|
||||
png_const_voidp memory, size_t size));
|
||||
/* The PNG header is read from the given memory buffer. */
|
||||
|
||||
PNG_EXPORT(237, int, png_image_finish_read, (png_imagep image,
|
||||
@@ -3136,7 +3326,7 @@ PNG_EXPORT(237, int, png_image_finish_read, (png_imagep image,
|
||||
* PNG_FORMAT_FLAG_LINEAR *not* set.
|
||||
*
|
||||
* For linear output removing the alpha channel is always done by compositing
|
||||
* on black and background is ignored.:
|
||||
* on black and background is ignored.
|
||||
*
|
||||
* colormap must be supplied when PNG_FORMAT_FLAG_COLORMAP is set. It must
|
||||
* be at least the size (in bytes) returned by PNG_IMAGE_COLORMAP_SIZE.
|
||||
@@ -3151,6 +3341,7 @@ PNG_EXPORT(238, void, png_image_free, (png_imagep image));
|
||||
#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */
|
||||
|
||||
#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
/* WRITE APIS
|
||||
* ----------
|
||||
* For write you must initialize a png_image structure to describe the image to
|
||||
@@ -3193,27 +3384,18 @@ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
|
||||
*
|
||||
* Note that the write API does not support interlacing or sub-8-bit pixels.
|
||||
*/
|
||||
#endif /* PNG_STDIO_SUPPORTED */
|
||||
#endif /* PNG_SIMPLIFIED_WRITE_SUPPORTED */
|
||||
/*******************************************************************************
|
||||
* END OF SIMPLIFIED API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \
|
||||
defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)
|
||||
PNG_EXPORT(242, void, png_set_check_for_invalid_index,
|
||||
(png_structrp png_ptr, int allowed));
|
||||
#endif
|
||||
|
||||
/* Maintainer: Put new public prototypes here ^, in libpng.3, and project
|
||||
* defs
|
||||
*/
|
||||
|
||||
/* The last ordinal number (this is the *last* one already used; the next
|
||||
* one to use is one more than this.) Maintainer, remember to add an entry to
|
||||
* scripts/symbols.def as well.
|
||||
*/
|
||||
#ifdef PNG_EXPORT_LAST_ORDINAL
|
||||
PNG_EXPORT_LAST_ORDINAL(242);
|
||||
PNG_EXPORT_LAST_ORDINAL(244);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
41
pngconf.h
41
pngconf.h
@@ -1,9 +1,9 @@
|
||||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng version 1.6.0beta33 - December 10, 2012
|
||||
* libpng version 1.7.0beta15 - June 18, 2013
|
||||
*
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -198,18 +198,16 @@
|
||||
* ==========================
|
||||
* This code is used at build time to find PNG_IMPEXP, the API settings
|
||||
* and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL
|
||||
* import processing is possible. On Windows/x86 systems it also sets
|
||||
* import processing is possible. On Windows systems it also sets
|
||||
* compiler-specific macros to the values required to change the calling
|
||||
* conventions of the various functions.
|
||||
*/
|
||||
#if ( defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\
|
||||
defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) ) &&\
|
||||
( defined(_X86_) || defined(_X64_) || defined(_M_IX86) ||\
|
||||
defined(_M_X64) || defined(_M_IA64) )
|
||||
/* Windows system (DOS doesn't support DLLs) running on x86/x64. Includes
|
||||
* builds under Cygwin or MinGW. Also includes Watcom builds but these need
|
||||
* special treatment because they are not compatible with GCC or Visual C
|
||||
* because of different calling conventions.
|
||||
#if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\
|
||||
defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
/* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or
|
||||
* MinGW on any architecture currently supported by Windows. Also includes
|
||||
* Watcom builds but these need special treatment because they are not
|
||||
* compatible with GCC or Visual C because of different calling conventions.
|
||||
*/
|
||||
# if PNG_API_RULE == 2
|
||||
/* If this line results in an error, either because __watcall is not
|
||||
@@ -220,9 +218,12 @@
|
||||
# define PNGCAPI __watcall
|
||||
# endif
|
||||
|
||||
# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800))
|
||||
# if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800))
|
||||
# define PNGCAPI __cdecl
|
||||
# if PNG_API_RULE == 1
|
||||
/* If this line results in an error __stdcall is not understood and
|
||||
* PNG_API_RULE should not have been set to '1'.
|
||||
*/
|
||||
# define PNGAPI __stdcall
|
||||
# endif
|
||||
# else
|
||||
@@ -260,7 +261,7 @@
|
||||
# endif
|
||||
# endif /* compiler */
|
||||
|
||||
#else /* !Windows/x86 */
|
||||
#else /* !Windows */
|
||||
# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
|
||||
# define PNGAPI _System
|
||||
# else /* !Windows/x86 && !OS/2 */
|
||||
@@ -510,6 +511,8 @@
|
||||
|
||||
/* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however,
|
||||
* requires an ISOC90 compiler and relies on consistent behavior of sizeof.
|
||||
*
|
||||
* DEPRECATED: don't use these types, instead use size_t and ptrdiff_t.
|
||||
*/
|
||||
typedef size_t png_size_t;
|
||||
typedef ptrdiff_t png_ptrdiff_t;
|
||||
@@ -530,13 +533,13 @@ typedef ptrdiff_t png_ptrdiff_t;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no
|
||||
* smaller than png_uint_32. Casts from png_size_t or png_uint_32 to
|
||||
/* png_alloc_size_t is guaranteed to be no smaller than size_t, and no
|
||||
* smaller than png_uint_32. Casts from size_t or png_uint_32 to
|
||||
* png_alloc_size_t are not necessary; in fact, it is recommended not to use
|
||||
* them at all so that the compiler can complain when something turns out to be
|
||||
* problematic.
|
||||
*
|
||||
* Casts in the other direction (from png_alloc_size_t to png_size_t or
|
||||
* Casts in the other direction (from png_alloc_size_t to size_t or
|
||||
* png_uint_32) should be explicitly applied; however, we do not expect to
|
||||
* encounter practical situations that require such conversions.
|
||||
*
|
||||
@@ -546,7 +549,7 @@ typedef ptrdiff_t png_ptrdiff_t;
|
||||
#ifdef PNG_SMALL_SIZE_T
|
||||
typedef png_uint_32 png_alloc_size_t;
|
||||
#else
|
||||
typedef png_size_t png_alloc_size_t;
|
||||
typedef size_t png_alloc_size_t;
|
||||
#endif
|
||||
|
||||
/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler
|
||||
@@ -582,8 +585,8 @@ typedef char * png_charp;
|
||||
typedef const char * png_const_charp;
|
||||
typedef png_fixed_point * png_fixed_point_p;
|
||||
typedef const png_fixed_point * png_const_fixed_point_p;
|
||||
typedef png_size_t * png_size_tp;
|
||||
typedef const png_size_t * png_const_size_tp;
|
||||
typedef size_t * png_size_tp;
|
||||
typedef const size_t * png_const_size_tp;
|
||||
|
||||
#ifdef PNG_STDIO_SUPPORTED
|
||||
typedef FILE * png_FILE_p;
|
||||
|
||||
37
pngerror.c
37
pngerror.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -163,7 +163,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||
case PNG_NUMBER_FORMAT_02u:
|
||||
/* Expects at least 2 digits. */
|
||||
mincount = 2;
|
||||
/* FALL THROUGH */
|
||||
/* fall through */
|
||||
|
||||
case PNG_NUMBER_FORMAT_u:
|
||||
*--end = digits[number % 10];
|
||||
@@ -173,7 +173,7 @@ png_format_number(png_const_charp start, png_charp end, int format,
|
||||
case PNG_NUMBER_FORMAT_02x:
|
||||
/* This format expects at least two digits */
|
||||
mincount = 2;
|
||||
/* FALL THROUGH */
|
||||
/* fall through */
|
||||
|
||||
case PNG_NUMBER_FORMAT_x:
|
||||
*--end = digits[number & 0xf];
|
||||
@@ -516,7 +516,7 @@ png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error)
|
||||
/* This is always supported, but for just read or just write it
|
||||
* unconditionally does the right thing.
|
||||
*/
|
||||
# if (defined PNG_READ_SUPPORTED) && (defined PNG_WRITE_SUPPORTED)
|
||||
# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED)
|
||||
if (png_ptr->mode & PNG_IS_READ_STRUCT)
|
||||
# endif
|
||||
|
||||
@@ -530,7 +530,7 @@ png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error)
|
||||
}
|
||||
# endif
|
||||
|
||||
# if (defined PNG_READ_SUPPORTED) && (defined PNG_WRITE_SUPPORTED)
|
||||
# if defined(PNG_READ_SUPPORTED) && defined(PNG_WRITE_SUPPORTED)
|
||||
else if (!(png_ptr->mode & PNG_IS_READ_STRUCT))
|
||||
# endif
|
||||
|
||||
@@ -546,7 +546,13 @@ png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error)
|
||||
}
|
||||
|
||||
#ifdef PNG_ERROR_TEXT_SUPPORTED
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
|
||||
#if defined(PNG_FLOATING_POINT_SUPPORTED) && \
|
||||
(defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \
|
||||
defined(PNG_sCAL_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || \
|
||||
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)) || \
|
||||
(defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) &&\
|
||||
defined(PNG_sCAL_SUPPORTED))
|
||||
PNG_FUNCTION(void,
|
||||
png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN)
|
||||
{
|
||||
@@ -740,8 +746,17 @@ png_longjmp,(png_const_structrp png_ptr, int val),PNG_NORETURN)
|
||||
png_ptr->longjmp_fn(*png_ptr->jmp_buf_ptr, val);
|
||||
#endif
|
||||
|
||||
/* Here if not setjmp support or if png_ptr is null. */
|
||||
PNG_ABORT();
|
||||
/* If control reaches this point, png_longjmp() must not return. The only
|
||||
* choice is to terminate the whole process (or maybe the thread); to do
|
||||
* this the ANSI-C abort() function is used unless a different method is
|
||||
* implemented by overriding the default configuration setting for
|
||||
* PNG_ABORT (see scripts/pnglibconf.dfa).
|
||||
*
|
||||
* API change: prior to 1.7.0 PNG_ABORT was invoked as a function type macro
|
||||
* with no arguments 'PNG_ABORT();', in 1.7.0 this is changed to a simple
|
||||
* macro that is defined in the configuration.
|
||||
*/
|
||||
PNG_ABORT
|
||||
}
|
||||
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
@@ -844,8 +859,8 @@ png_set_strip_error_numbers(png_structrp png_ptr, png_uint_32 strip_mode)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined PNG_SIMPLIFIED_READ_SUPPORTED ||\
|
||||
defined PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||
#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\
|
||||
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
|
||||
/* Currently the above both depend on SETJMP_SUPPORTED, however it would be
|
||||
* possible to implement without setjmp support just so long as there is some
|
||||
* way to handle the error return here:
|
||||
|
||||
66
pngget.c
66
pngget.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -552,14 +552,14 @@ png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
*green_Z = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z");
|
||||
if (blue_X != NULL)
|
||||
*blue_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.blue_X,
|
||||
"cHRM blue X");
|
||||
*blue_X = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X");
|
||||
if (blue_Y != NULL)
|
||||
*blue_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.blue_Y,
|
||||
"cHRM blue Y");
|
||||
*blue_Y = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y");
|
||||
if (blue_Z != NULL)
|
||||
*blue_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.blue_Z,
|
||||
"cHRM blue Z");
|
||||
*blue_Z = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z");
|
||||
return (PNG_INFO_cHRM);
|
||||
}
|
||||
|
||||
@@ -701,7 +701,7 @@ png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
|
||||
#ifdef PNG_iCCP_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_iCCP(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_charpp name, int *compression_type,
|
||||
png_bytepp profile, png_uint_32 *proflen)
|
||||
{
|
||||
@@ -726,14 +726,14 @@ png_get_iCCP(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sPLT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sPLT(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
int PNGAPI
|
||||
png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_sPLT_tpp spalettes)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
|
||||
{
|
||||
*spalettes = info_ptr->splt_palettes;
|
||||
return ((png_uint_32)info_ptr->splt_palettes_num);
|
||||
return info_ptr->splt_palettes_num;
|
||||
}
|
||||
|
||||
return (0);
|
||||
@@ -742,7 +742,7 @@ png_get_sPLT(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
|
||||
#ifdef PNG_hIST_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_hIST(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_uint_16p *hist)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "hIST");
|
||||
@@ -818,7 +818,7 @@ png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
|
||||
#ifdef PNG_pCAL_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_pCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, int *nparams,
|
||||
png_charp *units, png_charpp *params)
|
||||
{
|
||||
@@ -843,9 +843,8 @@ png_get_pCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sCAL_SUPPORTED
|
||||
# ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
# if (defined PNG_FLOATING_ARITHMETIC_SUPPORTED) || \
|
||||
(defined PNG_FLOATING_POINT_SUPPORTED)
|
||||
# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
# ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
int *unit, png_fixed_point *width, png_fixed_point *height)
|
||||
@@ -866,9 +865,9 @@ png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
|
||||
return(0);
|
||||
}
|
||||
# endif /* FLOATING_ARITHMETIC */
|
||||
# endif /* FIXED_POINT */
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
# endif /* FIXED_POINT */
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
int *unit, double *width, double *height)
|
||||
@@ -884,7 +883,9 @@ png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
|
||||
return(0);
|
||||
}
|
||||
# endif /* FLOATING POINT */
|
||||
# endif /* FLOATING POINT */
|
||||
# endif /* FLOATING_ARITHMETIC */
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
int *unit, png_charpp width, png_charpp height)
|
||||
@@ -938,7 +939,7 @@ png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
#endif /* pHYs */
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_PLTE(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_colorp *palette, int *num_palette)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "PLTE");
|
||||
@@ -974,8 +975,8 @@ png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_text(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
int PNGAPI
|
||||
png_get_text(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_textp *text_ptr, int *num_text)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
|
||||
@@ -989,7 +990,7 @@ png_get_text(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
if (num_text != NULL)
|
||||
*num_text = info_ptr->num_text;
|
||||
|
||||
return ((png_uint_32)info_ptr->num_text);
|
||||
return info_ptr->num_text;
|
||||
}
|
||||
|
||||
if (num_text != NULL)
|
||||
@@ -1064,7 +1065,7 @@ png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
int PNGAPI
|
||||
png_get_unknown_chunks(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_get_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_unknown_chunkpp unknowns)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && unknowns != NULL)
|
||||
@@ -1161,4 +1162,17 @@ png_get_io_chunk_type (png_const_structrp png_ptr)
|
||||
}
|
||||
#endif /* ?PNG_IO_STATE_SUPPORTED */
|
||||
|
||||
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
# ifdef PNG_GET_PALETTE_MAX_SUPPORTED
|
||||
int PNGAPI
|
||||
png_get_palette_max(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return png_ptr->num_palette_max;
|
||||
|
||||
return (-1);
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#endif /* PNG_READ_SUPPORTED || PNG_WRITE_SUPPORTED */
|
||||
|
||||
@@ -88,7 +88,7 @@ struct png_info_def
|
||||
* and initialize the appropriate fields below.
|
||||
*/
|
||||
|
||||
#if defined PNG_COLORSPACE_SUPPORTED || defined PNG_GAMMA_SUPPORTED
|
||||
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||
/* png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are
|
||||
* defined. When COLORSPACE is switched on all the colorspace-defining
|
||||
* chunks should be enabled, when GAMMA is switched on all the gamma-defining
|
||||
@@ -223,13 +223,13 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Storage for unknown chunks that the library doesn't recognize. */
|
||||
png_unknown_chunkp unknown_chunks;
|
||||
unsigned int unknown_chunks_num;
|
||||
int unknown_chunks_num;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sPLT_SUPPORTED
|
||||
/* Data on sPLT chunks (there may be more than one). */
|
||||
png_sPLT_tp splt_palettes;
|
||||
png_uint_32 splt_palettes_num;
|
||||
int splt_palettes_num;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sCAL_SUPPORTED
|
||||
|
||||
110
pngmem.c
110
pngmem.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -76,7 +76,7 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
PNG_UNUSED(png_ptr)
|
||||
#endif
|
||||
if (size > 0 && size <= ~(size_t)0
|
||||
if (size > 0 && size <= PNG_SIZE_MAX
|
||||
# ifdef PNG_MAX_MALLOC_64K
|
||||
&& size <= 65536U
|
||||
# endif
|
||||
@@ -95,6 +95,77 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* This is really here only to work round a spurious warning in GCC 4.6 and 4.7
|
||||
* that arises because of the checks in png_realloc_array that are repeated in
|
||||
* png_malloc_array.
|
||||
*/
|
||||
static png_voidp
|
||||
png_malloc_array_checked(png_const_structrp png_ptr, int nelements,
|
||||
size_t element_size)
|
||||
{
|
||||
png_alloc_size_t req = nelements; /* known to be > 0 */
|
||||
|
||||
if (req <= PNG_SIZE_MAX/element_size)
|
||||
return png_malloc_base(png_ptr, req * element_size);
|
||||
|
||||
/* The failure case when the request is too large */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_malloc_array,(png_const_structrp png_ptr, int nelements,
|
||||
size_t element_size),PNG_ALLOCATED)
|
||||
{
|
||||
if (nelements <= 0 || element_size == 0)
|
||||
png_error(png_ptr, "internal error: array alloc");
|
||||
|
||||
return png_malloc_array_checked(png_ptr, nelements, element_size);
|
||||
}
|
||||
|
||||
PNG_FUNCTION(png_voidp /* PRIVATE */,
|
||||
png_realloc_array,(png_structrp png_ptr, png_const_voidp old_array,
|
||||
int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED)
|
||||
{
|
||||
/* These are internal errors: */
|
||||
if (add_elements <= 0 || element_size == 0 || old_elements < 0 ||
|
||||
(old_array == NULL && old_elements > 0))
|
||||
png_error(png_ptr, "internal error: array realloc");
|
||||
|
||||
/* Check for overflow on the elements count (so the caller does not have to
|
||||
* check.)
|
||||
*/
|
||||
if (add_elements <= INT_MAX - old_elements)
|
||||
{
|
||||
png_voidp new_array = png_malloc_array_checked(png_ptr,
|
||||
old_elements+add_elements, element_size);
|
||||
|
||||
if (new_array != NULL)
|
||||
{
|
||||
/* Because png_malloc_array worked the size calculations below cannot
|
||||
* overflow.
|
||||
*/
|
||||
if (old_elements > 0)
|
||||
memcpy(new_array, old_array, element_size*(unsigned)old_elements);
|
||||
|
||||
memset((char*)new_array + element_size*(unsigned)old_elements, 0,
|
||||
element_size*(unsigned)add_elements);
|
||||
|
||||
return new_array;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
# ifdef PNG_USER_LIMITS_SUPPORTED
|
||||
/* The potential overflow case. Set the cache counter so libpng will
|
||||
* not make any more attempts
|
||||
*/
|
||||
png_ptr->user_chunk_cache_max = 2;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return NULL; /* error */
|
||||
}
|
||||
|
||||
/* Various functions that have different error handling are derived from this.
|
||||
* png_malloc always exists, but if PNG_USER_MEM_SUPPORTED is defined a separate
|
||||
* function png_malloc_default is also provided.
|
||||
@@ -110,31 +181,11 @@ png_malloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
|
||||
ret = png_malloc_base(png_ptr, size);
|
||||
|
||||
if (ret == NULL)
|
||||
png_error(png_ptr, "Out of memory"); /* 'm' means png_malloc */
|
||||
png_error(png_ptr, "Out of memory");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
PNG_FUNCTION(png_voidp,PNGAPI
|
||||
png_malloc_default,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||
PNG_ALLOCATED PNG_DEPRECATED)
|
||||
{
|
||||
png_voidp ret;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return NULL;
|
||||
|
||||
/* Passing 'NULL' here bypasses the application provided memory handler. */
|
||||
ret = png_malloc_base(NULL/*use malloc*/, size);
|
||||
|
||||
if (ret == NULL)
|
||||
png_error(png_ptr, "Out of Memory"); /* 'M' means png_malloc_default */
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
/* This function was added at libpng version 1.2.3. The png_malloc_warn()
|
||||
* function will issue a png_warning and return NULL instead of issuing a
|
||||
* png_error, if it fails to allocate the requested memory.
|
||||
@@ -170,17 +221,8 @@ png_free(png_const_structrp png_ptr, png_voidp ptr)
|
||||
png_ptr->free_fn(png_constcast(png_structrp,png_ptr), ptr);
|
||||
|
||||
else
|
||||
png_free_default(png_ptr, ptr);
|
||||
}
|
||||
|
||||
PNG_FUNCTION(void,PNGAPI
|
||||
png_free_default,(png_const_structrp png_ptr, png_voidp ptr),PNG_DEPRECATED)
|
||||
{
|
||||
if (png_ptr == NULL || ptr == NULL)
|
||||
return;
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
free(ptr);
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
||||
391
pngpriv.h
391
pngpriv.h
@@ -2,11 +2,11 @@
|
||||
/* pngpriv.h - private declarations for use inside libpng
|
||||
*
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -39,9 +39,18 @@
|
||||
*/
|
||||
#define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */
|
||||
|
||||
#ifndef PNG_VERSION_INFO_ONLY
|
||||
/* Keep standard libraries at the top of this file */
|
||||
|
||||
/* Standard library headers not required by png.h: */
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
|
||||
/* For headers only required with some build configurations see the lines after
|
||||
* pnglibconf.h is included!
|
||||
*/
|
||||
|
||||
#endif /* VERSION_INFO_ONLY */
|
||||
|
||||
#define PNGLIB_BUILD /*libpng is being built, not used*/
|
||||
|
||||
@@ -54,7 +63,7 @@
|
||||
* configure generated config.h. Libpng is expected to compile without *any*
|
||||
* special build system support on a reasonably ANSI-C compliant system.
|
||||
*/
|
||||
#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H)
|
||||
#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
|
||||
# include <config.h>
|
||||
|
||||
/* Pick up the definition of 'restrict' from config.h if it was read: */
|
||||
@@ -71,7 +80,7 @@
|
||||
#endif
|
||||
|
||||
/* Local renames may change non-exported API functions from png.h */
|
||||
#if defined PNG_PREFIX && !defined PNGPREFIX_H
|
||||
#if defined(PNG_PREFIX) && !defined(PNGPREFIX_H)
|
||||
# include "pngprefix.h"
|
||||
#endif
|
||||
|
||||
@@ -86,6 +95,76 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef PNG_VERSION_INFO_ONLY
|
||||
/* Additional standard libaries required in certain cases, put only standard
|
||||
* ANSI-C89 headers here. If not available, or non-functional, the problem
|
||||
* should be fixed by writing a wrapper for the header and the file on your
|
||||
* include path.
|
||||
*/
|
||||
#if defined(PNG_sCAL_SUPPORTED) && defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
/* png.c requires the following ANSI-C constants if the conversion of
|
||||
* floating point to ASCII is implemented therein:
|
||||
*
|
||||
* DBL_MIN_10_EXP Minimum negative integer such that 10^integer is a
|
||||
* normalized (double) value.
|
||||
* DBL_DIG Maximum number of decimal digits (can be set to any constant)
|
||||
* DBL_MIN Smallest normalized fp number (can be set to an arbitrary value)
|
||||
* DBL_MAX Maximum floating point number (can be set to an arbitrary value)
|
||||
*/
|
||||
# include <float.h>
|
||||
#endif /* sCAL && FLOATING_POINT */
|
||||
|
||||
#if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) ||\
|
||||
defined(PNG_FLOATING_POINT_SUPPORTED)
|
||||
/* ANSI-C90 math functions are required. Full compliance with the standard
|
||||
* is probably not a requirement, but the functions must exist and be
|
||||
* declared in <math.h>
|
||||
*/
|
||||
# include <math.h>
|
||||
#endif /* FLOATING_ARITHMETIC || FLOATING_POINT */
|
||||
|
||||
#endif /* VERSION_INFO_ONLY */
|
||||
|
||||
/* Compile time options.
|
||||
* =====================
|
||||
* In a multi-arch build the compiler may compile the code several times for the
|
||||
* same object module, producing different binaries for different architectures.
|
||||
* When this happens configure-time setting of the target host options cannot be
|
||||
* done and this interferes with the handling of the ARM NEON optimizations, and
|
||||
* possibly other similar optimizations. Put additional tests here; in general
|
||||
* this is needed when the same option can be changed at both compile time and
|
||||
* run time depending on the target OS (i.e. iOS vs Android.)
|
||||
*
|
||||
* NOTE: symbol prefixing does not pass $(CFLAGS) to the preprocessor, because
|
||||
* this is not possible with certain compilers (Oracle SUN OS CC), as a result
|
||||
* it is necessary to ensure that all extern functions that *might* be used
|
||||
* regardless of $(CFLAGS) get declared in this file. The test on __ARM_NEON__
|
||||
* below is one example of this behavior because it is controlled by the
|
||||
* presence or not of -mfpu=neon on the GCC command line, it is possible to do
|
||||
* this in $(CC), e.g. "CC=gcc -mfpu=neon", but people who build libpng rarely
|
||||
* do this.
|
||||
*/
|
||||
#ifndef PNG_ARM_NEON_OPT
|
||||
/* ARM NEON optimizations are being controlled by the compiler settings,
|
||||
* typically the target FPU. If the FPU has been set to NEON (-mfpu=neon
|
||||
* with GCC) then the compiler will define __ARM_NEON__ and we can rely
|
||||
* unconditionally on NEON instructions not crashing, otherwise we must
|
||||
* disable use of NEON instructions:
|
||||
*/
|
||||
# ifdef __ARM_NEON__
|
||||
# define PNG_ARM_NEON_OPT 2
|
||||
# else
|
||||
# define PNG_ARM_NEON_OPT 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if PNG_ARM_NEON_OPT > 0
|
||||
/* NEON optimizations are to be at least considered by libpng, so enable the
|
||||
* callbacks to do this.
|
||||
*/
|
||||
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_neon
|
||||
#endif
|
||||
|
||||
/* Is this a build of a DLL where compilation of the object modules requires
|
||||
* different preprocessor settings to those required for a simple library? If
|
||||
* so PNG_BUILD_DLL must be set.
|
||||
@@ -177,10 +256,12 @@
|
||||
# ifndef PNG_FLOATING_POINT_SUPPORTED
|
||||
# define PNG_FP_EXPORT(ordinal, type, name, args)\
|
||||
PNG_INTERNAL_FUNCTION(type, name, args, PNG_EMPTY);
|
||||
typedef struct png_incomplete png_double;
|
||||
typedef png_double* png_doublep;
|
||||
typedef const png_double* png_const_doublep;
|
||||
typedef png_double** png_doublepp;
|
||||
# ifndef PNG_VERSION_INFO_ONLY
|
||||
typedef struct png_incomplete png_double;
|
||||
typedef png_double* png_doublep;
|
||||
typedef const png_double* png_const_doublep;
|
||||
typedef png_double** png_doublepp;
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#ifndef PNG_FIXED_EXPORT
|
||||
@@ -190,15 +271,27 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Include png.h here to get the version info and other macros, pngstruct.h and
|
||||
* pnginfo.h are included later under the protection of !PNG_VERSION_INFO_ONLY
|
||||
*/
|
||||
#include "png.h"
|
||||
#include "pngstruct.h"
|
||||
#include "pnginfo.h"
|
||||
|
||||
/* pngconf.h does not set PNG_DLL_EXPORT unless it is required, so: */
|
||||
#ifndef PNG_DLL_EXPORT
|
||||
# define PNG_DLL_EXPORT
|
||||
#endif
|
||||
|
||||
/* asserts are turned off in release code, but are in even in release candidates
|
||||
* because often system builders only check future libpng releases when a
|
||||
* release candidate is available.
|
||||
*/
|
||||
#if PNG_LIBPNG_BUILD_BASE_TYPE == PNG_LIBPNG_BUILD_STABLE
|
||||
# define NDEBUG
|
||||
#endif
|
||||
#ifndef PNG_VERSION_INFO_ONLY
|
||||
# include <assert.h>
|
||||
#endif
|
||||
|
||||
/* SECURITY and SAFETY:
|
||||
*
|
||||
* By default libpng is built without any internal limits on image size,
|
||||
@@ -238,11 +331,6 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* This is used for 16 bit gamma tables -- only the top level pointers are
|
||||
* const; this could be changed:
|
||||
*/
|
||||
typedef const png_uint_16p * png_const_uint_16pp;
|
||||
|
||||
/* Moved to pngpriv.h at libpng-1.5.0 */
|
||||
/* NOTE: some of these may have been used in external applications as
|
||||
* these definitions were exposed in pngconf.h prior to 1.5.
|
||||
@@ -331,65 +419,6 @@ typedef const png_uint_16p * png_const_uint_16pp;
|
||||
# define PNGFAPI /* PRIVATE */
|
||||
#endif
|
||||
|
||||
/* Other defines specific to compilers can go here. Try to keep
|
||||
* them inside an appropriate ifdef/endif pair for portability.
|
||||
*/
|
||||
#if defined(PNG_FLOATING_POINT_SUPPORTED) ||\
|
||||
defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)
|
||||
/* png.c requires the following ANSI-C constants if the conversion of
|
||||
* floating point to ASCII is implemented therein:
|
||||
*
|
||||
* DBL_DIG Maximum number of decimal digits (can be set to any constant)
|
||||
* DBL_MIN Smallest normalized fp number (can be set to an arbitrary value)
|
||||
* DBL_MAX Maximum floating point number (can be set to an arbitrary value)
|
||||
*/
|
||||
# include <float.h>
|
||||
|
||||
# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
|
||||
defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
|
||||
/* We need to check that <math.h> hasn't already been included earlier
|
||||
* as it seems it doesn't agree with <fp.h>, yet we should really use
|
||||
* <fp.h> if possible.
|
||||
*/
|
||||
# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)
|
||||
# include <fp.h>
|
||||
# endif
|
||||
# else
|
||||
# include <math.h>
|
||||
# endif
|
||||
# if defined(_AMIGA) && defined(__SASC) && defined(_M68881)
|
||||
/* Amiga SAS/C: We must include builtin FPU functions when compiling using
|
||||
* MATH=68881
|
||||
*/
|
||||
# include <m68881.h>
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* This provides the non-ANSI (far) memory allocation routines. */
|
||||
#if defined(__TURBOC__) && defined(__MSDOS__)
|
||||
# include <mem.h>
|
||||
# include <alloc.h>
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \
|
||||
defined(_WIN32) || defined(__WIN32__)
|
||||
# include <windows.h> /* defines _WINDOWS_ macro */
|
||||
#endif
|
||||
|
||||
/* Moved here around 1.5.0beta36 from pngconf.h */
|
||||
/* Users may want to use these so they are not private. Any library
|
||||
* functions that are passed far data must be model-independent.
|
||||
*/
|
||||
|
||||
/* Memory model/platform independent fns */
|
||||
#ifndef PNG_ABORT
|
||||
# ifdef _WINDOWS_
|
||||
# define PNG_ABORT() ExitProcess(0)
|
||||
# else
|
||||
# define PNG_ABORT() abort()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* These macros may need to be architecture dependent. */
|
||||
#define PNG_ALIGN_NONE 0 /* do not use data alignment */
|
||||
#define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */
|
||||
@@ -411,7 +440,7 @@ typedef const png_uint_16p * png_const_uint_16pp;
|
||||
#if PNG_ALIGN_TYPE == PNG_ALIGN_SIZE
|
||||
/* This is used because in some compiler implementations non-aligned
|
||||
* structure members are supported, so the offsetof approach below fails.
|
||||
* Set PNG_ALIGN_TO_SIZE=0 for compiler combinations where unaligned access
|
||||
* Set PNG_ALIGN_SIZE=0 for compiler combinations where unaligned access
|
||||
* is good for performance. Do not do this unless you have tested the result
|
||||
* and understand it.
|
||||
*/
|
||||
@@ -458,7 +487,7 @@ typedef const png_uint_16p * png_const_uint_16pp;
|
||||
#define PNG_HAVE_CHUNK_HEADER 0x100
|
||||
#define PNG_WROTE_tIME 0x200
|
||||
#define PNG_WROTE_INFO_BEFORE_PLTE 0x400
|
||||
#define PNG_BACKGROUND_IS_GRAY 0x800
|
||||
/* 0x800 (unused) */
|
||||
#define PNG_HAVE_PNG_SIGNATURE 0x1000
|
||||
#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */
|
||||
/* 0x4000 (unused) */
|
||||
@@ -472,10 +501,10 @@ typedef const png_uint_16p * png_const_uint_16pp;
|
||||
#define PNG_SWAP_BYTES 0x0010
|
||||
#define PNG_INVERT_MONO 0x0020
|
||||
#define PNG_QUANTIZE 0x0040
|
||||
#define PNG_COMPOSE 0x0080 /* Was PNG_BACKGROUND */
|
||||
#define PNG_BACKGROUND_EXPAND 0x0100
|
||||
#define PNG_EXPAND_16 0x0200 /* Added to libpng 1.5.2 */
|
||||
#define PNG_16_TO_8 0x0400 /* Becomes 'chop' in 1.5.4 */
|
||||
#define PNG_COMPOSE 0x0080 /* Was PNG_BACKGROUND */
|
||||
/* 0x0100 unused */
|
||||
#define PNG_EXPAND_16 0x0200 /* Added to libpng 1.5.2 */
|
||||
#define PNG_16_TO_8 0x0400 /* Becomes 'chop' in 1.5.4 */
|
||||
#define PNG_RGBA 0x0800
|
||||
#define PNG_EXPAND 0x1000
|
||||
#define PNG_GAMMA 0x2000
|
||||
@@ -490,13 +519,13 @@ typedef const png_uint_16p * png_const_uint_16pp;
|
||||
#define PNG_RGB_TO_GRAY_WARN 0x400000
|
||||
#define PNG_RGB_TO_GRAY 0x600000 /* two bits, RGB_TO_GRAY_ERR|WARN */
|
||||
#define PNG_ENCODE_ALPHA 0x800000 /* Added to libpng-1.5.4 */
|
||||
#define PNG_ADD_ALPHA 0x1000000 /* Added to libpng-1.2.7 */
|
||||
#define PNG_EXPAND_tRNS 0x2000000 /* Added to libpng-1.2.9 */
|
||||
#define PNG_SCALE_16_TO_8 0x4000000 /* Added to libpng-1.5.4 */
|
||||
/* 0x8000000 unused */
|
||||
/* 0x10000000 unused */
|
||||
/* 0x20000000 unused */
|
||||
/* 0x40000000 unused */
|
||||
#define PNG_ADD_ALPHA 0x1000000 /* Added to libpng-1.2.7 */
|
||||
#define PNG_EXPAND_tRNS 0x2000000 /* Added to libpng-1.2.9 */
|
||||
#define PNG_SCALE_16_TO_8 0x4000000 /* Added to libpng-1.5.4 */
|
||||
/* 0x8000000 unused */
|
||||
/* 0x10000000 unused */
|
||||
/* 0x20000000 unused */
|
||||
/* 0x40000000 unused */
|
||||
/* Flags for png_create_struct */
|
||||
#define PNG_STRUCT_PNG 0x0001
|
||||
#define PNG_STRUCT_INFO 0x0002
|
||||
@@ -529,8 +558,8 @@ typedef const png_uint_16p * png_const_uint_16pp;
|
||||
#define PNG_FLAG_BENIGN_ERRORS_WARN 0x100000 /* Added to libpng-1.4.0 */
|
||||
#define PNG_FLAG_APP_WARNINGS_WARN 0x200000 /* Added to libpng-1.6.0 */
|
||||
#define PNG_FLAG_APP_ERRORS_WARN 0x400000 /* Added to libpng-1.6.0 */
|
||||
/* 0x800000 unused */
|
||||
/* 0x1000000 unused */
|
||||
#define PNG_FLAG_BACKGROUND_IS_GRAY 0x800000
|
||||
#define PNG_FLAG_BACKGROUND_EXPAND 0x1000000
|
||||
/* 0x2000000 unused */
|
||||
/* 0x4000000 unused */
|
||||
/* 0x8000000 unused */
|
||||
@@ -553,19 +582,9 @@ typedef const png_uint_16p * png_const_uint_16pp;
|
||||
abs((int)((c1).green) - (int)((c2).green)) + \
|
||||
abs((int)((c1).blue) - (int)((c2).blue)))
|
||||
|
||||
/* Added to libpng-1.5.7: sRGB conversion tables */
|
||||
#if defined PNG_SIMPLIFIED_READ_SUPPORTED ||\
|
||||
defined PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||
#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
|
||||
PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_table, [256]);
|
||||
/* Convert from an sRGB encoded value 0..255 to a 16-bit linear value,
|
||||
* 0..65535. This table gives the closest 16-bit answers (no errors).
|
||||
*/
|
||||
#endif
|
||||
|
||||
PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_base, [512]);
|
||||
PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]);
|
||||
|
||||
#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\
|
||||
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
|
||||
/* See below for the definitions of the tables used in these macros */
|
||||
#define PNG_sRGB_FROM_LINEAR(linear) ((png_byte)((png_sRGB_base[(linear)>>15] +\
|
||||
((((linear)&0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8))
|
||||
/* Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB
|
||||
@@ -637,76 +656,56 @@ PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]);
|
||||
*/
|
||||
#endif
|
||||
|
||||
/* Constants for known chunk types. If you need to add a chunk, define the name
|
||||
* here. For historical reasons these constants have the form png_<name>; i.e.
|
||||
* the prefix is lower case. Please use decimal values as the parameters to
|
||||
* match the ISO PNG specification and to avoid relying on the C locale
|
||||
* interpretation of character values.
|
||||
*
|
||||
* Prior to 1.5.6 these constants were strings, as of 1.5.6 png_uint_32 values
|
||||
* are computed and a new macro (PNG_STRING_FROM_CHUNK) added to allow a string
|
||||
* to be generated if required.
|
||||
*
|
||||
* PNG_32b correctly produces a value shifted by up to 24 bits, even on
|
||||
* architectures where (int) is only 16 bits.
|
||||
*/
|
||||
#define PNG_32b(b,s) ((png_uint_32)(b) << (s))
|
||||
#define PNG_CHUNK(b1,b2,b3,b4) \
|
||||
(PNG_32b(b1,24) | PNG_32b(b2,16) | PNG_32b(b3,8) | PNG_32b(b4,0))
|
||||
|
||||
#define png_IHDR PNG_CHUNK( 73, 72, 68, 82)
|
||||
#define png_IDAT PNG_CHUNK( 73, 68, 65, 84)
|
||||
#define png_IEND PNG_CHUNK( 73, 69, 78, 68)
|
||||
#define png_PLTE PNG_CHUNK( 80, 76, 84, 69)
|
||||
#define png_bKGD PNG_CHUNK( 98, 75, 71, 68)
|
||||
#define png_cHRM PNG_CHUNK( 99, 72, 82, 77)
|
||||
#define png_gAMA PNG_CHUNK(103, 65, 77, 65)
|
||||
#define png_hIST PNG_CHUNK(104, 73, 83, 84)
|
||||
#define png_iCCP PNG_CHUNK(105, 67, 67, 80)
|
||||
#define png_iTXt PNG_CHUNK(105, 84, 88, 116)
|
||||
#define png_oFFs PNG_CHUNK(111, 70, 70, 115)
|
||||
#define png_pCAL PNG_CHUNK(112, 67, 65, 76)
|
||||
#define png_sCAL PNG_CHUNK(115, 67, 65, 76)
|
||||
#define png_pHYs PNG_CHUNK(112, 72, 89, 115)
|
||||
#define png_sBIT PNG_CHUNK(115, 66, 73, 84)
|
||||
#define png_sPLT PNG_CHUNK(115, 80, 76, 84)
|
||||
#define png_sRGB PNG_CHUNK(115, 82, 71, 66)
|
||||
#define png_sTER PNG_CHUNK(115, 84, 69, 82)
|
||||
#define png_tEXt PNG_CHUNK(116, 69, 88, 116)
|
||||
#define png_tIME PNG_CHUNK(116, 73, 77, 69)
|
||||
#define png_tRNS PNG_CHUNK(116, 82, 78, 83)
|
||||
#define png_zTXt PNG_CHUNK(122, 84, 88, 116)
|
||||
|
||||
/* The following will work on (signed char*) strings, whereas the get_uint_32
|
||||
* macro will fail on top-bit-set values because of the sign extension.
|
||||
*/
|
||||
#define PNG_CHUNK_FROM_STRING(s)\
|
||||
PNG_CHUNK(0xff&(s)[0], 0xff&(s)[1], 0xff&(s)[2], 0xff&(s)[3])
|
||||
|
||||
/* This uses (char), not (png_byte) to avoid warnings on systems where (char) is
|
||||
* signed and the argument is a (char[]) This macro will fail miserably on
|
||||
* systems where (char) is more than 8 bits.
|
||||
*/
|
||||
#define PNG_STRING_FROM_CHUNK(s,c)\
|
||||
(void)(((char*)(s))[0]=(char)((c)>>24), ((char*)(s))[1]=(char)((c)>>16),\
|
||||
((char*)(s))[2]=(char)((c)>>8), ((char*)(s))[3]=(char)((c)))
|
||||
|
||||
/* Do the same but terminate with a null character. */
|
||||
#define PNG_CSTRING_FROM_CHUNK(s,c)\
|
||||
(void)(PNG_STRING_FROM_CHUNK(s,c), ((char*)(s))[4] = 0)
|
||||
|
||||
/* Test on flag values as defined in the spec (section 5.4): */
|
||||
#define PNG_CHUNK_ANCILLIARY(c) (1 & ((c) >> 29))
|
||||
#define PNG_CHUNK_CRITICAL(c) (!PNG_CHUNK_ANCILLIARY(c))
|
||||
#define PNG_CHUNK_PRIVATE(c) (1 & ((c) >> 21))
|
||||
#define PNG_CHUNK_RESERVED(c) (1 & ((c) >> 13))
|
||||
#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >> 5))
|
||||
|
||||
/* Gamma values (new at libpng-1.5.4): */
|
||||
#define PNG_GAMMA_MAC_OLD 151724 /* Assume '1.8' is really 2.2/1.45! */
|
||||
#define PNG_GAMMA_MAC_INVERSE 65909
|
||||
#define PNG_GAMMA_sRGB_INVERSE 45455
|
||||
|
||||
/* Almost everything below is C specific; the #defines above can be used in
|
||||
* non-C code (so long as it is C-preprocessed) the rest of this stuff cannot.
|
||||
*/
|
||||
#ifndef PNG_VERSION_INFO_ONLY
|
||||
|
||||
#include "pngstruct.h"
|
||||
#include "pnginfo.h"
|
||||
|
||||
/* Validate the include paths - the include path used to generate pnglibconf.h
|
||||
* must match that used in the build, or we must be using pnglibconf.h.prebuilt:
|
||||
*/
|
||||
#if PNG_ZLIB_VERNUM != 0 && PNG_ZLIB_VERNUM != ZLIB_VERNUM
|
||||
# error ZLIB_VERNUM != PNG_ZLIB_VERNUM \
|
||||
"-I (include path) error: see the notes in pngpriv.h"
|
||||
/* This means that when pnglibconf.h was built the copy of zlib.h that it
|
||||
* used is not the same as the one being used here. Because the build of
|
||||
* libpng makes decisions to use inflateInit2 and inflateReset2 based on the
|
||||
* zlib version number and because this affects handling of certain broken
|
||||
* PNG files the -I directives must match.
|
||||
*
|
||||
* The most likely explanation is that you passed a -I in CFLAGS, this will
|
||||
* not work; all the preprocessor directories and in particular all the -I
|
||||
* directives must be in CPPFLAGS.
|
||||
*/
|
||||
#endif
|
||||
|
||||
/* This is used for 16 bit gamma tables -- only the top level pointers are
|
||||
* const; this could be changed:
|
||||
*/
|
||||
typedef const png_uint_16p * png_const_uint_16pp;
|
||||
|
||||
/* Added to libpng-1.5.7: sRGB conversion tables */
|
||||
#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\
|
||||
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
|
||||
#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
|
||||
PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_table, [256]);
|
||||
/* Convert from an sRGB encoded value 0..255 to a 16-bit linear value,
|
||||
* 0..65535. This table gives the closest 16-bit answers (no errors).
|
||||
*/
|
||||
#endif
|
||||
|
||||
PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_base, [512]);
|
||||
PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]);
|
||||
#endif /* PNG_SIMPLIFIED_READ/WRITE */
|
||||
|
||||
|
||||
/* Inhibit C++ name-mangling for libpng functions but not for system calls. */
|
||||
#ifdef __cplusplus
|
||||
@@ -733,6 +732,16 @@ PNG_INTERNAL_FUNCTION(void,png_free_buffer_list,(png_structrp png_ptr,
|
||||
/* Free the buffer list used by the compressed write code. */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(void,png_write_alloc_filter_row_buffers,
|
||||
(png_structrp png_ptr, int filters),PNG_EMPTY);
|
||||
/* Allocate pixel row buffers to cache filtered rows while testing candidate
|
||||
* filters.
|
||||
* TODO: avoid this, only one spare row buffer (at most) is required, this
|
||||
* wastes a lot of memory for large images.
|
||||
*/
|
||||
#endif
|
||||
|
||||
#if defined(PNG_FLOATING_POINT_SUPPORTED) && \
|
||||
!defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \
|
||||
(defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \
|
||||
@@ -757,6 +766,23 @@ PNG_INTERNAL_FUNCTION(int,png_user_version_check,(png_structrp png_ptr,
|
||||
PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_base,(png_const_structrp png_ptr,
|
||||
png_alloc_size_t size),PNG_ALLOCATED);
|
||||
|
||||
#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\
|
||||
defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
/* Internal array allocator, outputs no error or warning messages on failure,
|
||||
* just returns NULL.
|
||||
*/
|
||||
PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_array,(png_const_structrp png_ptr,
|
||||
int nelements, size_t element_size),PNG_ALLOCATED);
|
||||
|
||||
/* The same but an existing array is extended by add_elements. This function
|
||||
* also memsets the new elements to 0 and copies the old elements. The old
|
||||
* array is not freed or altered.
|
||||
*/
|
||||
PNG_INTERNAL_FUNCTION(png_voidp,png_realloc_array,(png_structrp png_ptr,
|
||||
png_const_voidp array, int old_elements, int add_elements,
|
||||
size_t element_size),PNG_ALLOCATED);
|
||||
#endif /* text, sPLT or unknown chunks */
|
||||
|
||||
/* Magic to create a struct when there is no struct to call the user supplied
|
||||
* memory allocators. Because error handling has not been set up the memory
|
||||
* handlers can't safely call png_error, but this is an obscure and undocumented
|
||||
@@ -933,7 +959,7 @@ PNG_INTERNAL_FUNCTION(void,png_write_iTXt,(png_structrp png_ptr,
|
||||
#endif
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED /* Added at version 1.0.14 and 1.2.4 */
|
||||
PNG_INTERNAL_FUNCTION(int,png_set_text_2,(png_const_structrp png_ptr,
|
||||
PNG_INTERNAL_FUNCTION(int,png_set_text_2,(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_const_textp text_ptr, int num_text),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
@@ -1802,13 +1828,13 @@ PNG_INTERNAL_FUNCTION(png_byte,png_gamma_8bit_correct,(unsigned int value,
|
||||
png_fixed_point gamma_value),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_destroy_gamma_table,(png_structrp png_ptr),
|
||||
PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_build_gamma_table,(png_structrp png_ptr,
|
||||
PNG_INTERNAL_FUNCTION(void,png_build_gamma_tables,(png_structrp png_ptr,
|
||||
int bit_depth),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
/* SIMPLIFIED READ/WRITE SUPPORT */
|
||||
#if defined PNG_SIMPLIFIED_READ_SUPPORTED ||\
|
||||
defined PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||
#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\
|
||||
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
|
||||
/* The internal structure that png_image::opaque points to. */
|
||||
typedef struct png_control
|
||||
{
|
||||
@@ -1862,6 +1888,24 @@ PNG_INTERNAL_FUNCTION(void, png_image_free, (png_imagep image), PNG_EMPTY);
|
||||
|
||||
#endif /* SIMPLIFIED READ/WRITE */
|
||||
|
||||
/* These are initialization functions for hardware specific PNG filter
|
||||
* optimizations; list these here then select the appropriate one at compile
|
||||
* time using the macro PNG_FILTER_OPTIMIZATIONS. If the macro is not defined
|
||||
* the generic code is used.
|
||||
*/
|
||||
#ifdef PNG_FILTER_OPTIMIZATIONS
|
||||
PNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structrp png_ptr,
|
||||
unsigned int bpp), PNG_EMPTY);
|
||||
/* Just declare the optimization that will be used */
|
||||
#else
|
||||
/* List *all* the possible optimizations here - this branch is required if
|
||||
* the builder of libpng passes the definition of PNG_FILTER_OPTIMIZATIONS in
|
||||
* CFLAGS in place of CPPFLAGS *and* uses symbol prefixing.
|
||||
*/
|
||||
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon,
|
||||
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
/* Maintainer: Put new private prototypes here ^ */
|
||||
|
||||
#include "pngdebug.h"
|
||||
@@ -1870,4 +1914,5 @@ PNG_INTERNAL_FUNCTION(void, png_image_free, (png_imagep image), PNG_EMPTY);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* PNG_VERSION_INFO_ONLY */
|
||||
#endif /* PNGPRIV_H */
|
||||
|
||||
35
pngread.c
35
pngread.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -15,7 +15,7 @@
|
||||
*/
|
||||
|
||||
#include "pngpriv.h"
|
||||
#if defined PNG_SIMPLIFIED_READ_SUPPORTED && defined PNG_STDIO_SUPPORTED
|
||||
#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) && defined(PNG_STDIO_SUPPORTED)
|
||||
# include <errno.h>
|
||||
#endif
|
||||
|
||||
@@ -877,8 +877,8 @@ png_read_destroy(png_structrp png_ptr)
|
||||
png_free(png_ptr, png_ptr->save_buffer);
|
||||
#endif
|
||||
|
||||
#if (defined PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) &&\
|
||||
(defined PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
#if defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) && \
|
||||
defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
|
||||
png_free(png_ptr, png_ptr->unknown_chunk.data);
|
||||
#endif
|
||||
|
||||
@@ -2004,6 +2004,28 @@ png_image_read_colormap(png_voidp argument)
|
||||
else
|
||||
back_b = back_r = back_g = 255;
|
||||
|
||||
/* Default the input file gamma if required - this is necessary because
|
||||
* libpng assumes that if no gamma information is present the data is in the
|
||||
* output format, but the simplified API deduces the gamma from the input
|
||||
* format.
|
||||
*/
|
||||
if ((png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) == 0)
|
||||
{
|
||||
/* Do this directly, not using the png_colorspace functions, to ensure
|
||||
* that it happens even if the colorspace is invalid (though probably if
|
||||
* it is the setting will be ignored) Note that the same thing can be
|
||||
* achieved at the application interface with png_set_gAMA.
|
||||
*/
|
||||
if (png_ptr->bit_depth == 16 &&
|
||||
(image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0)
|
||||
png_ptr->colorspace.gamma = PNG_GAMMA_LINEAR;
|
||||
|
||||
else
|
||||
png_ptr->colorspace.gamma = PNG_GAMMA_sRGB_INVERSE;
|
||||
|
||||
png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
|
||||
}
|
||||
|
||||
/* Decide what to do based on the PNG color type of the input data. The
|
||||
* utility function png_create_colormap_entry deals with most aspects of the
|
||||
* output transformations; this code works out how to produce bytes of
|
||||
@@ -3547,7 +3569,8 @@ png_image_read_direct(png_voidp argument)
|
||||
{
|
||||
png_fixed_point input_gamma_default;
|
||||
|
||||
if (base_format & PNG_FORMAT_FLAG_LINEAR)
|
||||
if ((base_format & PNG_FORMAT_FLAG_LINEAR) &&
|
||||
(image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0)
|
||||
input_gamma_default = PNG_GAMMA_LINEAR;
|
||||
else
|
||||
input_gamma_default = PNG_DEFAULT_sRGB;
|
||||
|
||||
6
pngrio.c
6
pngrio.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -102,6 +102,7 @@ png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr,
|
||||
png_ptr->read_data_fn = read_data_fn;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
/* It is an error to write to a read device */
|
||||
if (png_ptr->write_data_fn != NULL)
|
||||
{
|
||||
@@ -110,6 +111,7 @@ png_set_read_fn(png_structrp png_ptr, png_voidp io_ptr,
|
||||
"Can't set both read_data_fn and write_data_fn in the"
|
||||
" same structure");
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
png_ptr->output_flush_fn = NULL;
|
||||
|
||||
1146
pngrtran.c
1146
pngrtran.c
File diff suppressed because it is too large
Load Diff
286
pngrutil.c
286
pngrutil.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngrutil.c - utilities to read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -18,19 +18,6 @@
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
|
||||
#define png_strtod(p,a,b) strtod(a,b)
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_uint_31(png_const_structrp png_ptr, png_const_bytep buf)
|
||||
{
|
||||
png_uint_32 uval = png_get_uint_32(buf);
|
||||
|
||||
if (uval > PNG_UINT_31_MAX)
|
||||
png_error(png_ptr, "PNG unsigned integer out of range");
|
||||
|
||||
return (uval);
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_READ_cHRM_SUPPORTED)
|
||||
/* The following is a variation on the above for use with the fixed
|
||||
* point values used for gAMA and cHRM. Instead of png_error it
|
||||
@@ -53,7 +40,7 @@ png_get_fixed_point(png_structrp png_ptr, png_const_bytep buf)
|
||||
|
||||
return PNG_FIXED_ERROR;
|
||||
}
|
||||
#endif
|
||||
#endif /* READ_gAMA or READ_cHRM */
|
||||
|
||||
#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
|
||||
/* NOTE: the read macros will obscure these definitions, so that if
|
||||
@@ -69,49 +56,39 @@ png_get_fixed_point(png_structrp png_ptr, png_const_bytep buf)
|
||||
png_uint_32 (PNGAPI
|
||||
png_get_uint_32)(png_const_bytep buf)
|
||||
{
|
||||
png_uint_32 uval =
|
||||
((png_uint_32)(*(buf )) << 24) +
|
||||
((png_uint_32)(*(buf + 1)) << 16) +
|
||||
((png_uint_32)(*(buf + 2)) << 8) +
|
||||
((png_uint_32)(*(buf + 3)) ) ;
|
||||
|
||||
return uval;
|
||||
return PNG_U32(buf[0], buf[1], buf[2], buf[3]);
|
||||
}
|
||||
|
||||
/* Grab a signed 32-bit integer from a buffer in big-endian format. The
|
||||
* data is stored in the PNG file in two's complement format and there
|
||||
* is no guarantee that a 'png_int_32' is exactly 32 bits, therefore
|
||||
* the following code does a two's complement to native conversion.
|
||||
*/
|
||||
/* Grab a signed 32-bit integer from a buffer in big-endian format. */
|
||||
png_int_32 (PNGAPI
|
||||
png_get_int_32)(png_const_bytep buf)
|
||||
{
|
||||
png_uint_32 uval = png_get_uint_32(buf);
|
||||
if ((uval & 0x80000000) == 0) /* non-negative */
|
||||
return uval;
|
||||
|
||||
uval = (uval ^ 0xffffffff) + 1; /* 2's complement: -x = ~x+1 */
|
||||
return -(png_int_32)uval;
|
||||
return PNG_S32(buf[0], buf[1], buf[2], buf[3]);
|
||||
}
|
||||
|
||||
/* Grab an unsigned 16-bit integer from a buffer in big-endian format. */
|
||||
png_uint_16 (PNGAPI
|
||||
png_get_uint_16)(png_const_bytep buf)
|
||||
{
|
||||
/* ANSI-C requires an int value to accomodate at least 16 bits so this
|
||||
* works and allows the compiler not to worry about possible narrowing
|
||||
* on 32 bit systems. (Pre-ANSI systems did not make integers smaller
|
||||
* than 16 bits either.)
|
||||
*/
|
||||
unsigned int val =
|
||||
((unsigned int)(*buf) << 8) +
|
||||
((unsigned int)(*(buf + 1)));
|
||||
|
||||
return (png_uint_16)val;
|
||||
return PNG_U16(buf[0], buf[1]);
|
||||
}
|
||||
|
||||
#endif /* PNG_READ_INT_FUNCTIONS_SUPPORTED */
|
||||
|
||||
/* This is an exported function however its error handling is too harsh for most
|
||||
* internal use. For example if it were used for reading the chunk parameters
|
||||
* it would error out even on ancillary chunks that can be ignored.
|
||||
*/
|
||||
png_uint_32 PNGAPI
|
||||
png_get_uint_31(png_const_structrp png_ptr, png_const_bytep buf)
|
||||
{
|
||||
png_uint_32 uval = png_get_uint_32(buf);
|
||||
|
||||
if (uval > PNG_UINT_31_MAX)
|
||||
png_error(png_ptr, "PNG unsigned integer out of range");
|
||||
|
||||
return uval;
|
||||
}
|
||||
|
||||
/* Read and check the PNG file signature */
|
||||
void /* PRIVATE */
|
||||
png_read_sig(png_structrp png_ptr, png_inforp info_ptr)
|
||||
@@ -221,7 +198,7 @@ png_crc_finish(png_structrp png_ptr, png_uint_32 skip)
|
||||
|
||||
if (png_crc_error(png_ptr))
|
||||
{
|
||||
if (PNG_CHUNK_ANCILLIARY(png_ptr->chunk_name) ?
|
||||
if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) ?
|
||||
!(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) :
|
||||
(png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE))
|
||||
{
|
||||
@@ -250,7 +227,7 @@ png_crc_error(png_structrp png_ptr)
|
||||
png_uint_32 crc;
|
||||
int need_crc = 1;
|
||||
|
||||
if (PNG_CHUNK_ANCILLIARY(png_ptr->chunk_name))
|
||||
if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name))
|
||||
{
|
||||
if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) ==
|
||||
(PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))
|
||||
@@ -334,7 +311,7 @@ png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn)
|
||||
* chunk apparently owns the stream. Prior to release it does a png_error.
|
||||
*/
|
||||
static int
|
||||
png_inflate_claim(png_structrp png_ptr, png_uint_32 owner, int window_bits)
|
||||
png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
|
||||
{
|
||||
if (png_ptr->zowner != 0)
|
||||
{
|
||||
@@ -358,8 +335,8 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner, int window_bits)
|
||||
* does not take the size of the data as an argument. Some efficiency could
|
||||
* be gained by using this when it is known *if* the zlib stream itself does
|
||||
* not record the number; however, this is an illusion: the original writer
|
||||
* follow of the PNG may have selected a lower window size, and we really
|
||||
* must do that because, for systems with with limited capabilities, we
|
||||
* of the PNG may have selected a lower window size, and we really must
|
||||
* follow that because, for systems with with limited capabilities, we
|
||||
* would otherwise reject the application's attempts to use a smaller window
|
||||
* size (zlib doesn't have an interface to say "this or lower"!).
|
||||
*
|
||||
@@ -369,6 +346,22 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner, int window_bits)
|
||||
*/
|
||||
{
|
||||
int ret; /* zlib return code */
|
||||
# if PNG_ZLIB_VERNUM >= 0x1240
|
||||
|
||||
# if defined(PNG_SET_OPTION_SUPPORTED) && \
|
||||
defined(PNG_MAXIMUM_INFLATE_WINDOW)
|
||||
int window_bits;
|
||||
|
||||
if (((png_ptr->options >> PNG_MAXIMUM_INFLATE_WINDOW) & 3) ==
|
||||
PNG_OPTION_ON)
|
||||
window_bits = 15;
|
||||
|
||||
else
|
||||
window_bits = 0;
|
||||
# else
|
||||
# define window_bits 0
|
||||
# endif
|
||||
# endif
|
||||
|
||||
/* Set this for safety, just in case the previous owner left pointers to
|
||||
* memory allocations.
|
||||
@@ -380,8 +373,7 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner, int window_bits)
|
||||
|
||||
if (png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED)
|
||||
{
|
||||
# if ZLIB_VERNUM < 0x1240
|
||||
PNG_UNUSED(window_bits)
|
||||
# if PNG_ZLIB_VERNUM < 0x1240
|
||||
ret = inflateReset(&png_ptr->zstream);
|
||||
# else
|
||||
ret = inflateReset2(&png_ptr->zstream, window_bits);
|
||||
@@ -390,7 +382,7 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner, int window_bits)
|
||||
|
||||
else
|
||||
{
|
||||
# if ZLIB_VERNUM < 0x1240
|
||||
# if PNG_ZLIB_VERNUM < 0x1240
|
||||
ret = inflateInit(&png_ptr->zstream);
|
||||
# else
|
||||
ret = inflateInit2(&png_ptr->zstream, window_bits);
|
||||
@@ -408,6 +400,10 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner, int window_bits)
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
# ifdef window_bits
|
||||
# undef window_bits
|
||||
# endif
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_COMPRESSED_TEXT_SUPPORTED
|
||||
@@ -562,7 +558,7 @@ png_decompress_chunk(png_structrp png_ptr,
|
||||
*/
|
||||
png_alloc_size_t limit = PNG_SIZE_MAX;
|
||||
|
||||
# ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
|
||||
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
if (png_ptr->user_chunk_malloc_max > 0 &&
|
||||
png_ptr->user_chunk_malloc_max < limit)
|
||||
limit = png_ptr->user_chunk_malloc_max;
|
||||
@@ -580,14 +576,8 @@ png_decompress_chunk(png_structrp png_ptr,
|
||||
if (limit < *newlength)
|
||||
*newlength = limit;
|
||||
|
||||
/* Now try to claim the stream; the 'warn' setting causes zlib to be told
|
||||
* to use the maximum window size during inflate; this hides errors in the
|
||||
* deflate header window bits value which is used if '0' is passed. In
|
||||
* fact this only has an effect with zlib versions 1.2.4 and later - see
|
||||
* the comments in png_inflate_claim above.
|
||||
*/
|
||||
ret = png_inflate_claim(png_ptr, png_ptr->chunk_name,
|
||||
png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN ? 15 : 0);
|
||||
/* Now try to claim the stream. */
|
||||
ret = png_inflate_claim(png_ptr, png_ptr->chunk_name);
|
||||
|
||||
if (ret == Z_OK)
|
||||
{
|
||||
@@ -1357,8 +1347,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
{
|
||||
read_length -= keyword_length+2;
|
||||
|
||||
if (png_inflate_claim(png_ptr, png_iCCP,
|
||||
png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN ? 15 : 0) == Z_OK)
|
||||
if (png_inflate_claim(png_ptr, png_iCCP) == Z_OK)
|
||||
{
|
||||
Byte profile_header[132];
|
||||
Byte local_buffer[PNG_INFLATE_BUF_SIZE];
|
||||
@@ -1582,7 +1571,8 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
|
||||
if (--png_ptr->user_chunk_cache_max == 1)
|
||||
{
|
||||
png_warning(png_ptr, "No space in chunk cache for sPLT");
|
||||
/* Warn the first time */
|
||||
png_chunk_benign_error(png_ptr, "chunk cache full");
|
||||
png_crc_finish(png_ptr, length);
|
||||
return;
|
||||
}
|
||||
@@ -1659,8 +1649,8 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
|
||||
if (dl > max_dl)
|
||||
{
|
||||
png_warning(png_ptr, "sPLT chunk too long");
|
||||
return;
|
||||
png_warning(png_ptr, "sPLT chunk too long");
|
||||
return;
|
||||
}
|
||||
|
||||
new_palette.nentries = (png_int_32)(data_length / entry_size);
|
||||
@@ -1670,8 +1660,8 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
|
||||
if (new_palette.entries == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "sPLT chunk requires too much memory");
|
||||
return;
|
||||
png_warning(png_ptr, "sPLT chunk requires too much memory");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef PNG_POINTER_INDEXING_SUPPORTED
|
||||
@@ -1832,6 +1822,8 @@ png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
*/
|
||||
png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans,
|
||||
&(png_ptr->trans_color));
|
||||
|
||||
png_ptr->trans_alpha = info_ptr->trans_alpha;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -2370,7 +2362,7 @@ png_handle_tEXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
if (--png_ptr->user_chunk_cache_max == 1)
|
||||
{
|
||||
png_crc_finish(png_ptr, length);
|
||||
png_chunk_benign_error(png_ptr, "no space in chunk cache");
|
||||
png_chunk_benign_error(png_ptr, "chunk cache full");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -2449,7 +2441,7 @@ png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
if (--png_ptr->user_chunk_cache_max == 1)
|
||||
{
|
||||
png_crc_finish(png_ptr, length);
|
||||
png_chunk_benign_error(png_ptr, "no space in chunk cache");
|
||||
png_chunk_benign_error(png_ptr, "chunk cache full");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -2558,7 +2550,7 @@ png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
if (--png_ptr->user_chunk_cache_max == 1)
|
||||
{
|
||||
png_crc_finish(png_ptr, length);
|
||||
png_chunk_benign_error(png_ptr, "no space in chunk cache");
|
||||
png_chunk_benign_error(png_ptr, "chunk cache full");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -2698,7 +2690,7 @@ png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length)
|
||||
png_ptr->unknown_chunk.data = NULL;
|
||||
}
|
||||
|
||||
# ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
|
||||
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
if (png_ptr->user_chunk_malloc_max > 0 &&
|
||||
png_ptr->user_chunk_malloc_max < limit)
|
||||
limit = png_ptr->user_chunk_malloc_max;
|
||||
@@ -2800,36 +2792,19 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
if (ret < 0)
|
||||
png_chunk_error(png_ptr, "error in user chunk");
|
||||
|
||||
else if (ret == 0)
|
||||
{
|
||||
/* If the keep value is 'default' or 'never' override it, but
|
||||
* still error out on critical chunks unless the keep value is
|
||||
* 'always' While this is weird it is the behavior in 1.4.12. A
|
||||
* possible improvement would be to obey the value set for the
|
||||
* chunk, but this would be an API change that would probably
|
||||
* damage some applications.
|
||||
*
|
||||
* The png_app_warning below catches the case that matters, where
|
||||
* the application has neither set specific save for this chunk
|
||||
* or global save.
|
||||
*/
|
||||
if (keep < PNG_HANDLE_CHUNK_IF_SAFE)
|
||||
{
|
||||
# ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
if (png_ptr->unknown_default < PNG_HANDLE_CHUNK_IF_SAFE)
|
||||
png_app_warning(png_ptr,
|
||||
"forcing save of an unhandled chunk; please call png_set_keep_unknown_chunks");
|
||||
# endif
|
||||
keep = PNG_HANDLE_CHUNK_IF_SAFE;
|
||||
}
|
||||
}
|
||||
|
||||
else /* chunk was handled */
|
||||
else if (ret > 0) /* chunk was handled */
|
||||
{
|
||||
handled = 1;
|
||||
/* Critical chunks can be safely discarded at this point. */
|
||||
keep = PNG_HANDLE_CHUNK_NEVER;
|
||||
}
|
||||
|
||||
/* else: use the default handling.
|
||||
* NOTE: this is an API change in 1.7.0, prior to 1.7.0 libpng would
|
||||
* force keep to PNG_HANDLE_CHUNK_IF_SAFE at this point, and 1.6.0
|
||||
* would issue a warning if this caused a default of discarding the
|
||||
* chunk to be changed.
|
||||
*/
|
||||
}
|
||||
|
||||
else
|
||||
@@ -2852,7 +2827,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
if (keep == PNG_HANDLE_CHUNK_ALWAYS ||
|
||||
(keep == PNG_HANDLE_CHUNK_IF_SAFE &&
|
||||
PNG_CHUNK_ANCILLIARY(png_ptr->chunk_name)))
|
||||
PNG_CHUNK_ANCILLARY(png_ptr->chunk_name)))
|
||||
{
|
||||
if (!png_cache_unknown_chunk(png_ptr, length))
|
||||
keep = PNG_HANDLE_CHUNK_NEVER;
|
||||
@@ -2886,14 +2861,14 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
*/
|
||||
if (keep == PNG_HANDLE_CHUNK_ALWAYS ||
|
||||
(keep == PNG_HANDLE_CHUNK_IF_SAFE &&
|
||||
PNG_CHUNK_ANCILLIARY(png_ptr->chunk_name)))
|
||||
PNG_CHUNK_ANCILLARY(png_ptr->chunk_name)))
|
||||
{
|
||||
# ifdef PNG_USER_LIMITS_SUPPORTED
|
||||
switch (png_ptr->user_chunk_cache_max)
|
||||
{
|
||||
case 2:
|
||||
png_ptr->user_chunk_cache_max = 1;
|
||||
png_chunk_benign_error(png_ptr, "no space in chunk cache");
|
||||
png_chunk_benign_error(png_ptr, "chunk cache full");
|
||||
/* FALL THROUGH */
|
||||
case 1:
|
||||
/* NOTE: prior to 1.6.0 this case resulted in an unknown critical
|
||||
@@ -3350,7 +3325,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
png_uint_32p dp32 = png_aligncast(png_uint_32p,dp);
|
||||
png_const_uint_32p sp32 = png_aligncastconst(
|
||||
png_const_uint_32p, sp);
|
||||
unsigned int skip = (bytes_to_jump-bytes_to_copy) /
|
||||
size_t skip = (bytes_to_jump-bytes_to_copy) /
|
||||
(sizeof (png_uint_32));
|
||||
|
||||
do
|
||||
@@ -3392,7 +3367,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
png_uint_16p dp16 = png_aligncast(png_uint_16p, dp);
|
||||
png_const_uint_16p sp16 = png_aligncastconst(
|
||||
png_const_uint_16p, sp);
|
||||
unsigned int skip = (bytes_to_jump-bytes_to_copy) /
|
||||
size_t skip = (bytes_to_jump-bytes_to_copy) /
|
||||
(sizeof (png_uint_16));
|
||||
|
||||
do
|
||||
@@ -3863,68 +3838,16 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_ARM_NEON
|
||||
|
||||
#ifdef __linux__
|
||||
#include <stdio.h>
|
||||
#include <elf.h>
|
||||
#include <asm/hwcap.h>
|
||||
|
||||
static int png_have_hwcap(unsigned cap)
|
||||
{
|
||||
FILE *f = fopen("/proc/self/auxv", "r");
|
||||
Elf32_auxv_t aux;
|
||||
int have_cap = 0;
|
||||
|
||||
if (!f)
|
||||
return 0;
|
||||
|
||||
while (fread(&aux, (sizeof aux), 1, f) > 0)
|
||||
{
|
||||
if (aux.a_type == AT_HWCAP &&
|
||||
aux.a_un.a_val & cap)
|
||||
{
|
||||
have_cap = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
|
||||
return have_cap;
|
||||
}
|
||||
#endif /* __linux__ */
|
||||
|
||||
static void
|
||||
png_init_filter_functions_neon(png_structrp pp, unsigned int bpp)
|
||||
{
|
||||
#ifdef __linux__
|
||||
if (!png_have_hwcap(HWCAP_NEON))
|
||||
return;
|
||||
#endif
|
||||
|
||||
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 */
|
||||
|
||||
static void
|
||||
png_init_filter_functions(png_structrp pp)
|
||||
/* This function is called once for every PNG image to set the
|
||||
* implementations required to reverse the filtering of PNG rows. Reversing
|
||||
* the filter is the first transformation performed on the row data. It is
|
||||
* performed in place, therefore an implementation can be selected based on
|
||||
* the image pixel format. If the implementation depends on image width then
|
||||
* take care to ensure that it works correctly if the image is interlaced -
|
||||
* interlacing causes the actual row width to vary.
|
||||
*/
|
||||
{
|
||||
unsigned int bpp = (pp->pixel_depth + 7) >> 3;
|
||||
|
||||
@@ -3938,8 +3861,16 @@ png_init_filter_functions(png_structrp pp)
|
||||
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
|
||||
png_read_filter_row_paeth_multibyte_pixel;
|
||||
|
||||
#ifdef PNG_ARM_NEON
|
||||
png_init_filter_functions_neon(pp, bpp);
|
||||
#ifdef PNG_FILTER_OPTIMIZATIONS
|
||||
/* To use this define PNG_FILTER_OPTIMIZATIONS as the name of a function to
|
||||
* call to install hardware optimizations for the above functions; simply
|
||||
* replace whatever elements of the pp->read_filter[] array with a hardware
|
||||
* specific (or, for that matter, generic) optimization.
|
||||
*
|
||||
* To see an example of this examine what configure.ac does when
|
||||
* --enable-arm-neon is specified on the command line.
|
||||
*/
|
||||
PNG_FILTER_OPTIMIZATIONS(pp, bpp);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -3947,6 +3878,10 @@ void /* PRIVATE */
|
||||
png_read_filter_row(png_structrp pp, png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row, int filter)
|
||||
{
|
||||
/* OPTIMIZATION: DO NOT MODIFY THIS FUNCTION, instead #define
|
||||
* PNG_FILTER_OPTIMIZATIONS to a function that overrides the generic
|
||||
* implementations. See png_init_filter_functions above.
|
||||
*/
|
||||
if (pp->read_filter[0] == NULL)
|
||||
png_init_filter_functions(pp);
|
||||
if (filter > PNG_FILTER_VALUE_NONE && filter < PNG_FILTER_VALUE_LAST)
|
||||
@@ -4018,7 +3953,7 @@ png_read_IDAT_data(png_structrp png_ptr, png_bytep output,
|
||||
png_ptr->zstream.avail_out = out;
|
||||
}
|
||||
|
||||
else /* check for end */
|
||||
else /* after last row, checking for end */
|
||||
{
|
||||
png_ptr->zstream.next_out = tmpbuf;
|
||||
png_ptr->zstream.avail_out = (sizeof tmpbuf);
|
||||
@@ -4033,10 +3968,13 @@ png_read_IDAT_data(png_structrp png_ptr, png_bytep output,
|
||||
*/
|
||||
ret = inflate(&png_ptr->zstream, Z_NO_FLUSH);
|
||||
|
||||
/* Take the unconsumed output back (so, in the 'check' case this just
|
||||
* counts up).
|
||||
*/
|
||||
avail_out += png_ptr->zstream.avail_out;
|
||||
/* Take the unconsumed output back. */
|
||||
if (output != NULL)
|
||||
avail_out += png_ptr->zstream.avail_out;
|
||||
|
||||
else /* avail_out counts the extra bytes */
|
||||
avail_out += (sizeof tmpbuf) - png_ptr->zstream.avail_out;
|
||||
|
||||
png_ptr->zstream.avail_out = 0;
|
||||
|
||||
if (ret == Z_STREAM_END)
|
||||
@@ -4075,7 +4013,7 @@ png_read_IDAT_data(png_structrp png_ptr, png_bytep output,
|
||||
if (output != NULL)
|
||||
png_error(png_ptr, "Not enough image data");
|
||||
|
||||
else /* checking */
|
||||
else /* the deflate stream contained extra data */
|
||||
png_chunk_benign_error(png_ptr, "Too much image data");
|
||||
}
|
||||
}
|
||||
@@ -4410,7 +4348,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||
png_error(png_ptr, "This image requires a row greater than 64KB");
|
||||
#endif
|
||||
|
||||
if (row_bytes + 48 > png_ptr->old_big_row_buf_size)
|
||||
if (row_bytes + 48 > png_ptr->big_row_buf_size)
|
||||
{
|
||||
png_free(png_ptr, png_ptr->big_row_buf);
|
||||
png_free(png_ptr, png_ptr->big_prev_row);
|
||||
@@ -4447,7 +4385,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||
png_ptr->row_buf = png_ptr->big_row_buf + 31;
|
||||
png_ptr->prev_row = png_ptr->big_prev_row + 31;
|
||||
#endif
|
||||
png_ptr->old_big_row_buf_size = row_bytes + 48;
|
||||
png_ptr->big_row_buf_size = row_bytes + 48;
|
||||
}
|
||||
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
@@ -4486,7 +4424,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||
* IDAT stream has a bogus deflate header window_bits value, but this should
|
||||
* not be happening any longer!)
|
||||
*/
|
||||
if (png_inflate_claim(png_ptr, png_IDAT, 0) != Z_OK)
|
||||
if (png_inflate_claim(png_ptr, png_IDAT) != Z_OK)
|
||||
png_error(png_ptr, png_ptr->zstream.msg);
|
||||
|
||||
png_ptr->flags |= PNG_FLAG_ROW_INIT;
|
||||
|
||||
448
pngset.c
448
pngset.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -238,16 +238,7 @@ png_set_IHDR(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
info_ptr->pixel_depth = (png_byte)(info_ptr->channels * info_ptr->bit_depth);
|
||||
|
||||
/* Check for potential overflow */
|
||||
if (width >
|
||||
(PNG_UINT_32_MAX >> 3) /* 8-byte RRGGBBAA pixels */
|
||||
- 48 /* bigrowbuf hack */
|
||||
- 1 /* filter byte */
|
||||
- 7*8 /* rounding of width to multiple of 8 pixels */
|
||||
- 8) /* extra max_pixel_depth pad */
|
||||
info_ptr->rowbytes = 0;
|
||||
else
|
||||
info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width);
|
||||
info_ptr->rowbytes = PNG_ROWBYTES(info_ptr->pixel_depth, width);
|
||||
}
|
||||
|
||||
#ifdef PNG_oFFs_SUPPORTED
|
||||
@@ -431,7 +422,8 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
info_ptr->free_me |= PNG_FREE_SCAL;
|
||||
}
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
# if defined(PNG_FLOATING_POINT_SUPPORTED) &&\
|
||||
defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)
|
||||
void PNGAPI
|
||||
png_set_sCAL(png_const_structrp png_ptr, png_inforp info_ptr, int unit,
|
||||
double width, double height)
|
||||
@@ -514,7 +506,7 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
png_debug1(1, "in %s storage function", "PLTE");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL || palette == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (num_palette < 0 || num_palette > PNG_MAX_PALETTE_LENGTH)
|
||||
@@ -529,6 +521,17 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
|
||||
}
|
||||
}
|
||||
|
||||
if ((num_palette > 0 && palette == NULL) ||
|
||||
(num_palette == 0
|
||||
# ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
&& (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0
|
||||
# endif
|
||||
))
|
||||
{
|
||||
png_chunk_report(png_ptr, "Invalid palette", PNG_CHUNK_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
/* It may not actually be necessary to set png_ptr->palette here;
|
||||
* we do it for backward compatibility with the way the png_handle_tRNS
|
||||
* function used to do the allocation.
|
||||
@@ -545,7 +548,8 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
|
||||
png_ptr->palette = png_voidcast(png_colorp, png_calloc(png_ptr,
|
||||
PNG_MAX_PALETTE_LENGTH * (sizeof (png_color))));
|
||||
|
||||
memcpy(png_ptr->palette, palette, num_palette * (sizeof (png_color)));
|
||||
if (num_palette > 0)
|
||||
memcpy(png_ptr->palette, palette, num_palette * (sizeof (png_color)));
|
||||
info_ptr->palette = png_ptr->palette;
|
||||
info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
|
||||
|
||||
@@ -677,7 +681,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_text(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_set_text(png_structrp png_ptr, png_inforp info_ptr,
|
||||
png_const_textp text_ptr, int num_text)
|
||||
{
|
||||
int ret;
|
||||
@@ -688,7 +692,7 @@ png_set_text(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
}
|
||||
|
||||
int /* PRIVATE */
|
||||
png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_set_text_2(png_structrp png_ptr, png_inforp info_ptr,
|
||||
png_const_textp text_ptr, int num_text)
|
||||
{
|
||||
int i;
|
||||
@@ -696,63 +700,63 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_debug1(1, "in %lx storage function", png_ptr == NULL ? "unexpected" :
|
||||
(unsigned long)png_ptr->chunk_name);
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL || num_text == 0)
|
||||
if (png_ptr == NULL || info_ptr == NULL || num_text <= 0 || text_ptr == NULL)
|
||||
return(0);
|
||||
|
||||
/* Make sure we have enough space in the "text" array in info_struct
|
||||
* to hold all of the incoming text_ptr objects.
|
||||
* to hold all of the incoming text_ptr objects. This compare can't overflow
|
||||
* because max_text >= num_text (anyway, subtract of two positive integers
|
||||
* can't overflow in any case.)
|
||||
*/
|
||||
if (info_ptr->num_text + num_text > info_ptr->max_text)
|
||||
if (num_text > info_ptr->max_text - info_ptr->num_text)
|
||||
{
|
||||
int old_max_text = info_ptr->max_text;
|
||||
int old_num_text = info_ptr->num_text;
|
||||
int max_text;
|
||||
png_textp new_text = NULL;
|
||||
|
||||
if (info_ptr->text != NULL)
|
||||
/* Calculate an appropriate max_text, checking for overflow. */
|
||||
max_text = old_num_text;
|
||||
if (num_text <= INT_MAX - max_text)
|
||||
{
|
||||
png_textp old_text;
|
||||
max_text += num_text;
|
||||
|
||||
info_ptr->max_text = info_ptr->num_text + num_text + 8;
|
||||
old_text = info_ptr->text;
|
||||
/* Round up to a multiple of 8 */
|
||||
if (max_text < INT_MAX-8)
|
||||
max_text = (max_text + 8) & ~0x7;
|
||||
|
||||
info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
|
||||
(png_size_t)(info_ptr->max_text * (sizeof (png_text))));
|
||||
else
|
||||
max_text = INT_MAX;
|
||||
|
||||
if (info_ptr->text == NULL)
|
||||
{
|
||||
/* Restore to previous condition */
|
||||
info_ptr->max_text = old_max_text;
|
||||
info_ptr->text = old_text;
|
||||
return(1);
|
||||
}
|
||||
|
||||
memcpy(info_ptr->text, old_text, (png_size_t)(old_max_text *
|
||||
(sizeof (png_text))));
|
||||
png_free(png_ptr, old_text);
|
||||
/* Now allocate a new array and copy the old members in, this does all
|
||||
* the overflow checks.
|
||||
*/
|
||||
new_text = png_voidcast(png_textp,png_realloc_array(png_ptr,
|
||||
info_ptr->text, old_num_text, max_text-old_num_text,
|
||||
sizeof *new_text));
|
||||
}
|
||||
|
||||
else
|
||||
if (new_text == NULL)
|
||||
{
|
||||
info_ptr->max_text = num_text + 8;
|
||||
info_ptr->num_text = 0;
|
||||
info_ptr->text = (png_textp)png_malloc_warn(png_ptr,
|
||||
(png_size_t)(info_ptr->max_text * (sizeof (png_text))));
|
||||
if (info_ptr->text == NULL)
|
||||
{
|
||||
/* Restore to previous condition */
|
||||
info_ptr->num_text = old_num_text;
|
||||
info_ptr->max_text = old_max_text;
|
||||
return(1);
|
||||
}
|
||||
info_ptr->free_me |= PNG_FREE_TEXT;
|
||||
png_chunk_report(png_ptr, "too many text chunks",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
png_debug1(3, "allocated %d entries for info_ptr->text",
|
||||
info_ptr->max_text);
|
||||
png_free(png_ptr, info_ptr->text);
|
||||
|
||||
info_ptr->text = new_text;
|
||||
info_ptr->free_me |= PNG_FREE_TEXT;
|
||||
info_ptr->max_text = max_text;
|
||||
/* num_text is adjusted below as the entries are copied in */
|
||||
|
||||
png_debug1(3, "allocated %d entries for info_ptr->text", max_text);
|
||||
}
|
||||
|
||||
for (i = 0; i < num_text; i++)
|
||||
{
|
||||
png_size_t text_length, key_len;
|
||||
png_size_t lang_len, lang_key_len;
|
||||
size_t text_length, key_len;
|
||||
size_t lang_len, lang_key_len;
|
||||
png_textp textp = &(info_ptr->text[info_ptr->num_text]);
|
||||
|
||||
if (text_ptr[i].key == NULL)
|
||||
@@ -761,7 +765,8 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
if (text_ptr[i].compression < PNG_TEXT_COMPRESSION_NONE ||
|
||||
text_ptr[i].compression >= PNG_TEXT_COMPRESSION_LAST)
|
||||
{
|
||||
png_warning(png_ptr, "text compression mode is out of range");
|
||||
png_chunk_report(png_ptr, "text compression mode is out of range",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -792,7 +797,8 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
}
|
||||
# else /* PNG_iTXt_SUPPORTED */
|
||||
{
|
||||
png_warning(png_ptr, "iTXt chunk not supported");
|
||||
png_chunk_report(png_ptr, "iTXt chunk not supported",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
continue;
|
||||
}
|
||||
# endif
|
||||
@@ -815,19 +821,22 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
textp->compression = text_ptr[i].compression;
|
||||
}
|
||||
|
||||
textp->key = (png_charp)png_malloc_warn(png_ptr,
|
||||
(png_size_t)
|
||||
(key_len + text_length + lang_len + lang_key_len + 4));
|
||||
textp->key = png_voidcast(png_charp,png_malloc_base(png_ptr,
|
||||
key_len + text_length + lang_len + lang_key_len + 4));
|
||||
|
||||
if (textp->key == NULL)
|
||||
return(1);
|
||||
{
|
||||
png_chunk_report(png_ptr, "text chunk: out of memory",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
return 1;
|
||||
}
|
||||
|
||||
png_debug2(2, "Allocated %lu bytes at %p in png_set_text",
|
||||
(unsigned long)(png_uint_32)
|
||||
(key_len + lang_len + lang_key_len + text_length + 4),
|
||||
textp->key);
|
||||
|
||||
memcpy(textp->key, text_ptr[i].key,(png_size_t)(key_len));
|
||||
memcpy(textp->key, text_ptr[i].key, key_len);
|
||||
*(textp->key + key_len) = '\0';
|
||||
|
||||
if (text_ptr[i].compression > 0)
|
||||
@@ -849,8 +858,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
}
|
||||
|
||||
if (text_length)
|
||||
memcpy(textp->text, text_ptr[i].text,
|
||||
(png_size_t)(text_length));
|
||||
memcpy(textp->text, text_ptr[i].text, text_length);
|
||||
|
||||
*(textp->text + text_length) = '\0';
|
||||
|
||||
@@ -871,6 +879,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
info_ptr->num_text++;
|
||||
png_debug1(3, "transferred text chunk %d", info_ptr->num_text);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
#endif
|
||||
@@ -910,59 +919,97 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
if (trans_alpha != NULL)
|
||||
if (info_ptr->color_type & PNG_COLOR_MASK_ALPHA)
|
||||
png_chunk_report(png_ptr,
|
||||
"png_set_tRNS: invalid on PNG with alpha channel", PNG_CHUNK_ERROR);
|
||||
|
||||
else if (info_ptr->color_type & PNG_COLOR_MASK_PALETTE)
|
||||
{
|
||||
/* It may not actually be necessary to set png_ptr->trans_alpha here;
|
||||
* we do it for backward compatibility with the way the png_handle_tRNS
|
||||
* function used to do the allocation.
|
||||
*
|
||||
* 1.6.0: The above statement is incorrect; png_handle_tRNS effectively
|
||||
* relies on png_set_tRNS storing the information in png_struct
|
||||
* (otherwise it won't be there for the code in pngrtran.c).
|
||||
*/
|
||||
int max_num;
|
||||
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
|
||||
/* Free the old data; num_trans 0 can be used to kill the tRNS */
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_TRNS, 0);
|
||||
|
||||
/* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1 */
|
||||
png_ptr->trans_alpha = info_ptr->trans_alpha = png_voidcast(png_bytep,
|
||||
png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH));
|
||||
/* Do this just in case the old data was not owned by libpng: */
|
||||
info_ptr->valid &= ~PNG_INFO_tRNS;
|
||||
info_ptr->trans_alpha = NULL;
|
||||
info_ptr->num_trans = 0;
|
||||
|
||||
if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH)
|
||||
memcpy(info_ptr->trans_alpha, trans_alpha, (png_size_t)num_trans);
|
||||
/* Expect png_set_PLTE to happen before png_set_tRNS, so num_palette will
|
||||
* be set, but this is not a requirement of the API.
|
||||
*/
|
||||
if (png_ptr->num_palette)
|
||||
max_num = png_ptr->num_palette;
|
||||
|
||||
else
|
||||
max_num = 1 << png_ptr->bit_depth;
|
||||
|
||||
if (num_trans > max_num)
|
||||
{
|
||||
png_chunk_report(png_ptr, "png_set_tRNS: num_trans too large",
|
||||
PNG_CHUNK_ERROR);
|
||||
/* If control returns simply limit it; the behavior prior to 1.7 was to
|
||||
* issue a warning and skip the palette in png_write_tRNS.
|
||||
*/
|
||||
num_trans = max_num;
|
||||
}
|
||||
|
||||
/* But only attempt a malloc if there is something to do; so the app can
|
||||
* set a tRNS array then later delete it.
|
||||
*/
|
||||
if (num_trans > 0 && trans_alpha != NULL)
|
||||
{
|
||||
/* Changed from num_trans to PNG_MAX_PALETTE_LENGTH in version 1.2.1,
|
||||
* this avoids issues where a palette image contains out of range
|
||||
* indices.
|
||||
*/
|
||||
info_ptr->trans_alpha = png_voidcast(png_bytep, png_malloc(png_ptr,
|
||||
PNG_MAX_PALETTE_LENGTH));
|
||||
info_ptr->free_me |= PNG_FREE_TRNS;
|
||||
|
||||
memcpy(info_ptr->trans_alpha, trans_alpha,
|
||||
(unsigned)/*SAFE*/num_trans);
|
||||
info_ptr->valid |= PNG_INFO_tRNS;
|
||||
info_ptr->num_trans = (png_uint_16)num_trans; /* SAFE */
|
||||
}
|
||||
}
|
||||
|
||||
if (trans_color != NULL)
|
||||
else /* not a PALETTE image */
|
||||
{
|
||||
int sample_max = (1 << info_ptr->bit_depth);
|
||||
/* Invalidate any prior transparent color, set num_trans too, it is not
|
||||
* used internally in this case but png_get_tRNS still returns it.
|
||||
*/
|
||||
info_ptr->valid &= ~PNG_INFO_tRNS;
|
||||
info_ptr->num_trans = 0; /* for png_get_tRNS */
|
||||
|
||||
if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
|
||||
trans_color->gray > sample_max) ||
|
||||
(info_ptr->color_type == PNG_COLOR_TYPE_RGB &&
|
||||
(trans_color->red > sample_max ||
|
||||
trans_color->green > sample_max ||
|
||||
trans_color->blue > sample_max)))
|
||||
png_warning(png_ptr,
|
||||
"tRNS chunk has out-of-range samples for bit_depth");
|
||||
if (trans_color != NULL)
|
||||
{
|
||||
int sample_max = (1 << info_ptr->bit_depth);
|
||||
|
||||
info_ptr->trans_color = *trans_color;
|
||||
if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
|
||||
trans_color->gray <= sample_max) ||
|
||||
(info_ptr->color_type == PNG_COLOR_TYPE_RGB &&
|
||||
trans_color->red <= sample_max &&
|
||||
trans_color->green <= sample_max &&
|
||||
trans_color->blue <= sample_max))
|
||||
{
|
||||
info_ptr->trans_color = *trans_color;
|
||||
info_ptr->valid |= PNG_INFO_tRNS;
|
||||
info_ptr->num_trans = 1; /* for png_get_tRNS */
|
||||
}
|
||||
|
||||
if (num_trans == 0)
|
||||
num_trans = 1;
|
||||
}
|
||||
|
||||
info_ptr->num_trans = (png_uint_16)num_trans;
|
||||
|
||||
if (num_trans != 0)
|
||||
{
|
||||
info_ptr->valid |= PNG_INFO_tRNS;
|
||||
info_ptr->free_me |= PNG_FREE_TRNS;
|
||||
else
|
||||
png_chunk_report(png_ptr,
|
||||
"tRNS chunk has out-of-range samples for bit_depth",
|
||||
PNG_CHUNK_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_sPLT_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_sPLT(png_const_structrp png_ptr,
|
||||
png_set_sPLT(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_const_sPLT_tp entries, int nentries)
|
||||
/*
|
||||
* entries - array of png_sPLT_t structures
|
||||
@@ -974,78 +1021,88 @@ png_set_sPLT(png_const_structrp png_ptr,
|
||||
*/
|
||||
{
|
||||
png_sPLT_tp np;
|
||||
int i;
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL || nentries <= 0 ||
|
||||
entries == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL || nentries <= 0 || entries == NULL)
|
||||
return;
|
||||
|
||||
np = png_voidcast(png_sPLT_tp, png_malloc_warn(png_ptr,
|
||||
(info_ptr->splt_palettes_num + nentries) * (sizeof (png_sPLT_t))));
|
||||
/* Use the internal realloc function, which checks for all the possible
|
||||
* overflows. Notice that the parameters are (int) and (size_t)
|
||||
*/
|
||||
np = png_voidcast(png_sPLT_tp,png_realloc_array(png_ptr,
|
||||
info_ptr->splt_palettes, info_ptr->splt_palettes_num, nentries,
|
||||
sizeof *np));
|
||||
|
||||
if (np == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "No memory for sPLT palettes");
|
||||
/* Out of memory or too many chunks */
|
||||
png_chunk_report(png_ptr, "too many sPLT chunks", PNG_CHUNK_WRITE_ERROR);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(np, info_ptr->splt_palettes,
|
||||
info_ptr->splt_palettes_num * (sizeof (png_sPLT_t)));
|
||||
|
||||
png_free(png_ptr, info_ptr->splt_palettes);
|
||||
info_ptr->splt_palettes=NULL;
|
||||
info_ptr->splt_palettes = np;
|
||||
info_ptr->free_me |= PNG_FREE_SPLT;
|
||||
|
||||
/* TODO: fix this, it apparently leaves NULL entries in the event of OOM
|
||||
* below.
|
||||
*/
|
||||
for (i = 0; i < nentries; i++)
|
||||
np += info_ptr->splt_palettes_num;
|
||||
|
||||
do
|
||||
{
|
||||
png_sPLT_tp to = np + info_ptr->splt_palettes_num + i;
|
||||
png_const_sPLT_tp from = entries + i;
|
||||
png_size_t length;
|
||||
|
||||
/* In event of error below the name and entries fields must be set to
|
||||
* NULL, otherwise libpng will crash later on while trying to free the
|
||||
* uninitialized pointers.
|
||||
/* Skip invalid input entries */
|
||||
if (entries->name == NULL || entries->entries == NULL)
|
||||
{
|
||||
/* png_handle_sPLT doesn't do this, so this is an app error */
|
||||
png_app_error(png_ptr, "png_set_sPLT: invalid sPLT");
|
||||
/* Just skip the invalid entry */
|
||||
continue;
|
||||
}
|
||||
|
||||
np->depth = entries->depth;
|
||||
|
||||
/* In the even of out-of-memory just return - there's no point keeping on
|
||||
* trying to add sPLT chunks.
|
||||
*/
|
||||
memset(to, 0, (sizeof *to));
|
||||
length = strlen(entries->name) + 1;
|
||||
np->name = png_voidcast(png_charp, png_malloc_base(png_ptr, length));
|
||||
|
||||
if (from->name == NULL || from->entries == NULL)
|
||||
continue;
|
||||
if (np->name == NULL)
|
||||
break;
|
||||
|
||||
length = strlen(from->name) + 1;
|
||||
to->name = png_voidcast(png_charp, png_malloc_warn(png_ptr, length));
|
||||
memcpy(np->name, entries->name, length);
|
||||
|
||||
if (to->name == NULL)
|
||||
/* IMPORTANT: we have memory now that won't get freed if something else
|
||||
* goes wrong, this code must free it. png_malloc_array produces no
|
||||
* warnings, use a png_chunk_report (below) if there is an error.
|
||||
*/
|
||||
np->entries = png_voidcast(png_sPLT_entryp, png_malloc_array(png_ptr,
|
||||
entries->nentries, sizeof (png_sPLT_entry)));
|
||||
|
||||
if (np->entries == NULL)
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Out of memory while processing sPLT chunk");
|
||||
continue;
|
||||
png_free(png_ptr, np->name);
|
||||
break;
|
||||
}
|
||||
|
||||
memcpy(to->name, from->name, length);
|
||||
to->entries = png_voidcast(png_sPLT_entryp, png_malloc_warn(png_ptr,
|
||||
from->nentries * (sizeof (png_sPLT_entry))));
|
||||
np->nentries = entries->nentries;
|
||||
/* This multiply can't overflow because png_malloc_array has already
|
||||
* checked it when doing the allocation.
|
||||
*/
|
||||
memcpy(np->entries, entries->entries,
|
||||
entries->nentries * sizeof (png_sPLT_entry));
|
||||
|
||||
if (to->entries == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Out of memory while processing sPLT chunk");
|
||||
png_free(png_ptr, to->name);
|
||||
to->name = NULL;
|
||||
continue;
|
||||
}
|
||||
|
||||
memcpy(to->entries, from->entries,
|
||||
from->nentries * (sizeof (png_sPLT_entry)));
|
||||
|
||||
to->nentries = from->nentries;
|
||||
to->depth = from->depth;
|
||||
/* Note that 'continue' skips the advance of the out pointer and out
|
||||
* count, so an invalid entry is not added.
|
||||
*/
|
||||
info_ptr->valid |= PNG_INFO_sPLT;
|
||||
++(info_ptr->splt_palettes_num);
|
||||
++np;
|
||||
}
|
||||
while (++entries, --nentries);
|
||||
|
||||
info_ptr->splt_palettes = np;
|
||||
info_ptr->splt_palettes_num += nentries;
|
||||
info_ptr->valid |= PNG_INFO_sPLT;
|
||||
info_ptr->free_me |= PNG_FREE_SPLT;
|
||||
if (nentries > 0)
|
||||
png_chunk_report(png_ptr, "sPLT out of memory", PNG_CHUNK_WRITE_ERROR);
|
||||
}
|
||||
#endif /* PNG_sPLT_SUPPORTED */
|
||||
|
||||
@@ -1069,6 +1126,9 @@ check_location(png_const_structrp png_ptr, int location)
|
||||
(PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT));
|
||||
}
|
||||
|
||||
/* This need not be an internal error - if the app calls
|
||||
* png_set_unknown_chunks on a read pointer it must get the location right.
|
||||
*/
|
||||
if (location == 0)
|
||||
png_error(png_ptr, "invalid location in png_set_unknown_chunks");
|
||||
|
||||
@@ -1085,12 +1145,13 @@ check_location(png_const_structrp png_ptr, int location)
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
png_set_unknown_chunks(png_const_structrp png_ptr,
|
||||
png_set_unknown_chunks(png_structrp png_ptr,
|
||||
png_inforp info_ptr, png_const_unknown_chunkp unknowns, int num_unknowns)
|
||||
{
|
||||
png_unknown_chunkp np;
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL || num_unknowns <= 0)
|
||||
if (png_ptr == NULL || info_ptr == NULL || num_unknowns <= 0 ||
|
||||
unknowns == NULL)
|
||||
return;
|
||||
|
||||
/* Check for the failure cases where support has been disabled at compile
|
||||
@@ -1099,16 +1160,16 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
|
||||
* code) but may be meaningless if the read or write handling of unknown
|
||||
* chunks is not compiled in.
|
||||
*/
|
||||
# if !(defined PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) && \
|
||||
(defined PNG_READ_SUPPORTED)
|
||||
# if !defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) && \
|
||||
defined(PNG_READ_SUPPORTED)
|
||||
if (png_ptr->mode & PNG_IS_READ_STRUCT)
|
||||
{
|
||||
png_app_error(png_ptr, "no unknown chunk support on read");
|
||||
return;
|
||||
}
|
||||
# endif
|
||||
# if !(defined PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) && \
|
||||
(defined PNG_WRITE_SUPPORTED)
|
||||
# if !defined(PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED) && \
|
||||
defined(PNG_WRITE_SUPPORTED)
|
||||
if (!(png_ptr->mode & PNG_IS_READ_STRUCT))
|
||||
{
|
||||
png_app_error(png_ptr, "no unknown chunk support on write");
|
||||
@@ -1116,20 +1177,22 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
|
||||
}
|
||||
# endif
|
||||
|
||||
/* Prior to 1.6.0 this code used png_malloc_warn, however this meant that
|
||||
/* Prior to 1.6.0 this code used png_malloc_warn; however, this meant that
|
||||
* unknown critical chunks could be lost with just a warning resulting in
|
||||
* undefined behavior. Changing to png_malloc fixes this by producing a
|
||||
* png_error. The (png_size_t) cast was also removed as it hides a potential
|
||||
* overflow.
|
||||
*
|
||||
* TODO: fix the potential overflow in the multiply
|
||||
* undefined behavior. Now png_chunk_report is used to provide behavior
|
||||
* appropriate to read or write.
|
||||
*/
|
||||
np = png_voidcast(png_unknown_chunkp, png_malloc(png_ptr,
|
||||
(info_ptr->unknown_chunks_num + (unsigned int)num_unknowns) *
|
||||
(sizeof (png_unknown_chunk))));
|
||||
np = png_voidcast(png_unknown_chunkp, png_realloc_array(png_ptr,
|
||||
info_ptr->unknown_chunks, info_ptr->unknown_chunks_num, num_unknowns,
|
||||
sizeof *np));
|
||||
|
||||
memcpy(np, info_ptr->unknown_chunks,
|
||||
info_ptr->unknown_chunks_num * (sizeof (png_unknown_chunk)));
|
||||
if (np == NULL)
|
||||
{
|
||||
png_chunk_report(png_ptr, "too many unknown chunks",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
png_free(png_ptr, info_ptr->unknown_chunks);
|
||||
info_ptr->unknown_chunks = np; /* safe because it is initialized */
|
||||
@@ -1140,24 +1203,41 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
|
||||
/* Increment unknown_chunks_num each time round the loop to protect the
|
||||
* just-allocated chunk data.
|
||||
*/
|
||||
for (; --num_unknowns >= 0;
|
||||
++np, ++unknowns, ++(info_ptr->unknown_chunks_num))
|
||||
for (; num_unknowns > 0; --num_unknowns, ++unknowns)
|
||||
{
|
||||
memcpy(np->name, unknowns->name, (sizeof unknowns->name));
|
||||
memcpy(np->name, unknowns->name, (sizeof np->name));
|
||||
np->name[(sizeof np->name)-1] = '\0';
|
||||
np->size = unknowns->size;
|
||||
np->location = check_location(png_ptr, unknowns->location);
|
||||
|
||||
if (unknowns->size == 0)
|
||||
{
|
||||
np->data = NULL;
|
||||
np->size = 0;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
/* png_error is safe here because the list is stored in png_ptr */
|
||||
np->data = png_voidcast(png_bytep,
|
||||
png_malloc(png_ptr, unknowns->size));
|
||||
png_malloc_base(png_ptr, unknowns->size));
|
||||
|
||||
if (np->data == NULL)
|
||||
{
|
||||
png_chunk_report(png_ptr, "unknown chunk: out of memory",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
/* But just skip storing the unknown chunk */
|
||||
continue;
|
||||
}
|
||||
|
||||
memcpy(np->data, unknowns->data, unknowns->size);
|
||||
np->size = unknowns->size;
|
||||
}
|
||||
|
||||
/* These increments are skipped on out-of-memory for the data - the
|
||||
* unknown chunk entry gets overwritten if the png_chunk_report returns.
|
||||
* This is correct in the read case (the chunk is just dropped.)
|
||||
*/
|
||||
++np;
|
||||
++(info_ptr->unknown_chunks_num);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1167,11 +1247,9 @@ png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
{
|
||||
/* This API is pretty pointless in 1.6.0 because the location can be set
|
||||
* before the call to png_set_unknown_chunks.
|
||||
*
|
||||
* TODO: add a png_app_warning in 1.7
|
||||
*/
|
||||
if (png_ptr != NULL && info_ptr != NULL && chunk >= 0 &&
|
||||
(unsigned int)chunk < info_ptr->unknown_chunks_num)
|
||||
chunk < info_ptr->unknown_chunks_num)
|
||||
{
|
||||
if ((location & (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT)) == 0)
|
||||
{
|
||||
@@ -1187,6 +1265,10 @@ png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
info_ptr->unknown_chunks[chunk].location =
|
||||
check_location(png_ptr, location);
|
||||
}
|
||||
|
||||
/* TODO: make this an error in 1.8 (or maybe it will become one in 1.7!) */
|
||||
else if (png_ptr != NULL)
|
||||
png_app_warning(png_ptr, "unknown chunk index out of range");
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1487,19 +1569,19 @@ png_set_user_limits (png_structrp png_ptr, png_uint_32 user_width_max,
|
||||
* rejected by png_set_IHDR(). To accept any PNG datastream
|
||||
* regardless of dimensions, set both limits to 0x7ffffffL.
|
||||
*/
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_ptr->user_width_max = user_width_max;
|
||||
png_ptr->user_height_max = user_height_max;
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
png_ptr->user_width_max = user_width_max;
|
||||
png_ptr->user_height_max = user_height_max;
|
||||
}
|
||||
}
|
||||
|
||||
/* This function was added to libpng 1.4.0 */
|
||||
void PNGAPI
|
||||
png_set_chunk_cache_max (png_structrp png_ptr, png_uint_32 user_chunk_cache_max)
|
||||
{
|
||||
if (png_ptr)
|
||||
png_ptr->user_chunk_cache_max = user_chunk_cache_max;
|
||||
if (png_ptr != NULL)
|
||||
png_ptr->user_chunk_cache_max = user_chunk_cache_max;
|
||||
}
|
||||
|
||||
/* This function was added to libpng 1.4.1 */
|
||||
@@ -1507,7 +1589,7 @@ void PNGAPI
|
||||
png_set_chunk_malloc_max (png_structrp png_ptr,
|
||||
png_alloc_size_t user_chunk_malloc_max)
|
||||
{
|
||||
if (png_ptr)
|
||||
if (png_ptr != NULL)
|
||||
png_ptr->user_chunk_malloc_max = user_chunk_malloc_max;
|
||||
}
|
||||
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */
|
||||
|
||||
657
pngstruct.h
657
pngstruct.h
@@ -1,11 +1,11 @@
|
||||
|
||||
/* pngstruct.h - header file for PNG reference library
|
||||
*
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@@ -28,7 +28,9 @@
|
||||
/* We must ensure that zlib uses 'const' in declarations. */
|
||||
# define ZLIB_CONST
|
||||
#endif
|
||||
#include "zlib.h"
|
||||
|
||||
#include PNG_ZLIB_HEADER
|
||||
|
||||
#ifdef const
|
||||
/* zlib.h sometimes #defines const to nothing, undo this. */
|
||||
# undef const
|
||||
@@ -48,10 +50,10 @@
|
||||
/* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib
|
||||
* can handle at once. This type need be no larger than 16 bits (so maximum of
|
||||
* 65535), this define allows us to discover how big it is, but limited by the
|
||||
* maximuum for png_size_t. The value can be overriden in a library build
|
||||
* (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably
|
||||
* lower value (e.g. 255 works). A lower value may help memory usage (slightly)
|
||||
* and may even improve performance on some systems (and degrade it on others.)
|
||||
* maximum for size_t. The value can be overridden in a library build (pngusr.h,
|
||||
* or set it in CPPFLAGS) and it works to set it to a considerably lower value
|
||||
* (e.g. 255 works). A lower value may help memory usage (slightly) and may
|
||||
* even improve performance on some systems (and degrade it on others.)
|
||||
*/
|
||||
#ifndef ZLIB_IO_MAX
|
||||
# define ZLIB_IO_MAX ((uInt)-1)
|
||||
@@ -100,7 +102,7 @@ typedef struct png_XYZ
|
||||
} png_XYZ;
|
||||
#endif /* COLORSPACE */
|
||||
|
||||
#if defined PNG_COLORSPACE_SUPPORTED || defined PNG_GAMMA_SUPPORTED
|
||||
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||
/* A colorspace is all the above plus, potentially, profile information,
|
||||
* however at present libpng does not use the profile internally so it is only
|
||||
* stored in the png_info struct (if iCCP is supported.) The rendering intent
|
||||
@@ -137,313 +139,239 @@ typedef const png_colorspace * PNG_RESTRICT png_const_colorspacerp;
|
||||
#define PNG_COLORSPACE_FROM_sRGB 0x0020
|
||||
#define PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB 0x0040
|
||||
#define PNG_COLORSPACE_MATCHES_sRGB 0x0080 /* exact match on profile */
|
||||
#define PNG_COLORSPACE_RGB_TO_GRAY_SET 0x0100 /* user specified coeffs */
|
||||
#define PNG_COLORSPACE_INVALID 0x8000
|
||||
#define PNG_COLORSPACE_CANCEL(flags) (0xffff ^ (flags))
|
||||
#endif /* COLORSPACE || GAMMA */
|
||||
|
||||
struct png_struct_def
|
||||
{
|
||||
/* Rearranged in libpng 1.7 to attempt to lessen padding; in general
|
||||
* (char), (short), (int) and pointer types are kept separate, however
|
||||
* associated members under the control of the same #define are still
|
||||
* together.
|
||||
*/
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
jmp_buf jmp_buf_local; /* New name in 1.6.0 for jmp_buf in png_struct */
|
||||
png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */
|
||||
jmp_buf *jmp_buf_ptr; /* passed to longjmp_fn */
|
||||
size_t jmp_buf_size; /* size of the above, if allocated */
|
||||
#endif
|
||||
png_error_ptr error_fn; /* function for printing errors and aborting */
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
png_error_ptr warning_fn; /* function for printing warnings */
|
||||
#endif
|
||||
png_voidp error_ptr; /* user supplied struct for error functions */
|
||||
png_rw_ptr write_data_fn; /* function for writing output data */
|
||||
png_rw_ptr read_data_fn; /* function for reading input data */
|
||||
png_voidp io_ptr; /* ptr to application struct for I/O functions */
|
||||
|
||||
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
png_user_transform_ptr read_user_transform_fn; /* user read transform */
|
||||
/* jmp_buf can have very high alignment requirements on some systems, so put
|
||||
* it first (the other setjmp members are later as they are infrequently
|
||||
* accesed.)
|
||||
*/
|
||||
jmp_buf jmp_buf_local;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||
png_user_transform_ptr write_user_transform_fn; /* user write transform */
|
||||
#endif
|
||||
/* Next the frequently accessed fields. Many processors perform arithmetic
|
||||
* in the address pipeline, but frequently the amount of addition or
|
||||
* subtraction is limited. By putting these fields at the head of png_struct
|
||||
* the hope is that such processors will generate code that is both smaller
|
||||
* and faster.
|
||||
*/
|
||||
png_colorp palette; /* palette from the input file */
|
||||
size_t rowbytes; /* size of row in bytes */
|
||||
size_t info_rowbytes; /* cache of updated row bytes */
|
||||
png_uint_32 width; /* width of image in pixels */
|
||||
png_uint_32 height; /* height of image in pixels */
|
||||
png_uint_32 num_rows; /* number of rows in current pass */
|
||||
png_uint_32 usr_width; /* width of row at start of write */
|
||||
png_uint_32 iwidth; /* width of current interlaced row in pixels */
|
||||
png_uint_32 row_number; /* current row in interlace pass */
|
||||
png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */
|
||||
png_uint_32 crc; /* current chunk CRC value */
|
||||
png_uint_32 mode; /* tells us where we are in the PNG file */
|
||||
png_uint_32 flags; /* flags indicating various things to libpng */
|
||||
png_uint_32 transformations;/* which transformations to perform */
|
||||
png_uint_32 zowner; /* ID (chunk type) of zstream owner, 0 if none */
|
||||
png_uint_32 free_me; /* items libpng is responsible for freeing */
|
||||
|
||||
/* These were added in libpng-1.0.2 */
|
||||
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
|
||||
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
|
||||
png_voidp user_transform_ptr; /* user supplied struct for user transform */
|
||||
png_byte user_transform_depth; /* bit depth of user transformed pixels */
|
||||
png_byte user_transform_channels; /* channels in user transformed pixels */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
png_uint_32 mode; /* tells us where we are in the PNG file */
|
||||
png_uint_32 flags; /* flags indicating various things to libpng */
|
||||
png_uint_32 transformations; /* which transformations to perform */
|
||||
|
||||
png_uint_32 zowner; /* ID (chunk type) of zstream owner, 0 if none */
|
||||
z_stream zstream; /* decompression structure */
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
png_compression_bufferp zbuffer_list; /* Created on demand during write */
|
||||
uInt zbuffer_size; /* size of the actual buffer */
|
||||
|
||||
int zlib_level; /* holds zlib compression level */
|
||||
int zlib_method; /* holds zlib compression method */
|
||||
int zlib_window_bits; /* holds zlib compression window bits */
|
||||
int zlib_mem_level; /* holds zlib compression memory level */
|
||||
int zlib_strategy; /* holds zlib compression strategy */
|
||||
#endif
|
||||
/* Added at libpng 1.5.4 */
|
||||
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
int zlib_text_level; /* holds zlib compression level */
|
||||
int zlib_text_method; /* holds zlib compression method */
|
||||
int zlib_text_window_bits; /* holds zlib compression window bits */
|
||||
int zlib_text_mem_level; /* holds zlib compression memory level */
|
||||
int zlib_text_strategy; /* holds zlib compression strategy */
|
||||
#endif
|
||||
/* End of material added at libpng 1.5.4 */
|
||||
/* Added at libpng 1.6.0 */
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
int zlib_set_level; /* Actual values set into the zstream on write */
|
||||
int zlib_set_method;
|
||||
int zlib_set_window_bits;
|
||||
int zlib_set_mem_level;
|
||||
int zlib_set_strategy;
|
||||
#endif
|
||||
|
||||
png_uint_32 width; /* width of image in pixels */
|
||||
png_uint_32 height; /* height of image in pixels */
|
||||
png_uint_32 num_rows; /* number of rows in current pass */
|
||||
png_uint_32 usr_width; /* width of row at start of write */
|
||||
png_size_t rowbytes; /* size of row in bytes */
|
||||
png_uint_32 iwidth; /* width of current interlaced row in pixels */
|
||||
png_uint_32 row_number; /* current row in interlace pass */
|
||||
png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */
|
||||
png_bytep prev_row; /* buffer to save previous (unfiltered) row.
|
||||
* This is a pointer into big_prev_row
|
||||
*/
|
||||
png_bytep row_buf; /* buffer to save current (unfiltered) row.
|
||||
* This is a pointer into big_row_buf
|
||||
*/
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
png_bytep sub_row; /* buffer to save "sub" row when filtering */
|
||||
png_bytep up_row; /* buffer to save "up" row when filtering */
|
||||
png_bytep avg_row; /* buffer to save "avg" row when filtering */
|
||||
png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
|
||||
#endif
|
||||
png_size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */
|
||||
|
||||
png_uint_32 idat_size; /* current IDAT size for read */
|
||||
png_uint_32 crc; /* current chunk CRC value */
|
||||
png_colorp palette; /* palette from the input file */
|
||||
png_uint_16 num_palette; /* number of color entries in palette */
|
||||
|
||||
/* Added at libpng-1.5.10 */
|
||||
int maximum_pixel_depth; /* pixel depth used for the row buffers */
|
||||
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
int num_palette_max; /* maximum palette index found in IDAT */
|
||||
int num_palette_max; /* maximum palette index found in IDAT */
|
||||
#endif
|
||||
|
||||
png_uint_16 num_palette; /* number of color entries in palette */
|
||||
png_uint_16 num_trans; /* number of transparency values */
|
||||
png_byte compression; /* file compression type (always 0) */
|
||||
|
||||
/* Single byte values, typically used either to save space or to hold 1-byte
|
||||
* values from the PNG chunk specifications.
|
||||
*/
|
||||
png_byte compression_type; /* file compression type (always 0) */
|
||||
png_byte filter; /* file filter type (always 0) */
|
||||
png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
|
||||
png_byte pass; /* current interlace pass (0 - 6) */
|
||||
png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */
|
||||
png_byte color_type; /* color type of file */
|
||||
png_byte bit_depth; /* bit depth of file */
|
||||
png_byte usr_bit_depth; /* bit depth of users row: write only */
|
||||
png_byte pixel_depth; /* number of bits per pixel */
|
||||
png_byte channels; /* number of channels in file */
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
png_byte usr_channels; /* channels at start of write: write only */
|
||||
#endif
|
||||
png_byte sig_bytes; /* magic bytes read/written from start of file */
|
||||
png_byte maximum_pixel_depth;
|
||||
/* pixel depth used for the row buffers */
|
||||
png_byte transformed_pixel_depth;
|
||||
/* pixel depth after read/write transforms */
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||
png_uint_16 filler; /* filler bytes for pixel expansion */
|
||||
|
||||
/* ERROR HANDLING */
|
||||
#ifdef PNG_SETJMP_SUPPORTED
|
||||
jmp_buf *jmp_buf_ptr; /* passed to longjmp_fn */
|
||||
png_longjmp_ptr longjmp_fn; /* setjmp non-local goto function. */
|
||||
size_t jmp_buf_size; /* size of *jmp_buf_ptr, if allocated */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||
png_byte background_gamma_type;
|
||||
png_fixed_point background_gamma;
|
||||
png_color_16 background; /* background color in screen gamma space */
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
png_color_16 background_1; /* background normalized to gamma 1.0 */
|
||||
/* Error/warning callbacks */
|
||||
png_error_ptr error_fn; /* print an error message and abort */
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
png_error_ptr warning_fn; /* print a warning and continue */
|
||||
#endif
|
||||
png_voidp error_ptr; /* user supplied data for the above */
|
||||
|
||||
/* MEMORY ALLOCATION */
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_malloc_ptr malloc_fn; /* allocate memory */
|
||||
png_free_ptr free_fn; /* free memory */
|
||||
png_voidp mem_ptr; /* user supplied data for the above */
|
||||
#endif
|
||||
|
||||
/* IO and BASIC READ/WRITE SUPPORT */
|
||||
png_voidp io_ptr; /* user supplied data for IO callbacks */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
png_rw_ptr read_data_fn; /* read some bytes (must succeed) */
|
||||
png_read_status_ptr read_row_fn; /* called after each row is decoded */
|
||||
png_bytep read_buffer; /* buffer for reading chunk data */
|
||||
|
||||
/* During read the following array is set up to point to the appropriate
|
||||
* un-filter function, this allows per-image and per-processor optimization.
|
||||
*/
|
||||
void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,
|
||||
png_bytep row, png_const_bytep prev_row);
|
||||
|
||||
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||
/* The png_struct colorspace structure is only required on read - on write it
|
||||
* is in (just) the info_struct.
|
||||
*/
|
||||
png_colorspace colorspace;
|
||||
#endif
|
||||
#endif /* PNG_READ_SUPPORTED */
|
||||
|
||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
png_uint_32 user_width_max; /* Maximum width on read */
|
||||
png_uint_32 user_height_max; /* Maximum height on read */
|
||||
/* Total memory that a single zTXt, sPLT, iTXt, iCCP, or unknown chunk
|
||||
* can occupy when decompressed. 0 means unlimited. This field is a counter
|
||||
* - it is decremented as memory is allocated.
|
||||
*/
|
||||
png_alloc_size_t user_chunk_malloc_max;
|
||||
#endif
|
||||
#ifdef PNG_USER_LIMITS_SUPPORTED
|
||||
/* limit on total *number* of sPLT, text and unknown chunks that can be
|
||||
* stored. 0 means unlimited. This field is a counter - it is decremented
|
||||
* as chunks are encountered.
|
||||
*/
|
||||
png_uint_32 user_chunk_cache_max;
|
||||
#endif
|
||||
|
||||
/* The progressive reader gets passed data and calls application handling
|
||||
* functions when appropriate.
|
||||
*/
|
||||
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
png_progressive_info_ptr info_fn; /* called after header data fully read */
|
||||
png_progressive_row_ptr row_fn; /* called after a row is decoded */
|
||||
png_progressive_end_ptr end_fn; /* called after image is complete */
|
||||
|
||||
/* Progressive read control data */
|
||||
png_bytep save_buffer_ptr; /* current location in save_buffer */
|
||||
png_bytep save_buffer; /* buffer for previously read data */
|
||||
png_bytep current_buffer_ptr; /* current location in current_buffer */
|
||||
png_bytep current_buffer; /* buffer for recently used data */
|
||||
|
||||
size_t save_buffer_size; /* amount of data now in save_buffer */
|
||||
size_t save_buffer_max; /* total size of save_buffer */
|
||||
size_t buffer_size; /* total amount of available input data */
|
||||
size_t current_buffer_size; /* amount of data now in current_buffer */
|
||||
|
||||
png_uint_32 push_length; /* size of current input chunk */
|
||||
png_uint_32 skip_length; /* bytes to skip in input data */
|
||||
|
||||
int process_mode; /* what push library is currently doing */
|
||||
int cur_palette; /* current push library palette index */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
png_rw_ptr write_data_fn;/* write some bytes (must succeed) */
|
||||
png_write_status_ptr write_row_fn; /* called after each row is encoded */
|
||||
#endif
|
||||
#endif /* PNG_bKGD_SUPPORTED */
|
||||
|
||||
#ifdef PNG_WRITE_FLUSH_SUPPORTED
|
||||
png_flush_ptr output_flush_fn; /* Function for flushing output */
|
||||
png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */
|
||||
png_uint_32 flush_rows; /* number of rows written since last flush */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */
|
||||
png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */
|
||||
|
||||
png_bytep gamma_table; /* gamma table for 8-bit depth files */
|
||||
png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
|
||||
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
png_bytep gamma_from_1; /* converts from 1.0 to screen */
|
||||
png_bytep gamma_to_1; /* converts from file to 1.0 */
|
||||
png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
|
||||
png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
|
||||
#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)
|
||||
png_color_8 sig_bit; /* significant bits in each available channel */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
|
||||
png_color_8 shift; /* shift for significant bit tranformation */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_tRNS_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) \
|
||||
|| defined(PNG_READ_EXPAND_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED)
|
||||
png_bytep trans_alpha; /* alpha values for paletted files */
|
||||
png_color_16 trans_color; /* transparent color for non-paletted files */
|
||||
#endif
|
||||
|
||||
png_read_status_ptr read_row_fn; /* called after each row is decoded */
|
||||
png_write_status_ptr write_row_fn; /* called after each row is encoded */
|
||||
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
|
||||
png_progressive_info_ptr info_fn; /* called after header data fully read */
|
||||
png_progressive_row_ptr row_fn; /* called after a prog. row is decoded */
|
||||
png_progressive_end_ptr end_fn; /* called after image is complete */
|
||||
png_bytep save_buffer_ptr; /* current location in save_buffer */
|
||||
png_bytep save_buffer; /* buffer for previously read data */
|
||||
png_bytep current_buffer_ptr; /* current location in current_buffer */
|
||||
png_bytep current_buffer; /* buffer for recently used data */
|
||||
png_uint_32 push_length; /* size of current input chunk */
|
||||
png_uint_32 skip_length; /* bytes to skip in input data */
|
||||
png_size_t save_buffer_size; /* amount of data now in save_buffer */
|
||||
png_size_t save_buffer_max; /* total size of save_buffer */
|
||||
png_size_t buffer_size; /* total amount of available input data */
|
||||
png_size_t current_buffer_size; /* amount of data now in current_buffer */
|
||||
int process_mode; /* what push library is currently doing */
|
||||
int cur_palette; /* current push library palette index */
|
||||
|
||||
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
|
||||
|
||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||
/* For the Borland special 64K segment handler */
|
||||
png_bytepp offset_table_ptr;
|
||||
png_bytep offset_table;
|
||||
png_uint_16 offset_table_number;
|
||||
png_uint_16 offset_table_count;
|
||||
png_uint_16 offset_table_count_free;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
png_bytep palette_lookup; /* lookup table for quantizing */
|
||||
png_bytep quantize_index; /* index translation for palette files */
|
||||
png_uint_32 flush_dist; /* how many rows apart to flush, 0 - no flush */
|
||||
png_uint_32 flush_rows; /* number of rows written since last flush */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
||||
png_byte heuristic_method; /* heuristic for row filter selection */
|
||||
png_byte num_prev_filters; /* number of weights for previous rows */
|
||||
png_bytep prev_filters; /* filter type(s) of previous row(s) */
|
||||
png_bytep prev_filters; /* filter type(s) of previous row(s) */
|
||||
png_uint_16p filter_weights; /* weight(s) for previous line(s) */
|
||||
png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */
|
||||
png_uint_16p filter_costs; /* relative filter calculation cost */
|
||||
png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
|
||||
png_byte heuristic_method; /* heuristic for row filter selection */
|
||||
png_byte num_prev_filters; /* number of weights for previous rows */
|
||||
#endif
|
||||
|
||||
#if PNG_LIBPNG_VER < 10700
|
||||
/* To do: remove this from libpng-1.7 */
|
||||
#ifdef PNG_TIME_RFC1123_SUPPORTED
|
||||
char time_buffer[29]; /* String to hold RFC 1123 time text */
|
||||
#endif
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
png_byte usr_bit_depth; /* bit depth of users row */
|
||||
png_byte usr_channels; /* channels at start of write */
|
||||
#endif
|
||||
|
||||
/* New members added in libpng-1.0.6 */
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
png_uint_32 io_state; /* tells the app read/write progress */
|
||||
#endif
|
||||
|
||||
png_uint_32 free_me; /* flags items libpng is responsible for freeing */
|
||||
/* ROW BUFFERS
|
||||
*
|
||||
* Members that hold pointers to the decompressed image rows.
|
||||
*/
|
||||
png_bytep row_buf; /* buffer for the current (unfiltered) row */
|
||||
#if defined(PNG_WRITE_FILTER_SUPPORTED) || defined(PNG_READ_SUPPORTED)
|
||||
png_bytep prev_row; /* buffer to save the previous (unfiltered) row */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* The row_buf and prev_row pointers are misaligned so that the start of the
|
||||
* row - after the filter byte - is aligned, the 'big_' pointers record the
|
||||
* original allocated pointer.
|
||||
*/
|
||||
png_bytep big_row_buf;
|
||||
png_bytep big_prev_row;
|
||||
size_t big_row_buf_size; /* Actual size of both */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
/* This is somewhat excessive, there is no obvious reason on write to
|
||||
* allocate a buffer for each possible filtered row, only for the one being
|
||||
* tested and the current best.
|
||||
*
|
||||
* TODO: fix this
|
||||
*/
|
||||
png_bytep sub_row; /* buffer to save "sub" row when filtering */
|
||||
png_bytep up_row; /* buffer to save "up" row when filtering */
|
||||
png_bytep avg_row; /* buffer to save "avg" row when filtering */
|
||||
png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
|
||||
#endif
|
||||
|
||||
/* UNKNOWN CHUNK HANDLING */
|
||||
/* TODO: this is excessively complicated, there are multiple ways of doing
|
||||
* the same thing. It should be cleaned up, possibly by finding out which
|
||||
* APIs applications really use.
|
||||
*/
|
||||
#ifdef PNG_USER_CHUNKS_SUPPORTED
|
||||
/* General purpose pointer for all user/unknown chunk handling; points to
|
||||
* application supplied data for use in the read_user_chunk_fn callback
|
||||
* (currently there is no write side support - the write side must use the
|
||||
* set_unknown_chunks interface.)
|
||||
*/
|
||||
png_voidp user_chunk_ptr;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
|
||||
png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
|
||||
/* This is called back from the unknown chunk handling */
|
||||
png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
int unknown_default; /* As PNG_HANDLE_* */
|
||||
unsigned int num_chunk_list; /* Number of entries in the list */
|
||||
png_bytep chunk_list; /* List of png_byte[5]; the textual chunk name
|
||||
* followed by a PNG_HANDLE_* byte */
|
||||
#endif
|
||||
|
||||
/* New members added in libpng-1.0.3 */
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
png_byte rgb_to_gray_status;
|
||||
/* Added in libpng 1.5.5 to record setting of coefficients: */
|
||||
png_byte rgb_to_gray_coefficients_set;
|
||||
/* These were changed from png_byte in libpng-1.0.6 */
|
||||
png_uint_16 rgb_to_gray_red_coeff;
|
||||
png_uint_16 rgb_to_gray_green_coeff;
|
||||
/* deleted in 1.5.5: rgb_to_gray_blue_coeff; */
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.0.4 (renamed in 1.0.9) */
|
||||
#if defined(PNG_MNG_FEATURES_SUPPORTED)
|
||||
/* Changed from png_byte to png_uint_32 at version 1.2.0 */
|
||||
png_uint_32 mng_features_permitted;
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.0.9, ifdef'ed out in 1.0.12, enabled in 1.2.0 */
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
png_byte filter_type;
|
||||
#endif
|
||||
|
||||
/* New members added in libpng-1.2.0 */
|
||||
|
||||
/* New members added in libpng-1.0.2 but first enabled by default in 1.2.0 */
|
||||
#ifdef PNG_USER_MEM_SUPPORTED
|
||||
png_voidp mem_ptr; /* user supplied struct for mem functions */
|
||||
png_malloc_ptr malloc_fn; /* function for allocating memory */
|
||||
png_free_ptr free_fn; /* function for freeing memory */
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.0.13 and 1.2.0 */
|
||||
png_bytep big_row_buf; /* buffer to save current (unfiltered) row */
|
||||
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
/* The following three members were added at version 1.0.14 and 1.2.4 */
|
||||
png_bytep quantize_sort; /* working sort array */
|
||||
png_bytep index_to_palette; /* where the original index currently is
|
||||
in the palette */
|
||||
png_bytep palette_to_index; /* which original index points to this
|
||||
palette color */
|
||||
#endif
|
||||
|
||||
/* New members added in libpng-1.0.16 and 1.2.6 */
|
||||
png_byte compression_type;
|
||||
|
||||
#ifdef PNG_USER_LIMITS_SUPPORTED
|
||||
png_uint_32 user_width_max;
|
||||
png_uint_32 user_height_max;
|
||||
|
||||
/* Added in libpng-1.4.0: Total number of sPLT, text, and unknown
|
||||
* chunks that can be stored (0 means unlimited).
|
||||
*/
|
||||
png_uint_32 user_chunk_cache_max;
|
||||
|
||||
/* Total memory that a zTXt, sPLT, iTXt, iCCP, or unknown chunk
|
||||
* can occupy when decompressed. 0 means unlimited.
|
||||
*/
|
||||
png_alloc_size_t user_chunk_malloc_max;
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.0.25 and 1.2.17 */
|
||||
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
|
||||
/* Temporary storage for unknown chunk that the library doesn't recognize,
|
||||
* used while reading the chunk.
|
||||
@@ -451,33 +379,182 @@ struct png_struct_def
|
||||
png_unknown_chunk unknown_chunk;
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.2.26 */
|
||||
png_size_t old_big_row_buf_size;
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
png_bytep chunk_list; /* List of png_byte[5]; the textual chunk name
|
||||
* followed by a PNG_HANDLE_* byte */
|
||||
int unknown_default; /* As PNG_HANDLE_* */
|
||||
unsigned int num_chunk_list; /* Number of entries in the list */
|
||||
#endif
|
||||
|
||||
/* USER TRANSFORM SUPPORT */
|
||||
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
png_user_transform_ptr read_user_transform_fn; /* user read transform */
|
||||
#endif
|
||||
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
|
||||
png_user_transform_ptr write_user_transform_fn; /* user write transform */
|
||||
#endif
|
||||
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
|
||||
png_voidp user_transform_ptr; /* user supplied data for the above */
|
||||
png_byte user_transform_depth; /* bit depth of user transformed pixels */
|
||||
png_byte user_transform_channels; /* channels in user transformed pixels */
|
||||
#endif
|
||||
|
||||
/* READ TRANSFORM SUPPORT
|
||||
*
|
||||
* Quite a lot of things can be done to the original image data on read, and
|
||||
* most of these are configurable. The data required by the configurable
|
||||
* read transforms should be stored here. The png_color_16 and png_color_8
|
||||
* structures have low alignment requirements and odd sizes, so may cause
|
||||
* misalignment when present. Member alignment is as follows:
|
||||
*
|
||||
* png_color_16 png_uint_16
|
||||
* png_color_8 png_byte
|
||||
*/
|
||||
/* GAMMA/BACKGROUND/ALPHA-MODE/RGB-TO-GRAY/tRNS/sBIT
|
||||
*
|
||||
* These things are all interrelated because they need some or all of the
|
||||
* gamma tables. Some attempt has been made below to order these members by
|
||||
* size, so that as little padding as possible is required.
|
||||
*/
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
png_bytep gamma_table; /* gamma table for 8-bit depth files */
|
||||
png_uint_16p gamma_16_table; /* gamma table for 16-bit depth files */
|
||||
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED) ||\
|
||||
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
|
||||
png_bytep gamma_from_1; /* converts from 1.0 to screen */
|
||||
png_uint_16p gamma_to_1; /* converts from file to 1.0 */
|
||||
png_uint_16p gamma_16_from_1; /* converts from 1.0 to screen */
|
||||
png_uint_16p gamma_16_to_1; /* converts from file to 1.0 */
|
||||
#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
|
||||
#endif /* PNG_READ_GAMMA_SUPPORTED */
|
||||
|
||||
#if defined(PNG_READ_tRNS_SUPPORTED) || \
|
||||
defined(PNG_READ_BACKGROUND_SUPPORTED) || \
|
||||
defined(PNG_READ_EXPAND_SUPPORTED)
|
||||
png_bytep trans_alpha; /* alpha values for paletted files */
|
||||
#endif
|
||||
|
||||
/* Integer values */
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||
png_fixed_point background_gamma;
|
||||
#endif
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */
|
||||
int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */
|
||||
#endif
|
||||
|
||||
/* png_color_16 */
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||
png_color_16 background; /* background color in screen gamma space */
|
||||
png_color_16 background_1; /* background normalized to gamma 1.0 */
|
||||
#endif
|
||||
#if defined(PNG_READ_tRNS_SUPPORTED) || \
|
||||
defined(PNG_READ_BACKGROUND_SUPPORTED) || \
|
||||
defined(PNG_READ_EXPAND_SUPPORTED)
|
||||
png_color_16 trans_color; /* transparent color for non-paletted files */
|
||||
#endif
|
||||
|
||||
/* png_uint_16 */
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
png_uint_16 rgb_to_gray_red_coeff;
|
||||
png_uint_16 rgb_to_gray_green_coeff;
|
||||
/* The blue coefficient is calculated from the above */
|
||||
#endif
|
||||
|
||||
/* png_color_8 */
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_sBIT_SUPPORTED)
|
||||
png_color_8 sig_bit; /* significant bits in each available channel */
|
||||
#endif
|
||||
|
||||
/* png_byte */
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) ||\
|
||||
defined(PNG_READ_ALPHA_MODE_SUPPORTED)
|
||||
png_byte background_gamma_type;
|
||||
#endif
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
png_byte rgb_to_gray_status;
|
||||
#endif
|
||||
|
||||
/* SHIFT - both READ_SHIFT and WRITE_SHIFT */
|
||||
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
|
||||
png_color_8 shift; /* shift for significant bit tranformation */
|
||||
#endif
|
||||
|
||||
/* FILLER SUPPORT (pixel expansion or read, contraction on write) */
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||
png_uint_16 filler; /* filler bytes for pixel expansion */
|
||||
#endif
|
||||
|
||||
/* QUANTIZE (convert to color-mapped) */
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
png_bytep palette_lookup; /* lookup table for quantizing */
|
||||
png_bytep quantize_index; /* index translation for palette files */
|
||||
png_bytep quantize_sort; /* working sort array */
|
||||
png_bytep index_to_palette; /* where the original index currently is in the
|
||||
* palette
|
||||
*/
|
||||
png_bytep palette_to_index; /* which original index points to this palette
|
||||
* color
|
||||
*/
|
||||
#endif
|
||||
|
||||
/* MNG SUPPORT */
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
png_uint_32 mng_features_permitted;
|
||||
png_byte filter_type;
|
||||
#endif
|
||||
|
||||
/* Options */
|
||||
#ifdef PNG_SET_OPTION_SUPPORTED
|
||||
png_byte options; /* On/off state (up to 4 options) */
|
||||
#endif
|
||||
|
||||
/* COMPRESSION AND DECOMPRESSION SUPPORT.
|
||||
*
|
||||
* zlib expects a 'zstream' as the fundamental control structure, it allows
|
||||
* all the parameters to be passed as one pointer.
|
||||
*/
|
||||
z_stream zstream; /* decompression structure */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* New member added in libpng-1.2.30 */
|
||||
png_bytep read_buffer; /* buffer for reading chunk data */
|
||||
png_alloc_size_t read_buffer_size; /* current size of the buffer */
|
||||
/* These, and IDAT_read_size below, control how much input and output (at
|
||||
* most) is available to zlib.
|
||||
*/
|
||||
png_uint_32 idat_size; /* current IDAT size for read */
|
||||
png_alloc_size_t read_buffer_size; /* current size of the buffer */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
int zlib_text_level; /* holds zlib compression level */
|
||||
int zlib_text_method; /* holds zlib compression method */
|
||||
int zlib_text_window_bits; /* holds zlib compression window bits */
|
||||
int zlib_text_mem_level; /* holds zlib compression memory level */
|
||||
int zlib_text_strategy; /* holds zlib compression strategy */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
int zlib_level; /* holds zlib compression level */
|
||||
int zlib_method; /* holds zlib compression method */
|
||||
int zlib_window_bits; /* holds zlib compression window bits */
|
||||
int zlib_mem_level; /* holds zlib compression memory level */
|
||||
int zlib_strategy; /* holds zlib compression strategy */
|
||||
|
||||
int zlib_set_level; /* Actual values set into the zstream on write */
|
||||
int zlib_set_method;
|
||||
int zlib_set_window_bits;
|
||||
int zlib_set_mem_level;
|
||||
int zlib_set_strategy;
|
||||
|
||||
png_compression_bufferp zbuffer_list; /* Created on demand during write */
|
||||
uInt zbuffer_size; /* size of the actual zlib buffer */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
uInt IDAT_read_size; /* limit on read buffer size for IDAT */
|
||||
#endif
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
/* New member added in libpng-1.4.0 */
|
||||
png_uint_32 io_state;
|
||||
#endif
|
||||
|
||||
/* New member added in libpng-1.5.6 */
|
||||
png_bytep big_prev_row;
|
||||
|
||||
void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,
|
||||
png_bytep row, png_const_bytep prev_row);
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#if defined PNG_COLORSPACE_SUPPORTED || defined PNG_GAMMA_SUPPORTED
|
||||
png_colorspace colorspace;
|
||||
#endif
|
||||
uInt IDAT_read_size; /* limit on read buffer size for IDAT */
|
||||
#endif
|
||||
};
|
||||
#endif /* PNGSTRUCT_H */
|
||||
|
||||
47
pngtest.c
47
pngtest.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngtest.c - a simple test program to test libpng
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -43,8 +43,24 @@
|
||||
|
||||
#include "png.h"
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED /* else nothing can be done */
|
||||
#include "zlib.h"
|
||||
/* Known chunks that exist in pngtest.png must be supported or pngtest will fail
|
||||
* simply as a result of re-ordering them. This may be fixed in 1.7
|
||||
*/
|
||||
#if defined PNG_READ_SUPPORTED && /* else nothing can be done */\
|
||||
defined PNG_READ_bKGD_SUPPORTED &&\
|
||||
defined PNG_READ_cHRM_SUPPORTED &&\
|
||||
defined PNG_READ_gAMA_SUPPORTED &&\
|
||||
defined PNG_READ_oFFs_SUPPORTED &&\
|
||||
defined PNG_READ_pCAL_SUPPORTED &&\
|
||||
defined PNG_READ_pHYs_SUPPORTED &&\
|
||||
defined PNG_READ_sBIT_SUPPORTED &&\
|
||||
defined PNG_READ_sCAL_SUPPORTED &&\
|
||||
defined PNG_READ_sRGB_SUPPORTED &&\
|
||||
defined PNG_READ_tEXt_SUPPORTED &&\
|
||||
defined PNG_READ_tIME_SUPPORTED &&\
|
||||
defined PNG_READ_zTXt_SUPPORTED
|
||||
|
||||
#include PNG_ZLIB_HEADER /* defined by pnglibconf.h */
|
||||
/* Copied from pngpriv.h but only used in error messages below. */
|
||||
#ifndef PNG_ZBUF_SIZE
|
||||
# define PNG_ZBUF_SIZE 8192
|
||||
@@ -100,10 +116,6 @@ static int unsupported_chunks = 0; /* chunk unsupported by libpng in input */
|
||||
static int error_count = 0; /* count calls to png_error */
|
||||
static int warning_count = 0; /* count calls to png_warning */
|
||||
|
||||
#ifdef __TURBOC__
|
||||
#include <mem.h>
|
||||
#endif
|
||||
|
||||
/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */
|
||||
#ifndef png_jmpbuf
|
||||
# define png_jmpbuf(png_ptr) png_ptr->jmpbuf
|
||||
@@ -707,18 +719,18 @@ static int PNGCBAPI read_user_chunk_callback(png_struct *png_ptr,
|
||||
static void
|
||||
write_sTER_chunk(png_structp write_ptr)
|
||||
{
|
||||
png_byte png_sTER[5] = {115, 84, 69, 82, '\0'};
|
||||
png_byte sTER[5] = {115, 84, 69, 82, '\0'};
|
||||
|
||||
if (verbose)
|
||||
fprintf(STDERR, "\n stereo mode = %d\n", user_chunk_data.sTER_mode);
|
||||
|
||||
png_write_chunk(write_ptr, png_sTER, &user_chunk_data.sTER_mode, 1);
|
||||
png_write_chunk(write_ptr, sTER, &user_chunk_data.sTER_mode, 1);
|
||||
}
|
||||
|
||||
static void
|
||||
write_vpAg_chunk(png_structp write_ptr)
|
||||
{
|
||||
png_byte png_vpAg[5] = {118, 112, 65, 103, '\0'};
|
||||
png_byte vpAg[5] = {118, 112, 65, 103, '\0'};
|
||||
|
||||
png_byte vpag_chunk_data[9];
|
||||
|
||||
@@ -731,7 +743,7 @@ write_vpAg_chunk(png_structp write_ptr)
|
||||
png_save_uint_32(vpag_chunk_data, user_chunk_data.vpAg_width);
|
||||
png_save_uint_32(vpag_chunk_data + 4, user_chunk_data.vpAg_height);
|
||||
vpag_chunk_data[8] = user_chunk_data.vpAg_units;
|
||||
png_write_chunk(write_ptr, png_vpAg, vpag_chunk_data, 9);
|
||||
png_write_chunk(write_ptr, vpAg, vpag_chunk_data, 9);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -1173,7 +1185,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
}
|
||||
#endif
|
||||
#ifdef PNG_sCAL_SUPPORTED
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
#if defined(PNG_FLOATING_POINT_SUPPORTED) && \
|
||||
defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)
|
||||
{
|
||||
int unit;
|
||||
double scal_width, scal_height;
|
||||
@@ -1470,7 +1483,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
|
||||
|
||||
/* When the unknown vpAg/sTER chunks are written by pngtest the only way to
|
||||
* do it is to write them *before* calling png_write_end. When unknown
|
||||
* chunks are written by libpng, however, they are written just before IEND. * There seems to be no way round this, however vpAg/sTER are not expected
|
||||
* chunks are written by libpng, however, they are written just before IEND.
|
||||
* There seems to be no way round this, however vpAg/sTER are not expected
|
||||
* after IDAT.
|
||||
*/
|
||||
write_chunks(write_ptr, after_IDAT);
|
||||
@@ -1944,9 +1958,10 @@ main(void)
|
||||
{
|
||||
fprintf(STDERR,
|
||||
" test ignored because libpng was not built with read support\n");
|
||||
return 0;
|
||||
/* And skip this test */
|
||||
return 77;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef png_libpng_version_1_6_0beta33 Your_png_h_is_not_version_1_6_0beta33;
|
||||
typedef png_libpng_version_1_7_0beta15 Your_png_h_is_not_version_1_7_0beta15;
|
||||
|
||||
19
pngtrans.c
19
pngtrans.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -57,7 +57,9 @@ png_set_packing(png_structrp png_ptr)
|
||||
if (png_ptr->bit_depth < 8)
|
||||
{
|
||||
png_ptr->transformations |= PNG_PACK;
|
||||
png_ptr->usr_bit_depth = 8;
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
png_ptr->usr_bit_depth = 8;
|
||||
# endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -782,6 +784,17 @@ png_set_user_transform_info(png_structrp png_ptr, png_voidp
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
|
||||
(png_ptr->flags & PNG_FLAG_ROW_INIT) != 0)
|
||||
{
|
||||
png_app_error(png_ptr,
|
||||
"info change after png_start_read_image or png_read_update_info");
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
png_ptr->user_transform_ptr = user_transform_ptr;
|
||||
png_ptr->user_transform_depth = (png_byte)user_transform_depth;
|
||||
png_ptr->user_transform_channels = (png_byte)user_transform_channels;
|
||||
|
||||
6
pngwio.c
6
pngwio.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngwio.c - functions for data output
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -151,6 +151,7 @@ png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr,
|
||||
# endif
|
||||
#endif /* PNG_WRITE_FLUSH_SUPPORTED */
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
/* It is an error to read while writing a png file */
|
||||
if (png_ptr->read_data_fn != NULL)
|
||||
{
|
||||
@@ -160,5 +161,6 @@ png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr,
|
||||
"Can't set both read_data_fn and write_data_fn in the"
|
||||
" same structure");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif /* PNG_WRITE_SUPPORTED */
|
||||
|
||||
242
pngwrite.c
242
pngwrite.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngwrite.c - general routines to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -12,7 +12,7 @@
|
||||
*/
|
||||
|
||||
#include "pngpriv.h"
|
||||
#if defined PNG_SIMPLIFIED_WRITE_SUPPORTED && defined PNG_STDIO_SUPPORTED
|
||||
#if defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) && defined(PNG_STDIO_SUPPORTED)
|
||||
# include <errno.h>
|
||||
#endif
|
||||
|
||||
@@ -216,8 +216,13 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||
if ((png_ptr->transformations & PNG_INVERT_ALPHA) &&
|
||||
info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
int j;
|
||||
for (j = 0; j<(int)info_ptr->num_trans; j++)
|
||||
int j, jend;
|
||||
|
||||
jend = info_ptr->num_trans;
|
||||
if (jend > PNG_MAX_PALETTE_LENGTH)
|
||||
jend = PNG_MAX_PALETTE_LENGTH;
|
||||
|
||||
for (j = 0; j<jend; ++j)
|
||||
info_ptr->trans_alpha[j] =
|
||||
(png_byte)(255 - info_ptr->trans_alpha[j]);
|
||||
}
|
||||
@@ -447,7 +452,6 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||
}
|
||||
|
||||
#ifdef PNG_CONVERT_tIME_SUPPORTED
|
||||
/* "tm" structure is not supported on WindowsCE */
|
||||
void PNGAPI
|
||||
png_convert_from_struct_tm(png_timep ptime, PNG_CONST struct tm * ttime)
|
||||
{
|
||||
@@ -496,46 +500,50 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||
error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);
|
||||
#endif /* PNG_USER_MEM_SUPPORTED */
|
||||
|
||||
/* Set the zlib control values to defaults; they can be overridden by the
|
||||
* application after the struct has been created.
|
||||
*/
|
||||
png_ptr->zbuffer_size = PNG_ZBUF_SIZE;
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
/* Set the zlib control values to defaults; they can be overridden by the
|
||||
* application after the struct has been created.
|
||||
*/
|
||||
png_ptr->zbuffer_size = PNG_ZBUF_SIZE;
|
||||
|
||||
png_ptr->zlib_strategy = Z_FILTERED; /* may be overridden if no filters */
|
||||
png_ptr->zlib_level = Z_DEFAULT_COMPRESSION;
|
||||
png_ptr->zlib_mem_level = 8;
|
||||
png_ptr->zlib_window_bits = 15;
|
||||
png_ptr->zlib_method = 8;
|
||||
/* The 'zlib_strategy' setting is irrelevant because png_default_claim in
|
||||
* pngwutil.c defaults it according to whether or not filters will be
|
||||
* used, and ignores this setting.
|
||||
*/
|
||||
png_ptr->zlib_strategy = PNG_Z_DEFAULT_STRATEGY;
|
||||
png_ptr->zlib_level = PNG_Z_DEFAULT_COMPRESSION;
|
||||
png_ptr->zlib_mem_level = 8;
|
||||
png_ptr->zlib_window_bits = 15;
|
||||
png_ptr->zlib_method = 8;
|
||||
|
||||
#ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
|
||||
png_ptr->zlib_text_strategy = Z_DEFAULT_STRATEGY;
|
||||
png_ptr->zlib_text_level = Z_DEFAULT_COMPRESSION;
|
||||
png_ptr->zlib_text_mem_level = 8;
|
||||
png_ptr->zlib_text_window_bits = 15;
|
||||
png_ptr->zlib_text_method = 8;
|
||||
png_ptr->zlib_text_strategy = PNG_TEXT_Z_DEFAULT_STRATEGY;
|
||||
png_ptr->zlib_text_level = PNG_TEXT_Z_DEFAULT_COMPRESSION;
|
||||
png_ptr->zlib_text_mem_level = 8;
|
||||
png_ptr->zlib_text_window_bits = 15;
|
||||
png_ptr->zlib_text_method = 8;
|
||||
#endif /* PNG_WRITE_COMPRESSED_TEXT_SUPPORTED */
|
||||
|
||||
/* This is a highly dubious configuration option; by default it is off, but
|
||||
* it may be appropriate for private builds that are testing extensions not
|
||||
* conformant to the current specification, or of applications that must not
|
||||
* fail to write at all costs!
|
||||
*/
|
||||
# ifdef PNG_BENIGN_WRITE_ERRORS_SUPPORTED
|
||||
/* This is a highly dubious configuration option; by default it is off,
|
||||
* but it may be appropriate for private builds that are testing
|
||||
* extensions not conformant to the current specification, or of
|
||||
* applications that must not fail to write at all costs!
|
||||
*/
|
||||
#ifdef PNG_BENIGN_WRITE_ERRORS_SUPPORTED
|
||||
png_ptr->flags |= PNG_FLAG_BENIGN_ERRORS_WARN;
|
||||
/* In stable builds only warn if an application error can be completely
|
||||
* handled.
|
||||
*/
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* App warnings are warnings in release (or release candidate) builds but
|
||||
* are errors during development.
|
||||
*/
|
||||
# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
|
||||
png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;
|
||||
# endif
|
||||
/* App warnings are warnings in release (or release candidate) builds but
|
||||
* are errors during development.
|
||||
*/
|
||||
#if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
|
||||
png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;
|
||||
#endif
|
||||
|
||||
if (png_ptr != NULL)
|
||||
{
|
||||
/* TODO: delay this, it can be done in png_init_io() (if the app doesn't
|
||||
* do it itself) avoiding setting the default function if it is not
|
||||
* required.
|
||||
@@ -927,42 +935,52 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
||||
if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
|
||||
(method == PNG_INTRAPIXEL_DIFFERENCING))
|
||||
method = PNG_FILTER_TYPE_BASE;
|
||||
|
||||
#endif
|
||||
if (method == PNG_FILTER_TYPE_BASE)
|
||||
{
|
||||
switch (filters & (PNG_ALL_FILTERS | 0x07))
|
||||
|
||||
/* The only supported method, except for the check above, is
|
||||
* PNG_FILTER_TYPE_BASE. The code below does not use 'method' other than
|
||||
* for the check, so just keep going if png_app_error returns.
|
||||
*/
|
||||
if (method != PNG_FILTER_TYPE_BASE)
|
||||
png_app_error(png_ptr, "Unknown custom filter method");
|
||||
|
||||
/* If filter writing is not supported the 'filters' value must be zero,
|
||||
* otherwise the value must be a single, valid, filter value or a set of the
|
||||
* mask values. The defines in png.h are such that the filter masks used in
|
||||
* this API and internally are 1<<(3+value), value is in the range 0..4, so
|
||||
* this fits in a byte.
|
||||
*/
|
||||
# ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
/* Notice that PNG_NO_FILTERS is 0 and passes this test; this is OK
|
||||
* because filters then gets set to PNG_FILTER_NONE, as is required.
|
||||
*/
|
||||
if (filters < PNG_FILTER_VALUE_LAST)
|
||||
filters = 0x08 << filters;
|
||||
|
||||
else if ((filters & ~PNG_ALL_FILTERS) != 0)
|
||||
{
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
case 5:
|
||||
case 6:
|
||||
case 7: png_app_error(png_ptr, "Unknown row filter for method 0");
|
||||
/* FALL THROUGH */
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
case PNG_FILTER_VALUE_NONE:
|
||||
png_ptr->do_filter = PNG_FILTER_NONE; break;
|
||||
png_app_error(png_ptr, "png_set_filter: invalid filters mask/value");
|
||||
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
case PNG_FILTER_VALUE_SUB:
|
||||
png_ptr->do_filter = PNG_FILTER_SUB; break;
|
||||
/* For compatibility with the previous behavior assume a mask value was
|
||||
* passed and ignore the non-mask bits.
|
||||
*/
|
||||
filters &= PNG_ALL_FILTERS;
|
||||
|
||||
case PNG_FILTER_VALUE_UP:
|
||||
png_ptr->do_filter = PNG_FILTER_UP; break;
|
||||
|
||||
case PNG_FILTER_VALUE_AVG:
|
||||
png_ptr->do_filter = PNG_FILTER_AVG; break;
|
||||
|
||||
case PNG_FILTER_VALUE_PAETH:
|
||||
png_ptr->do_filter = PNG_FILTER_PAETH; break;
|
||||
|
||||
default:
|
||||
png_ptr->do_filter = (png_byte)filters; break;
|
||||
#else
|
||||
default:
|
||||
png_app_error(png_ptr, "Unknown row filter for method 0");
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
/* For a possibly foolish consistency (it shouldn't matter) set
|
||||
* PNG_FILTER_NONE rather than 0.
|
||||
*/
|
||||
if (filters == 0)
|
||||
filters = PNG_FILTER_NONE;
|
||||
}
|
||||
# else
|
||||
/* PNG_FILTER_VALUE_NONE and PNG_NO_FILTERS are both 0. */
|
||||
if (filters != 0 && filters != PNG_FILTER_NONE)
|
||||
png_app_error(png_ptr, "png_set_filter: no filters supported");
|
||||
|
||||
filters = PNG_FILTER_NONE;
|
||||
# endif
|
||||
|
||||
# ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
/* If we have allocated the row_buf, this means we have already started
|
||||
* with the image and we should have allocated all of the filter buffers
|
||||
* that have been selected. If prev_row isn't already allocated, then
|
||||
@@ -971,75 +989,45 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
||||
* wants to start and stop using particular filters during compression,
|
||||
* it should start out with all of the filters, and then add and
|
||||
* remove them after the start of compression.
|
||||
*
|
||||
* NOTE: this is a nasty constraint on the code, because it means that the
|
||||
* prev_row buffer must be maintained even if there are currently no
|
||||
* 'prev_row' requiring filters active.
|
||||
*/
|
||||
if (png_ptr->row_buf != NULL)
|
||||
{
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
if ((png_ptr->do_filter & PNG_FILTER_SUB) && png_ptr->sub_row == NULL)
|
||||
/* Repeat the checks in png_write_start_row; 1 pixel high or wide
|
||||
* images cannot benefit from certain filters. If this isn't done here
|
||||
* the check below will fire on 1 pixel high images.
|
||||
*/
|
||||
if (png_ptr->height == 1)
|
||||
filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH);
|
||||
|
||||
if (png_ptr->width == 1)
|
||||
filters &= ~(PNG_FILTER_SUB|PNG_FILTER_AVG|PNG_FILTER_PAETH);
|
||||
|
||||
if ((filters & (PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH)) != 0
|
||||
&& png_ptr->prev_row == NULL)
|
||||
{
|
||||
png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,
|
||||
(png_ptr->rowbytes + 1));
|
||||
png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
|
||||
/* This is the error case, however it is benign - the previous row
|
||||
* is not available so the filter can't be used. Just warn here.
|
||||
*/
|
||||
png_app_warning(png_ptr,
|
||||
"png_set_filter: UP/AVG/PAETH cannot be added after start");
|
||||
filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH);
|
||||
}
|
||||
|
||||
if ((png_ptr->do_filter & PNG_FILTER_UP) && png_ptr->up_row == NULL)
|
||||
{
|
||||
if (png_ptr->prev_row == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Can't add Up filter after starting");
|
||||
png_ptr->do_filter = (png_byte)(png_ptr->do_filter &
|
||||
~PNG_FILTER_UP);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
|
||||
(png_ptr->rowbytes + 1));
|
||||
png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
|
||||
}
|
||||
}
|
||||
|
||||
if ((png_ptr->do_filter & PNG_FILTER_AVG) && png_ptr->avg_row == NULL)
|
||||
{
|
||||
if (png_ptr->prev_row == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Can't add Average filter after starting");
|
||||
png_ptr->do_filter = (png_byte)(png_ptr->do_filter &
|
||||
~PNG_FILTER_AVG);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
|
||||
(png_ptr->rowbytes + 1));
|
||||
png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
|
||||
}
|
||||
}
|
||||
|
||||
if ((png_ptr->do_filter & PNG_FILTER_PAETH) &&
|
||||
png_ptr->paeth_row == NULL)
|
||||
{
|
||||
if (png_ptr->prev_row == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Can't add Paeth filter after starting");
|
||||
png_ptr->do_filter &= (png_byte)(~PNG_FILTER_PAETH);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,
|
||||
(png_ptr->rowbytes + 1));
|
||||
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
|
||||
}
|
||||
}
|
||||
|
||||
if (png_ptr->do_filter == PNG_NO_FILTERS)
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
png_ptr->do_filter = PNG_FILTER_NONE;
|
||||
/* Allocate any required buffers that have not already been allocated.
|
||||
*/
|
||||
png_write_alloc_filter_row_buffers(png_ptr, filters);
|
||||
}
|
||||
}
|
||||
else
|
||||
png_error(png_ptr, "Unknown custom filter method");
|
||||
# endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
|
||||
/* Finally store the value.
|
||||
* TODO: this field could probably be removed if neither READ nor
|
||||
* WRITE_FILTER are supported.
|
||||
*/
|
||||
png_ptr->do_filter = (png_byte)filters; /* SAFE: checked above */
|
||||
}
|
||||
|
||||
/* This allows us to influence the way in which libpng chooses the "best"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
||||
130
pngwutil.c
130
pngwutil.c
@@ -1,8 +1,8 @@
|
||||
|
||||
/* pngwutil.c - utilities to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2012 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
@@ -338,10 +338,10 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
|
||||
strategy = png_ptr->zlib_strategy;
|
||||
|
||||
else if (png_ptr->do_filter != PNG_FILTER_NONE)
|
||||
strategy = Z_FILTERED;
|
||||
strategy = PNG_Z_DEFAULT_STRATEGY;
|
||||
|
||||
else
|
||||
strategy = Z_DEFAULT_STRATEGY;
|
||||
strategy = PNG_Z_DEFAULT_NOFILTER_STRATEGY;
|
||||
}
|
||||
|
||||
else
|
||||
@@ -1425,10 +1425,11 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
|
||||
|
||||
if (color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
if (num_trans <= 0 || num_trans > (int)png_ptr->num_palette)
|
||||
if (num_trans <= 0 || num_trans > png_ptr->num_palette)
|
||||
{
|
||||
png_app_warning(png_ptr,
|
||||
"Invalid number of transparent colors specified");
|
||||
/* This is an error which can only be reliably detected late. */
|
||||
png_app_error(png_ptr,
|
||||
"Invalid number of transparent colors specified");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1442,7 +1443,8 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
|
||||
/* One 16 bit value */
|
||||
if (tran->gray >= (1 << png_ptr->bit_depth))
|
||||
{
|
||||
png_app_warning(png_ptr,
|
||||
/* This can no longer happen because it is checked in png_set_tRNS */
|
||||
png_app_error(png_ptr,
|
||||
"Ignoring attempt to write tRNS chunk out-of-range for bit_depth");
|
||||
|
||||
return;
|
||||
@@ -1464,7 +1466,8 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
|
||||
if (buf[0] | buf[2] | buf[4])
|
||||
#endif
|
||||
{
|
||||
png_app_warning(png_ptr,
|
||||
/* Also checked in png_set_tRNS */
|
||||
png_app_error(png_ptr,
|
||||
"Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8");
|
||||
return;
|
||||
}
|
||||
@@ -1474,7 +1477,8 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
|
||||
|
||||
else
|
||||
{
|
||||
png_app_warning(png_ptr, "Can't write tRNS with an alpha channel");
|
||||
/* Checked in png_set_tRNS */
|
||||
png_app_error(png_ptr, "Can't write tRNS with an alpha channel");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1744,6 +1748,9 @@ png_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key,
|
||||
{
|
||||
if (comp.input_len > PNG_UINT_31_MAX-prefix_len)
|
||||
png_error(png_ptr, "iTXt: uncompressed text too long");
|
||||
|
||||
/* So the string will fit in a chunk: */
|
||||
comp.output_len = (png_uint_32)/*SAFE*/comp.input_len;
|
||||
}
|
||||
|
||||
png_write_chunk_header(png_ptr, png_iTXt, comp.output_len + prefix_len);
|
||||
@@ -1758,7 +1765,7 @@ png_write_iTXt(png_structrp png_ptr, int compression, png_const_charp key,
|
||||
png_write_compressed_data_out(png_ptr, &comp);
|
||||
|
||||
else
|
||||
png_write_chunk_data(png_ptr, (png_const_bytep)text, comp.input_len);
|
||||
png_write_chunk_data(png_ptr, (png_const_bytep)text, comp.output_len);
|
||||
|
||||
png_write_chunk_end(png_ptr);
|
||||
}
|
||||
@@ -1931,6 +1938,47 @@ png_write_tIME(png_structrp png_ptr, png_const_timep mod_time)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
png_write_alloc_filter_row_buffers(png_structrp png_ptr, int filters)
|
||||
/* Allocate row buffers for any filters that need them, this is also called
|
||||
* from png_set_filter if the filters are changed during write to ensure that
|
||||
* the required buffers exist. png_set_filter ensures that up/avg/paeth are
|
||||
* only set if png_ptr->prev_row is allocated.
|
||||
*/
|
||||
{
|
||||
/* The buffer size is determined just by the output row size, not any
|
||||
* processing requirements.
|
||||
*/
|
||||
png_alloc_size_t buf_size = png_ptr->rowbytes + 1;
|
||||
|
||||
if ((filters & PNG_FILTER_SUB) != 0 && png_ptr->sub_row == NULL)
|
||||
{
|
||||
png_ptr->sub_row = png_voidcast(png_bytep, png_malloc(png_ptr, buf_size));
|
||||
png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
|
||||
}
|
||||
|
||||
if ((filters & PNG_FILTER_UP) != 0 && png_ptr->up_row == NULL)
|
||||
{
|
||||
png_ptr->up_row = png_voidcast(png_bytep, png_malloc(png_ptr, buf_size));
|
||||
png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
|
||||
}
|
||||
|
||||
if ((filters & PNG_FILTER_AVG) != 0 && png_ptr->avg_row == NULL)
|
||||
{
|
||||
png_ptr->avg_row = png_voidcast(png_bytep, png_malloc(png_ptr, buf_size));
|
||||
png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
|
||||
}
|
||||
|
||||
if ((filters & PNG_FILTER_PAETH) != 0 && png_ptr->paeth_row == NULL)
|
||||
{
|
||||
png_ptr->paeth_row = png_voidcast(png_bytep, png_malloc(png_ptr,
|
||||
buf_size));
|
||||
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
|
||||
}
|
||||
}
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
|
||||
/* Initializes the row writing capability of libpng */
|
||||
void /* PRIVATE */
|
||||
png_write_start_row(png_structrp png_ptr)
|
||||
@@ -1951,11 +1999,18 @@ png_write_start_row(png_structrp png_ptr)
|
||||
static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
int filters;
|
||||
#endif
|
||||
|
||||
png_alloc_size_t buf_size;
|
||||
int usr_pixel_depth;
|
||||
|
||||
png_debug(1, "in png_write_start_row");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
usr_pixel_depth = png_ptr->usr_channels * png_ptr->usr_bit_depth;
|
||||
buf_size = PNG_ROWBYTES(usr_pixel_depth, png_ptr->width) + 1;
|
||||
|
||||
@@ -1964,49 +2019,34 @@ png_write_start_row(png_structrp png_ptr)
|
||||
png_ptr->maximum_pixel_depth = (png_byte)usr_pixel_depth;
|
||||
|
||||
/* Set up row buffer */
|
||||
png_ptr->row_buf = (png_bytep)png_malloc(png_ptr, buf_size);
|
||||
png_ptr->row_buf = png_voidcast(png_bytep, png_malloc(png_ptr, buf_size));
|
||||
|
||||
png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE;
|
||||
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
/* Set up filtering buffer, if using this filter */
|
||||
if (png_ptr->do_filter & PNG_FILTER_SUB)
|
||||
{
|
||||
png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, png_ptr->rowbytes + 1);
|
||||
filters = png_ptr->do_filter;
|
||||
|
||||
png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
|
||||
}
|
||||
if (png_ptr->height == 1)
|
||||
filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH);
|
||||
|
||||
/* We only need to keep the previous row if we are using one of these. */
|
||||
if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH))
|
||||
{
|
||||
/* Set up previous row buffer */
|
||||
png_ptr->prev_row = (png_bytep)png_calloc(png_ptr, buf_size);
|
||||
if (png_ptr->width == 1)
|
||||
filters &= ~(PNG_FILTER_SUB|PNG_FILTER_AVG|PNG_FILTER_PAETH);
|
||||
|
||||
if (png_ptr->do_filter & PNG_FILTER_UP)
|
||||
{
|
||||
png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
|
||||
png_ptr->rowbytes + 1);
|
||||
if (filters == 0)
|
||||
filters = PNG_FILTER_NONE;
|
||||
|
||||
png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
|
||||
}
|
||||
/* We only need to keep the previous row if we are using one of the following
|
||||
* filters.
|
||||
*/
|
||||
if (filters & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH))
|
||||
png_ptr->prev_row = png_voidcast(png_bytep, png_calloc(png_ptr,
|
||||
buf_size));
|
||||
|
||||
if (png_ptr->do_filter & PNG_FILTER_AVG)
|
||||
{
|
||||
png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
|
||||
png_ptr->rowbytes + 1);
|
||||
png_write_alloc_filter_row_buffers(png_ptr, filters);
|
||||
|
||||
png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
|
||||
}
|
||||
|
||||
if (png_ptr->do_filter & PNG_FILTER_PAETH)
|
||||
{
|
||||
png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,
|
||||
png_ptr->rowbytes + 1);
|
||||
|
||||
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
|
||||
}
|
||||
}
|
||||
png_ptr->do_filter = (png_byte)filters; /* in case it was changed above */
|
||||
#else
|
||||
png_ptr->do_filter = PNG_FILTER_NONE;
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
|
||||
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
|
||||
@@ -2994,6 +3034,7 @@ png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
|
||||
|
||||
png_compress_IDAT(png_ptr, filtered_row, full_row_length, Z_NO_FLUSH);
|
||||
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
/* Swap the current and previous rows */
|
||||
if (png_ptr->prev_row != NULL)
|
||||
{
|
||||
@@ -3003,6 +3044,7 @@ png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
|
||||
png_ptr->prev_row = png_ptr->row_buf;
|
||||
png_ptr->row_buf = tptr;
|
||||
}
|
||||
#endif /* PNG_WRITE_FILTER_SUPPORTED */
|
||||
|
||||
/* Finish row - updates counters and flushes zlib if last row */
|
||||
png_write_finish_row(png_ptr);
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/libpng16.dll"
|
||||
OutputFile="$(OutDir)/libpng17.dll"
|
||||
LinkIncremental="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
@@ -78,7 +78,7 @@
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/libpng16d.dll"
|
||||
OutputFile="$(OutDir)/libpng17d.dll"
|
||||
GenerateDebugInformation="TRUE"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
@@ -126,7 +126,7 @@
|
||||
Name="VCCustomBuildTool"/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/libpng16vb.dll"
|
||||
OutputFile="$(OutDir)/libpng17vb.dll"
|
||||
LinkIncremental="1"/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"/>
|
||||
|
||||
@@ -130,7 +130,7 @@ $(TargetPath) ..\..\pngtest.png $(IntDir)\pngout.png"
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(OutDir)/pngtest.exe"
|
||||
LinkIncremental="1"
|
||||
IgnoreDefaultLibraryNames="$(IntDir)\libpng16b.lib"
|
||||
IgnoreDefaultLibraryNames="$(IntDir)\libpng17b.lib"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"/>
|
||||
<Tool
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>libpng</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<Import Project="$(SolutionDir)\zlib.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
@@ -63,23 +63,23 @@
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<CustomBuildBeforeTargets>
|
||||
</CustomBuildBeforeTargets>
|
||||
<TargetName>$(ProjectName)16</TargetName>
|
||||
<TargetName>$(ProjectName)17</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Library|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<CustomBuildBeforeTargets />
|
||||
<TargetName>$(ProjectName)16</TargetName>
|
||||
<TargetName>$(ProjectName)17</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<CustomBuildBeforeTargets>
|
||||
</CustomBuildBeforeTargets>
|
||||
<TargetName>$(ProjectName)16</TargetName>
|
||||
<TargetName>$(ProjectName)17</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Library|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<CustomBuildBeforeTargets />
|
||||
<TargetName>$(ProjectName)16</TargetName>
|
||||
<TargetName>$(ProjectName)17</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
@@ -107,7 +107,7 @@
|
||||
<SubSystem>Windows</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>zlib.lib</AdditionalDependencies>
|
||||
<Version>16</Version>
|
||||
<Version>17</Version>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
@@ -164,7 +164,7 @@
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>zlib.lib</AdditionalDependencies>
|
||||
<Version>16</Version>
|
||||
<Version>17</Version>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(SolutionDir)\zlib.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>pngstest</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<Import Project="$(SolutionDir)\zlib.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
@@ -96,7 +96,7 @@
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>libpng17.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
@@ -129,7 +129,7 @@
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
@@ -163,7 +163,7 @@
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>libpng17.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
</Link>
|
||||
@@ -199,7 +199,7 @@
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
</Link>
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>pngtest</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<Import Project="$(SolutionDir)\zlib.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
@@ -96,7 +96,7 @@
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>libpng16.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>libpng17.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
@@ -129,7 +129,7 @@
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
@@ -164,7 +164,7 @@
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
<AdditionalDependencies>libpng16.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>libpng17.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
@@ -199,7 +199,7 @@
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>pngunknown</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<Import Project="$(SolutionDir)\zlib.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
@@ -96,7 +96,7 @@
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>libpng17.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
@@ -129,7 +129,7 @@
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
@@ -163,7 +163,7 @@
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>libpng17.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
</Link>
|
||||
@@ -199,7 +199,7 @@
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
</Link>
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>pngvalid</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<Import Project="$(SolutionDir)\zlib.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
@@ -96,7 +96,7 @@
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
@@ -129,7 +129,7 @@
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
</Link>
|
||||
<CustomBuildStep>
|
||||
@@ -163,7 +163,7 @@
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
</Link>
|
||||
@@ -199,7 +199,7 @@
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
|
||||
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
|
||||
</Link>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
|
||||
VisualStudio instructions
|
||||
|
||||
libpng version 1.6.0beta33 - December 10, 2012
|
||||
libpng version 1.7.0beta15 - June 18, 2013
|
||||
|
||||
Copyright (c) 1998-2010 Glenn Randers-Pehrson
|
||||
|
||||
@@ -40,7 +40,7 @@ problems.
|
||||
|
||||
If you don't use the Visual Studio defaults your application must still be built
|
||||
with the default runtime option (/MD). If, for some reason, it is not then your
|
||||
application will crash inside libpng16.dll as soon as libpng tries to read
|
||||
application will crash inside libpng17.dll as soon as libpng tries to read
|
||||
from a file handle you pass in.
|
||||
|
||||
If you do not want to use the DLL, for example for a very small application,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<!--
|
||||
* zlib.props - location of zlib source
|
||||
*
|
||||
* libpng version 1.6.0beta33 - December 10, 2012
|
||||
* libpng version 1.7.0beta15 - June 18, 2013
|
||||
*
|
||||
* Copyright (c) 1998-2011 Glenn Randers-Pehrson
|
||||
*
|
||||
@@ -33,5 +33,13 @@
|
||||
below:
|
||||
-->
|
||||
<ZLibSrcDir>..\..\..\..\zlib-1.2.5</ZLibSrcDir>
|
||||
|
||||
<!-- The following line allows compilation for an ARM target with Visual
|
||||
Studio 2012. Notice that this is not supported by the Visual Studio
|
||||
2012 IDE and that the programs that result cannot be run unless they
|
||||
signed by Microsoft. This is therefore untested; only Microsoft can
|
||||
test it:
|
||||
-->
|
||||
<WindowsSDKDesktopARMSupport>true</WindowsSDKDesktopARMSupport>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
|
||||
@@ -36,8 +36,8 @@
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>zlib</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<Import Project="$(SolutionDir)\zlib.props" />
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Library|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
|
||||
Makefiles for libpng version 1.6.0beta33 - December 10, 2012
|
||||
Makefiles for libpng version 1.7.0beta15 - June 18, 2013
|
||||
|
||||
pnglibconf.h.prebuilt => Stores configuration settings
|
||||
makefile.linux => Linux/ELF makefile
|
||||
(gcc, creates libpng16.so.16.1.6.0beta33)
|
||||
(gcc, creates libpng17.so.17.1.7.0beta15)
|
||||
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
|
||||
makefile.knr => Archaic UNIX Makefile that converts files with
|
||||
ansi2knr (Requires ansi2knr.c from
|
||||
@@ -20,7 +20,7 @@ pnglibconf.h.prebuilt => Stores configuration settings
|
||||
makefile.dec => DEC Alpha UNIX makefile
|
||||
makefile.dj2 => DJGPP 2 makefile
|
||||
makefile.elf => Linux/ELF makefile symbol versioning,
|
||||
(gcc, creates libpng16.so.16.1.6.0beta33)
|
||||
(gcc, creates libpng17.so.17.1.7.0beta15)
|
||||
makefile.freebsd => FreeBSD makefile
|
||||
makefile.gcc => Generic gcc makefile
|
||||
makefile.hpgcc => HPUX makefile using gcc
|
||||
@@ -35,12 +35,12 @@ pnglibconf.h.prebuilt => Stores configuration settings
|
||||
makefile.os2 => OS/2 Makefile (gcc and emx, requires libpng.def)
|
||||
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
|
||||
makefile.sggcc => Silicon Graphics (gcc,
|
||||
creates libpng16.so.16.1.6.0beta33)
|
||||
creates libpng17.so.17.1.7.0beta15)
|
||||
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
|
||||
makefile.solaris => Solaris 2.X makefile (gcc,
|
||||
creates libpng16.so.16.1.6.0beta33)
|
||||
creates libpng17.so.17.1.7.0beta15)
|
||||
makefile.so9 => Solaris 9 makefile (gcc,
|
||||
creates libpng16.so.16.1.6.0beta33)
|
||||
creates libpng17.so.17.1.7.0beta15)
|
||||
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
|
||||
makefile.sunos => Sun makefile
|
||||
makefile.32sunu => Sun Ultra 32-bit makefile
|
||||
|
||||
@@ -113,6 +113,16 @@ END{
|
||||
err = 1
|
||||
}
|
||||
unexported=0
|
||||
# Add a standard header to symbols.new:
|
||||
print ";Version INSERT-VERSION-HERE" >of
|
||||
print ";--------------------------------------------------------------" >of
|
||||
print "; LIBPNG symbol list as a Win32 DEF file" >of
|
||||
print "; Contains all the symbols that can be exported from libpng" >of
|
||||
print ";--------------------------------------------------------------" >of
|
||||
print "LIBRARY" >of
|
||||
print "" >of
|
||||
print "EXPORTS" >of
|
||||
|
||||
for (o=1; o<=lasto; ++o) {
|
||||
if (symbol[o] == "" && removed[o] == "") {
|
||||
if (unexported == 0) unexported = o
|
||||
|
||||
@@ -8,31 +8,22 @@
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
/* These macros exist to make the header and trailer shorter below: */
|
||||
#define S PNG_DEFN_MAGIC
|
||||
#define E PNG_DEFN_END
|
||||
|
||||
/* Write the export file header: */
|
||||
S-;---------------------------------------------------------------E
|
||||
S-; LIBPNG module definition file for OS/2-E
|
||||
S-;---------------------------------------------------------------E
|
||||
S--E
|
||||
S-; If you give the library an explicit name one or other files-E
|
||||
S-; may need modifying to support the new name on one or more-E
|
||||
S-; systems.-E
|
||||
S-LIBRARY-E
|
||||
S-OS2 DESCRIPTION "PNG image compression library"-E
|
||||
S-OS2 CODE PRELOAD MOVEABLE DISCARDABLE-E
|
||||
S--E
|
||||
S-EXPORTS-E
|
||||
S-;Version 1.5.0beta58-E
|
||||
PNG_DFN ";--------------------------------------------------------------"
|
||||
PNG_DFN "; LIBPNG module definition file for OS/2"
|
||||
PNG_DFN ";--------------------------------------------------------------"
|
||||
PNG_DFN ""
|
||||
PNG_DFN "; If you give the library an explicit name one or other files"
|
||||
PNG_DFN "; may need modifying to support the new name on one or more"
|
||||
PNG_DFN "; systems."
|
||||
PNG_DFN "LIBRARY"
|
||||
PNG_DFN "OS2 DESCRIPTION "PNG image compression library""
|
||||
PNG_DFN "OS2 CODE PRELOAD MOVEABLE DISCARDABLE"
|
||||
PNG_DFN ""
|
||||
PNG_DFN "EXPORTS"
|
||||
PNG_DFN ";Version 1.7.0beta15"
|
||||
|
||||
/* NOTE: PNG_JOIN is interpreted by the calling script as a signal to
|
||||
* join the two things on either side, so we can do symbol
|
||||
* substitution within the name, regular C ## joins the pp-tokens,
|
||||
* not their final values.
|
||||
*/
|
||||
#define PNG_EXPORTA(ordinal, type, name, args, attributes)\
|
||||
PNG_DEFN_MAGIC- SYMBOL_PREFIX PNG_JOIN name-PNG_DEFN_END
|
||||
PNG_DFN "@" SYMBOL_PREFIX "@@" name "@"
|
||||
|
||||
#include "../png.h"
|
||||
|
||||
203
scripts/dfn.awk
Normal file
203
scripts/dfn.awk
Normal file
@@ -0,0 +1,203 @@
|
||||
#!/bin/awk -f
|
||||
# scripts/dfn.awk - process a .dfn file
|
||||
#
|
||||
# last changed in libpng version 1.5.14 - February 4, 2013
|
||||
#
|
||||
# Copyright (c) 2013-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
|
||||
|
||||
# The output of this script is written to the file given by
|
||||
# the variable 'out', which should be set on the command line.
|
||||
# Error messages are printed to stdout and if any are printed
|
||||
# the script will exit with error code 1.
|
||||
|
||||
BEGIN{
|
||||
out="/dev/null" # as a flag
|
||||
out_count=0 # count of output lines
|
||||
err=0 # set if an error occured
|
||||
sort=0 # sort the output
|
||||
array[""]=""
|
||||
}
|
||||
|
||||
# The output file must be specified before any input:
|
||||
NR==1 && out == "/dev/null" {
|
||||
print "out=output.file must be given on the command line"
|
||||
# but continue without setting the error code, this allows the
|
||||
# script to be checked easily
|
||||
}
|
||||
|
||||
# Output can be sorted; two lines are recognized
|
||||
$1 == "PNG_DFN_START_SORT"{
|
||||
sort=0+$2
|
||||
next
|
||||
}
|
||||
|
||||
$1 ~ /^PNG_DFN_END_SORT/{
|
||||
# Do a very simple, slow, sort; notice that blank lines won't be
|
||||
# output by this
|
||||
for (entry in array) {
|
||||
while (array[entry] != "") {
|
||||
key = entry
|
||||
value = array[key]
|
||||
array[key] = ""
|
||||
|
||||
for (alt in array) {
|
||||
if (array[alt] != "" && alt < key) {
|
||||
array[key] = value
|
||||
value = array[alt]
|
||||
key = alt
|
||||
array[alt] = ""
|
||||
}
|
||||
}
|
||||
|
||||
print value >out
|
||||
}
|
||||
}
|
||||
sort=0
|
||||
next
|
||||
}
|
||||
|
||||
/^[^"]*PNG_DFN *".*"[^"]*$/{
|
||||
# A definition line, apparently correctly formated, extract the
|
||||
# definition then replace any doubled "" that remain with a single
|
||||
# double quote. Notice that the original doubled double quotes
|
||||
# may have been split by tokenization
|
||||
#
|
||||
# Sometimes GCC splits the PNG_DFN lines, we know this has happened
|
||||
# if the quotes aren't closed and must read another line. In this
|
||||
# case it is essential to reject lines that start '#' because those
|
||||
# are introduced #line directives.
|
||||
orig=$0
|
||||
line=$0
|
||||
lineno=FNR
|
||||
if (lineno == "") lineno=NR
|
||||
|
||||
if (sub(/^[^"]*PNG_DFN *"/,"",line) != 1) {
|
||||
print "line", lineno ": processing failed:"
|
||||
print orig
|
||||
err=1
|
||||
next
|
||||
} else {
|
||||
++out_count
|
||||
}
|
||||
|
||||
# Now examine quotes within the value:
|
||||
#
|
||||
# @" - delete this and any following spaces
|
||||
# "@ - delete this and any preceding spaces
|
||||
# @' - replace this by a double quote
|
||||
#
|
||||
# This allows macro substitution by the C compiler thus:
|
||||
#
|
||||
# #define first_name John
|
||||
# #define last_name Smith
|
||||
#
|
||||
# PNG_DFN"#define name @'@" first_name "@ @" last_name "@@'"
|
||||
#
|
||||
# Might get C preprocessed to:
|
||||
#
|
||||
# PNG_DFN "#define foo @'@" John "@ @" Smith "@@'"
|
||||
#
|
||||
# Which this script reduces to:
|
||||
#
|
||||
# #define name "John Smith"
|
||||
#
|
||||
while (1) {
|
||||
# While there is an @" remove it and the next "@
|
||||
if (line ~ /@"/) {
|
||||
if (line ~ /@".*"@/) {
|
||||
# Do this special case first to avoid swallowing extra spaces
|
||||
# before or after the @ stuff:
|
||||
if (!sub(/@" *"@/, "", line)) {
|
||||
# Ok, do it in pieces - there has to be a non-space between the
|
||||
# two. NOTE: really weird things happen if a leading @" is
|
||||
# lost - the code will error out below (I believe).
|
||||
if (!sub(/@" */, "", line) || !sub(/ *"@/, "", line)) {
|
||||
print "line", lineno, ": internal error:", orig
|
||||
exit 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# There is no matching "@. Assume a split line
|
||||
else while (1) {
|
||||
if (getline nextline) {
|
||||
# If the line starts with '#' it is a preprocesor line directive
|
||||
# from cc -E, skip it:
|
||||
if (nextline !~ /^#/) {
|
||||
line = line " " nextline
|
||||
break
|
||||
}
|
||||
} else {
|
||||
# This is end-of-input - probably a missig "@ on the first line:
|
||||
print "line", lineno ": unbalanced @\" ... \"@ pair"
|
||||
err=1
|
||||
next
|
||||
}
|
||||
}
|
||||
|
||||
# Keep going until all the @" have gone
|
||||
continue
|
||||
}
|
||||
|
||||
# Attempt to remove a trailing " (not preceded by '@') - if this can
|
||||
# be done stop now, if not assume a split line again
|
||||
if (sub(/"[^"]*$/, "", line))
|
||||
break
|
||||
|
||||
# Read another line
|
||||
while (1) {
|
||||
if (getline nextline) {
|
||||
if (nextline !~ /^#/) {
|
||||
line = line " " nextline
|
||||
# Go back to stripping @" "@ pairs
|
||||
break
|
||||
}
|
||||
} else {
|
||||
print "line", lineno ": unterminated PNG_DFN string"
|
||||
err=1
|
||||
next
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Put any needed double quotes in (at the end, because these would otherwise
|
||||
# interfere with the processing above.)
|
||||
gsub(/@'/,"\"", line)
|
||||
|
||||
# Remove any trailing spaces (not really required, but for
|
||||
# editorial consistency
|
||||
sub(/ *$/, "", line)
|
||||
|
||||
# Remove trailing CR
|
||||
sub(/
|
||||
$/, "", line)
|
||||
|
||||
if (sort) {
|
||||
if (split(line, parts) < sort) {
|
||||
print "line", lineno ": missing sort field:", line
|
||||
err=1
|
||||
} else
|
||||
array[parts[sort]] = line
|
||||
}
|
||||
|
||||
else
|
||||
print line >out
|
||||
next
|
||||
}
|
||||
|
||||
/PNG_DFN/{
|
||||
print "line", NR, "incorrectly formated PNG_DFN line:"
|
||||
print $0
|
||||
err = 1
|
||||
}
|
||||
|
||||
END{
|
||||
if (out_count > 0 || err > 0)
|
||||
exit err
|
||||
|
||||
print "no definition lines found"
|
||||
exit 1
|
||||
@@ -10,10 +10,10 @@
|
||||
*/
|
||||
|
||||
#define PNG_INTERNAL_DATA(type, name, array)\
|
||||
PNG_DEFN_MAGIC-name-PNG_DEFN_END
|
||||
PNG_DFN "@" name "@"
|
||||
|
||||
#define PNG_INTERNAL_FUNCTION(type, name, args, attributes)\
|
||||
PNG_DEFN_MAGIC-name-PNG_DEFN_END
|
||||
PNG_DFN "@" name "@"
|
||||
|
||||
#define PNGPREFIX_H /* self generation */
|
||||
#include "../pngpriv.h"
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
# Modeled after libxml-config.
|
||||
|
||||
version=1.6.0beta33
|
||||
version=1.7.0beta15
|
||||
prefix=""
|
||||
libdir=""
|
||||
libs=""
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@/libpng16
|
||||
includedir=@includedir@/libpng17
|
||||
|
||||
Name: libpng
|
||||
Description: Loads and saves PNG files
|
||||
Version: 1.6.0beta33
|
||||
Libs: -L${libdir} -lpng16
|
||||
Version: 1.7.0beta15
|
||||
Libs: -L${libdir} -lpng17
|
||||
Cflags: -I${includedir}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
# and license in png.h
|
||||
|
||||
# Library name:
|
||||
LIBNAME=libpng16
|
||||
PNGMAJ = 16
|
||||
LIBNAME=libpng17
|
||||
PNGMAJ = 17
|
||||
|
||||
# Shared library names:
|
||||
LIBSO=$(LIBNAME).so
|
||||
@@ -29,7 +29,7 @@ RM_F=/bin/rm -f
|
||||
SUN_CC_FLAGS=-fast -xtarget=ultra
|
||||
SUN_LD_FLAGS=-fast -xtarget=ultra
|
||||
|
||||
# where make install puts libpng.a, libpng16.so and libpng16/png.h
|
||||
# where make install puts libpng.a, libpng17.so and libpng17/png.h
|
||||
prefix=/a
|
||||
exec_prefix=$(prefix)
|
||||
|
||||
@@ -95,7 +95,7 @@ libpng.pc:
|
||||
-e s!@exec_prefix@!$(exec_prefix)! \
|
||||
-e s!@libdir@!$(LIBPATH)! \
|
||||
-e s!@includedir@!$(INCPATH)! \
|
||||
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
|
||||
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
|
||||
|
||||
libpng-config:
|
||||
( cat scripts/libpng-config-head.in; \
|
||||
@@ -106,7 +106,7 @@ libpng-config:
|
||||
echo R_opts=\"-R$(LIBPATH)\"; \
|
||||
echo ccopts=\"-xtarget=ultra\"; \
|
||||
echo ldopts=\"-xtarget=ultra\"; \
|
||||
echo libs=\"-lpng16 -lz -lm\"; \
|
||||
echo libs=\"-lpng17 -lz -lm\"; \
|
||||
cat scripts/libpng-config-body.in ) > libpng-config
|
||||
chmod +x libpng-config
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
# and license in png.h
|
||||
|
||||
# Library name:
|
||||
LIBNAME=libpng16
|
||||
PNGMAJ = 16
|
||||
LIBNAME=libpng17
|
||||
PNGMAJ = 17
|
||||
|
||||
# Shared library names:
|
||||
LIBSO=$(LIBNAME).so
|
||||
@@ -29,7 +29,7 @@ RM_F=/bin/rm -f
|
||||
SUN_CC_FLAGS=-fast -xtarget=ultra -xarch=v9
|
||||
SUN_LD_FLAGS=-fast -xtarget=ultra -xarch=v9
|
||||
|
||||
# where make install puts libpng.a, libpng16.so and libpng16/png.h
|
||||
# where make install puts libpng.a, libpng17.so and libpng17/png.h
|
||||
prefix=/a
|
||||
exec_prefix=$(prefix)
|
||||
|
||||
@@ -47,7 +47,7 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
|
||||
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
|
||||
CFLAGS=-I$(ZLIBINC) $(SUN_CC_FLAGS) \
|
||||
# $(WARNMORE) -g -DPNG_DEBUG=5
|
||||
LDFLAGS=-L. -R. $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng16 -lz -lm
|
||||
LDFLAGS=-L. -R. $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng17 -lz -lm
|
||||
|
||||
INCPATH=$(prefix)/include
|
||||
LIBPATH=$(exec_prefix)/lib
|
||||
@@ -95,7 +95,7 @@ libpng.pc:
|
||||
-e s!@exec_prefix@!$(exec_prefix)! \
|
||||
-e s!@libdir@!$(LIBPATH)! \
|
||||
-e s!@includedir@!$(INCPATH)! \
|
||||
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
|
||||
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
|
||||
|
||||
libpng-config:
|
||||
( cat scripts/libpng-config-head.in; \
|
||||
@@ -106,7 +106,7 @@ libpng-config:
|
||||
echo R_opts=\"-R$(LIBPATH)\"; \
|
||||
echo ccopts=\"-xtarget=ultra -xarch=v9\"; \
|
||||
echo ldopts=\"-xtarget=ultra -xarch=v9\"; \
|
||||
echo libs=\"-lpng16 -lz -lm\"; \
|
||||
echo libs=\"-lpng17 -lz -lm\"; \
|
||||
cat scripts/libpng-config-body.in ) > libpng-config
|
||||
chmod +x libpng-config
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ RANLIB = ranlib
|
||||
RM_F = rm -f
|
||||
LN_SF = ln -f -s
|
||||
|
||||
LIBNAME=libpng16
|
||||
PNGMAJ = 16
|
||||
LIBNAME=libpng17
|
||||
PNGMAJ = 17
|
||||
|
||||
prefix=/usr/local
|
||||
INCPATH=$(prefix)/include
|
||||
@@ -47,7 +47,7 @@ CRELEASE = -O2
|
||||
LDRELEASE = -s
|
||||
WARNMORE=-W -Wall
|
||||
CFLAGS = -I$(ZLIBINC) $(WARNMORE) $(CRELEASE)
|
||||
LDFLAGS = -L. -L$(ZLIBLIB) -lpng16 -lz -lm $(LDRELEASE)
|
||||
LDFLAGS = -L. -L$(ZLIBLIB) -lpng17 -lz -lm $(LDRELEASE)
|
||||
|
||||
# File extensions
|
||||
O=.o
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
# and license in png.h
|
||||
|
||||
# Library name:
|
||||
LIBNAME=libpng16
|
||||
PNGMAJ = 16
|
||||
LIBNAME=libpng17
|
||||
PNGMAJ = 17
|
||||
|
||||
# Shared library names:
|
||||
LIBSO=$(LIBNAME).so
|
||||
@@ -45,7 +45,7 @@ CFLAGS=-I$(ZLIBINC) -W -Wall -O1 -funroll-loops \
|
||||
# LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz
|
||||
LDFLAGS=-L. -Wl,-soname=$(LIBSOMAJ) -L$(ZLIBLIB) -lz
|
||||
|
||||
# where make install puts libpng.a, libpng16.so*, and png.h
|
||||
# where make install puts libpng.a, libpng17.so*, and png.h
|
||||
prefix=/usr/local
|
||||
exec_prefix=$(prefix)
|
||||
INCPATH=$(prefix)/include
|
||||
@@ -91,13 +91,13 @@ libpng.pc:
|
||||
-e s!@exec_prefix@!$(exec_prefix)! \
|
||||
-e s!@libdir@!$(LIBPATH)! \
|
||||
-e s!@includedir@!$(INCPATH)! \
|
||||
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
|
||||
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
|
||||
|
||||
libpng-config:
|
||||
( cat scripts/libpng-config-head.in; \
|
||||
echo prefix=\"$(prefix)\"; \
|
||||
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
|
||||
echo libs=\"-lpng16 -lz \"; \
|
||||
echo libs=\"-lpng17 -lz \"; \
|
||||
cat scripts/libpng-config-body.in ) > libpng-config
|
||||
chmod +x libpng-config
|
||||
|
||||
@@ -110,7 +110,7 @@ $(LIBSOMAJ): $(OBJSDLL)
|
||||
$(LIBSOMAJ) $(OBJSDLL) $(LDFLAGS)
|
||||
|
||||
pngtest: pngtest.o $(LIBSO)
|
||||
$(CC) -L$(ZLIBLIB) -L. -lz -lpng16 -o pngtest pngtest.o
|
||||
$(CC) -L$(ZLIBLIB) -L. -lz -lpng17 -o pngtest pngtest.o
|
||||
|
||||
test: pngtest
|
||||
./pngtest
|
||||
|
||||
@@ -22,16 +22,16 @@
|
||||
# make clean
|
||||
|
||||
VERMAJ = 1
|
||||
VERMIN = 6
|
||||
VERMIN = 7
|
||||
VERMIC = 0
|
||||
VER = $(VERMAJ).$(VERMIN).$(VERMIC)
|
||||
NAME = libpng
|
||||
PACKAGE = $(NAME)-$(VER)
|
||||
|
||||
BIN = libpng16-0.dll
|
||||
LIB = libpng16.a libpng16.dll.a libpng.a libpng.dll.a
|
||||
BIN = libpng17-0.dll
|
||||
LIB = libpng17.a libpng17.dll.a libpng.a libpng.dll.a
|
||||
INCLUDE = png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
PC = libpng16.pc libpng.pc
|
||||
PC = libpng17.pc libpng.pc
|
||||
|
||||
MANIFESTVERBIN = "Libpng-$(VER): Binary files"
|
||||
MANIFESTVERDEV = "Libpng-$(VER): Developer files"
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
|
||||
# where "make install" puts libpng.a, libpng16.dylib, png.h, pngconf.h,
|
||||
# where "make install" puts libpng.a, libpng17.dylib, png.h, pngconf.h,
|
||||
# and pnglibconf.h
|
||||
prefix=/usr/local
|
||||
exec_prefix=$(prefix)
|
||||
@@ -19,8 +19,8 @@ ZLIBLIB=/usr/lib
|
||||
ZLIBINC=/usr/include
|
||||
|
||||
# Library name:
|
||||
LIBNAME = libpng16
|
||||
PNGMAJ = 16
|
||||
LIBNAME = libpng17
|
||||
PNGMAJ = 17
|
||||
|
||||
# Shared library names:
|
||||
LIBSO=$(LIBNAME).dylib
|
||||
@@ -39,7 +39,7 @@ ARCH=-arch ppc -arch i386 -arch x86_64
|
||||
|
||||
# CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops
|
||||
CFLAGS=-I$(ZLIBINC) -W -Wall -O -funroll-loops $(ARCH)
|
||||
LDFLAGS=-L. -L$(ZLIBLIB) -lpng16 -lz $(ARCH)
|
||||
LDFLAGS=-L. -L$(ZLIBLIB) -lpng17 -lz $(ARCH)
|
||||
|
||||
INCPATH=$(prefix)/include
|
||||
LIBPATH=$(exec_prefix)/lib
|
||||
@@ -87,14 +87,14 @@ libpng.pc:
|
||||
-e s!@exec_prefix@!$(exec_prefix)! \
|
||||
-e s!@libdir@!$(LIBPATH)! \
|
||||
-e s!@includedir@!$(INCPATH)! \
|
||||
-e s!-lpng16!-lpng16\ -lz! > libpng.pc
|
||||
-e s!-lpng17!-lpng17\ -lz! > libpng.pc
|
||||
|
||||
libpng-config:
|
||||
( cat scripts/libpng-config-head.in; \
|
||||
echo prefix=\"$(prefix)\"; \
|
||||
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
|
||||
echo L_opts=\"-L$(LIBPATH)\"; \
|
||||
echo libs=\"-lpng16 -lz\"; \
|
||||
echo libs=\"-lpng17 -lz\"; \
|
||||
cat scripts/libpng-config-body.in ) > libpng-config
|
||||
chmod +x libpng-config
|
||||
|
||||
@@ -104,7 +104,7 @@ $(LIBSO): $(LIBSOMAJ)
|
||||
$(LIBSOMAJ): $(OBJSDLL)
|
||||
$(CC) -dynamiclib \
|
||||
-install_name $(LIBPATH)/$(LIBSOMAJ) \
|
||||
-current_version 16 -compatibility_version 16 \
|
||||
-current_version 17 -compatibility_version 17 \
|
||||
$(ARCH) -o $(LIBSOMAJ) \
|
||||
$(OBJSDLL) -L$(ZLIBLIB) -lz
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
# and license in png.h
|
||||
|
||||
# Library name:
|
||||
PNGMAJ = 16
|
||||
LIBNAME = libpng16
|
||||
PNGMAJ = 17
|
||||
LIBNAME = libpng17
|
||||
|
||||
# Shared library names:
|
||||
LIBSO=$(LIBNAME).so
|
||||
@@ -75,7 +75,7 @@ libpng.pc:
|
||||
-e s!@exec_prefix@!$(exec_prefix)! \
|
||||
-e s!@libdir@!$(LIBPATH)! \
|
||||
-e s!@includedir@!$(INCPATH)! \
|
||||
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
|
||||
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
|
||||
|
||||
libpng-config:
|
||||
( cat scripts/libpng-config-head.in; \
|
||||
@@ -83,7 +83,7 @@ libpng-config:
|
||||
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
|
||||
echo ccopts=\"-std\"; \
|
||||
echo L_opts=\"-L$(LIBPATH)\"; \
|
||||
echo libs=\"-lpng16 -lz -lm\"; \
|
||||
echo libs=\"-lpng17 -lz -lm\"; \
|
||||
cat scripts/libpng-config-body.in ) > libpng-config
|
||||
chmod +x libpng-config
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# makefile for libpng.a and libpng16.so on Linux ELF with gcc
|
||||
# makefile for libpng.a and libpng17.so on Linux ELF with gcc
|
||||
# Copyright (C) 1998, 1999, 2002, 2006, 2008, 2010-2011 Greg Roelofs
|
||||
# and Glenn Randers-Pehrson
|
||||
# Copyright (C) 1996, 1997 Andreas Dilger
|
||||
@@ -10,19 +10,19 @@
|
||||
# Modified for Debian by Junichi Uekawa and Josselin Mouette
|
||||
# Major modifications are:
|
||||
# * link libpng explicitly with libz and libm
|
||||
# * $(OLDSO).16 is a symlink rather than a different library
|
||||
# * $(OLDSO).17 is a symlink rather than a different library
|
||||
# * versioned symbols
|
||||
|
||||
# Library name:
|
||||
LIBNAME = libpng16
|
||||
PNGMAJ = 16
|
||||
LIBNAME = libpng17
|
||||
PNGMAJ = 17
|
||||
|
||||
# Shared library names:
|
||||
LIBSO=$(LIBNAME).so
|
||||
LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ)
|
||||
LIBSOREL=$(LIBSOMAJ).$(RELEASE)
|
||||
OLDSO=libpng.so
|
||||
OLDSOMAJ=libpng.so.16
|
||||
OLDSOMAJ=libpng.so.17
|
||||
|
||||
# Utilities:
|
||||
AR_RC=ar rc
|
||||
@@ -32,8 +32,8 @@ LN_SF=ln -sf
|
||||
RANLIB=ranlib
|
||||
RM_F=/bin/rm -f
|
||||
|
||||
# where "make install" puts libpng16.a, libpng16.so*,
|
||||
# libpng16/png.h, libpng16/pngconf.h, and libpng16/pnglibconf.h
|
||||
# where "make install" puts libpng17.a, libpng17.so*,
|
||||
# libpng17/png.h, libpng17/pngconf.h, and libpng17/pnglibconf.h
|
||||
# Prefix must be a full pathname.
|
||||
prefix=/usr/local
|
||||
exec_prefix=$(prefix)
|
||||
@@ -57,7 +57,7 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
|
||||
CFLAGS=-W -Wall -D_REENTRANT -O2 \
|
||||
$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
|
||||
|
||||
LDFLAGS=-L. -lpng16
|
||||
LDFLAGS=-L. -lpng17
|
||||
LDFLAGS_A=libpng.a -lz -lm
|
||||
LIBADDFLAGS=-lz -lm
|
||||
|
||||
@@ -108,11 +108,11 @@ libpng.pc:
|
||||
-e s!@exec_prefix@!$(exec_prefix)! \
|
||||
-e s!@libdir@!$(LIBPATH)! \
|
||||
-e s!@includedir@!$(INCPATH)! \
|
||||
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
|
||||
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
|
||||
|
||||
libpng.syms: png.h pngconf.h pnglibconf.h
|
||||
$(CC) $(CFLAGS) -E -DPNG_BUILDSYMS -DPNG_INTERNAL png.h |\
|
||||
awk -F '[\t [\\]();]' -v PNGMAJ=$(PNGMAJ) 'BEGIN{printf("PNG16_%s {global:\n",PNGMAJ)}\
|
||||
awk -F '[\t [\\]();]' -v PNGMAJ=$(PNGMAJ) 'BEGIN{printf("PNG17_%s {global:\n",PNGMAJ)}\
|
||||
{ for (i=1;i+2<=NF;++i)\
|
||||
if ($$(i)=="PNG_FUNCTION_EXPORT" && $$(i+2)=="END")\
|
||||
print $$(i+1) ";";\
|
||||
@@ -129,8 +129,8 @@ libpng-config:
|
||||
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
|
||||
echo L_opts=\"\"; \
|
||||
echo R_opts=\"\"; \
|
||||
echo libs=\"-lpng16\"; \
|
||||
echo all_libs=\"-lpng16 $(LIBADDFLAGS)\"; \
|
||||
echo libs=\"-lpng17\"; \
|
||||
echo all_libs=\"-lpng17 $(LIBADDFLAGS)\"; \
|
||||
cat scripts/libpng-config-body.in ) > libpng-config
|
||||
chmod +x libpng-config
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
# and license in png.h
|
||||
|
||||
PREFIX?= /usr/local
|
||||
SHLIB_VER?= 16
|
||||
SHLIB_VER?= 17
|
||||
|
||||
LIB= png
|
||||
SHLIB_MAJOR= ${SHLIB_VER}
|
||||
@@ -26,19 +26,24 @@ SYMLINKS= libpng/png.h ${INCSDIR}/../png.h \
|
||||
libpng/pngconf.h ${INCSDIR}/../pngconf.h \
|
||||
libpng/pnglibconf.h ${INCSDIR}/../pnglibconf.h
|
||||
|
||||
LDADD+= -lm -lz
|
||||
#LDADD+= -lm -lz -lssp_nonshared # for OSVERSION < 800000 ?
|
||||
# where make install finds libz.a and zlib.h
|
||||
ZLIBLIB= /usr/lib
|
||||
ZLIBINC= /usr/include
|
||||
|
||||
LDADD+= -lm -lz
|
||||
#LDADD+= -lm -lz -lssp_nonshared # for OSVERSION < 800000 ?
|
||||
|
||||
DPADD+= ${LIBM} ${LIBZ}
|
||||
|
||||
CFLAGS+= -I.
|
||||
CFLAGS+= -I. -I${ZLIBINC}
|
||||
|
||||
SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
|
||||
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
|
||||
pngwtran.c pngmem.c pngerror.c pngpread.c
|
||||
|
||||
pngtest: pngtest.o libpng.a
|
||||
${CC} ${CFLAGS} -L. -static -o pngtest pngtest.o -lpng -lz -lm
|
||||
${CC} ${CFLAGS} -L. -static -o pngtest pngtest.o -L${ZLIBLIB} \
|
||||
-lpng ${LDADD}
|
||||
|
||||
CLEANFILES= pngtest pngtest.o pngout.png
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ ZLIBINC=/opt/zlib/include
|
||||
# SHAREDLIB=libz.sl
|
||||
|
||||
# Library name:
|
||||
LIBNAME = libpng16
|
||||
PNGMAJ = 16
|
||||
LIBNAME = libpng17
|
||||
PNGMAJ = 17
|
||||
|
||||
# Shared library names:
|
||||
LIBSO=$(LIBNAME).sl
|
||||
@@ -44,7 +44,7 @@ CCFLAGS=-I$(ZLIBINC) -O -Ae -Wl,+vnocompatwarnings +DD64 \
|
||||
|
||||
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm
|
||||
|
||||
# where make install puts libpng.a, libpng16.sl, and png.h
|
||||
# where make install puts libpng.a, libpng17.sl, and png.h
|
||||
prefix=/opt/libpng
|
||||
exec_prefix=$(prefix)
|
||||
INCPATH=$(prefix)/include
|
||||
@@ -93,7 +93,7 @@ libpng.pc:
|
||||
-e s!@exec_prefix@!$(exec_prefix)! \
|
||||
-e s!@libdir@!$(LIBPATH)! \
|
||||
-e s!@includedir@!$(INCPATH)! \
|
||||
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
|
||||
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
|
||||
|
||||
libpng-config:
|
||||
( cat scripts/libpng-config-head.in; \
|
||||
@@ -101,7 +101,7 @@ libpng-config:
|
||||
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
|
||||
echo ccopts=\"-Ae +DA1.1 +DS2.0\"; \
|
||||
echo L_opts=\"-L$(LIBPATH)\"; \
|
||||
echo libs=\"-lpng16 -lz -lm\"; \
|
||||
echo libs=\"-lpng17 -lz -lm\"; \
|
||||
cat scripts/libpng-config-body.in ) > libpng-config
|
||||
chmod +x libpng-config
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
# and license in png.h
|
||||
|
||||
# Library name:
|
||||
LIBNAME = libpng16
|
||||
PNGMAJ = 16
|
||||
LIBNAME = libpng17
|
||||
PNGMAJ = 17
|
||||
|
||||
# Shared library names:
|
||||
LIBSO=$(LIBNAME).sl
|
||||
@@ -55,8 +55,8 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
|
||||
|
||||
CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \
|
||||
$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
|
||||
#LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng16 -lz -lm
|
||||
LDFLAGS=-L. -L$(ZLIBLIB) -lpng16 -lz -lm
|
||||
#LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng17 -lz -lm
|
||||
LDFLAGS=-L. -L$(ZLIBLIB) -lpng17 -lz -lm
|
||||
|
||||
INCPATH=$(prefix)/include
|
||||
LIBPATH=$(exec_prefix)/lib
|
||||
@@ -100,13 +100,13 @@ libpng.pc:
|
||||
-e s!@exec_prefix@!$(exec_prefix)! \
|
||||
-e s!@libdir@!$(LIBPATH)! \
|
||||
-e s!@includedir@!$(INCPATH)! \
|
||||
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
|
||||
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
|
||||
|
||||
libpng-config:
|
||||
( cat scripts/libpng-config-head.in; \
|
||||
echo prefix=\"$(prefix)\"; \
|
||||
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
|
||||
echo libs=\"-lpng16 -lz -lm\"; \
|
||||
echo libs=\"-lpng17 -lz -lm\"; \
|
||||
cat scripts/libpng-config-body.in ) > libpng-config
|
||||
chmod +x libpng-config
|
||||
|
||||
|
||||
@@ -19,8 +19,8 @@ ZLIBINC=/opt/zlib/include
|
||||
# SHAREDLIB=libz.sl
|
||||
|
||||
# Library name:
|
||||
LIBNAME = libpng16
|
||||
PNGMAJ = 16
|
||||
LIBNAME = libpng17
|
||||
PNGMAJ = 17
|
||||
|
||||
# Shared library names:
|
||||
LIBSO=$(LIBNAME).sl
|
||||
@@ -36,7 +36,7 @@ LN_SF=ln -sf
|
||||
RANLIB=ranlib
|
||||
RM_F=/bin/rm -f
|
||||
|
||||
# where make install puts libpng.a, libpng16.sl, and png.h
|
||||
# where make install puts libpng.a, libpng17.sl, and png.h
|
||||
prefix=/opt/libpng
|
||||
exec_prefix=$(prefix)
|
||||
INCPATH=$(prefix)/include
|
||||
@@ -90,7 +90,7 @@ libpng.pc:
|
||||
-e s!@exec_prefix@!$(exec_prefix)! \
|
||||
-e s!@libdir@!$(LIBPATH)! \
|
||||
-e s!@includedir@!$(INCPATH)! \
|
||||
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
|
||||
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
|
||||
|
||||
libpng-config:
|
||||
( cat scripts/libpng-config-head.in; \
|
||||
@@ -98,7 +98,7 @@ libpng-config:
|
||||
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
|
||||
echo ccopts=\"-Ae +DA1.1 +DS2.0\"; \
|
||||
echo L_opts=\"-L$(LIBPATH)\"; \
|
||||
echo libs=\"-lpng16 -lz -lm\"; \
|
||||
echo libs=\"-lpng17 -lz -lm\"; \
|
||||
cat scripts/libpng-config-body.in ) > libpng-config
|
||||
chmod +x libpng-config
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# makefile for libpng.a and libpng16.so on Linux ELF with gcc
|
||||
# makefile for libpng.a and libpng17.so on Linux ELF with gcc
|
||||
# Copyright (C) 1998, 1999, 2002, 2006, 2008, 2010-2011 Greg Roelofs and
|
||||
# Glenn Randers-Pehrson
|
||||
# Copyright (C) 1996, 1997 Andreas Dilger
|
||||
@@ -8,8 +8,8 @@
|
||||
# and license in png.h
|
||||
|
||||
# Library name:
|
||||
LIBNAME = libpng16
|
||||
PNGMAJ = 16
|
||||
LIBNAME = libpng17
|
||||
PNGMAJ = 17
|
||||
RELEASE = 0
|
||||
|
||||
# Shared library names:
|
||||
@@ -26,8 +26,8 @@ LN_SF=ln -sf
|
||||
RANLIB=ranlib
|
||||
RM_F=/bin/rm -f
|
||||
|
||||
# where "make install" puts libpng16.a, libpng16.so*,
|
||||
# libpng16/png.h, libpng16/pngconf.h, and libpng16/pnglibconf.h
|
||||
# where "make install" puts libpng17.a, libpng17.so*,
|
||||
# libpng17/png.h, libpng17/pngconf.h, and libpng17/pnglibconf.h
|
||||
# Prefix must be a full pathname.
|
||||
prefix=/usr/local
|
||||
exec_prefix=$(prefix)
|
||||
@@ -51,7 +51,7 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
|
||||
CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops \
|
||||
$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
|
||||
|
||||
LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng16 -lz -lm
|
||||
LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng17 -lz -lm
|
||||
LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm
|
||||
|
||||
INCPATH=$(prefix)/include
|
||||
@@ -100,7 +100,7 @@ libpng.pc:
|
||||
-e s!@exec_prefix@!$(exec_prefix)! \
|
||||
-e s!@libdir@!$(LIBPATH)! \
|
||||
-e s!@includedir@!$(INCPATH)! \
|
||||
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
|
||||
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
|
||||
|
||||
libpng-config:
|
||||
( cat scripts/libpng-config-head.in; \
|
||||
@@ -108,7 +108,7 @@ libpng-config:
|
||||
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
|
||||
echo L_opts=\"-L$(LIBPATH)\"; \
|
||||
echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \
|
||||
echo libs=\"-lpng16 -lz -lm\"; \
|
||||
echo libs=\"-lpng17 -lz -lm\"; \
|
||||
cat scripts/libpng-config-body.in ) > libpng-config
|
||||
chmod +x libpng-config
|
||||
|
||||
@@ -236,4 +236,4 @@ pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h
|
||||
pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
|
||||
pngtest.o: png.h pngconf.h
|
||||
pngtest.o: png.h pngconf.h pnglibconf.h
|
||||
|
||||
204
scripts/makefile.msys
Normal file
204
scripts/makefile.msys
Normal file
@@ -0,0 +1,204 @@
|
||||
# makefile for libpng using MSYS/gcc (shared, static library)
|
||||
# Copyright (C) 2012 Glenn Randers-Pehrson and Christopher M. Wheeler
|
||||
#
|
||||
# Portions taken from makefile.linux:
|
||||
# Copyright (C) 1998, 1999, 2002, 2006, 2008, 2010-2011 Greg Roelofs and
|
||||
# Glenn Randers-Pehrson
|
||||
# Copyright (C) 2000 Cosmin Truta
|
||||
# Copyright (C) 1996, 1997 Andreas Dilger
|
||||
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
#
|
||||
# This code is released under the libpng license.
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
# # # # # # # # # # # # # # # # #
|
||||
prefix=/usr/local
|
||||
exec_prefix=$(prefix)
|
||||
|
||||
# Library name:
|
||||
LIBNAME = libpng17
|
||||
PNGMAJ = 17
|
||||
RELEASE = 0
|
||||
|
||||
# Shared library names:
|
||||
LIBSO=$(LIBNAME).dll
|
||||
LIBSOMAJ=$(LIBNAME).dll.$(PNGMAJ)
|
||||
LIBSOREL=$(PNGMAJ).$(RELEASE)
|
||||
OLDSO=libpng.dll
|
||||
|
||||
# Where the zlib library and include files are located.
|
||||
#ZLIBLIB=../zlib
|
||||
#ZLIBINC=../zlib
|
||||
ZLIBLIB=/usr/local/lib
|
||||
ZLIBINC=/usr/local/include
|
||||
|
||||
# Compiler, linker, lib and other tools
|
||||
CC = gcc
|
||||
LD = $(CC)
|
||||
AR_RC = ar rcs
|
||||
RANLIB = ranlib
|
||||
RM_F = rm -rf
|
||||
MKDIR_P=mkdir -p
|
||||
LN_SF=ln -sf
|
||||
|
||||
#ARCH = -march=pentium3
|
||||
#ARCH = -march=i686
|
||||
ARCH =
|
||||
CDEBUG = -g -DPNG_DEBUG=5
|
||||
LDDEBUG =
|
||||
CRELEASE = -O2
|
||||
LDRELEASE = -s
|
||||
#CFLAGS = -W -Wall $(CDEBUG)
|
||||
CFLAGS = -W -Wall $(CRELEASE) $(ARCH)
|
||||
#LDFLAGS = $(LDDEBUG)
|
||||
LDFLAGS = $(LDRELEASE)
|
||||
LIBS = -lz -lm
|
||||
|
||||
# File extensions
|
||||
O=.o
|
||||
A=.a
|
||||
EXE=.exe
|
||||
|
||||
INCPATH=$(prefix)/include
|
||||
LIBPATH=$(exec_prefix)/lib
|
||||
MANPATH=$(prefix)/man
|
||||
BINPATH=$(exec_prefix)/bin
|
||||
|
||||
# override DESTDIR= on the make install command line to easily support
|
||||
# installing into a temporary location. Example:
|
||||
#
|
||||
# make install DESTDIR=/tmp/build/libpng
|
||||
#
|
||||
# If you're going to install into a temporary location
|
||||
# via DESTDIR, $(DESTDIR)$(prefix) must already exist before
|
||||
# you execute make install.
|
||||
|
||||
DESTDIR=
|
||||
|
||||
DB=$(DESTDIR)$(BINPATH)
|
||||
DI=$(DESTDIR)$(INCPATH)
|
||||
DL=$(DESTDIR)$(LIBPATH)
|
||||
DM=$(DESTDIR)$(MANPATH)
|
||||
|
||||
# Variables
|
||||
OBJS = png$(O) pngerror$(O) pngget$(O) pngmem$(O) pngpread$(O) \
|
||||
pngread$(O) pngrio$(O) pngrtran$(O) pngrutil$(O) pngset$(O) \
|
||||
pngtrans$(O) pngwio$(O) pngwrite$(O) pngwtran$(O) pngwutil$(O)
|
||||
|
||||
# Targets
|
||||
all: static shared
|
||||
|
||||
# see scripts/pnglibconf.mak for more options
|
||||
pnglibconf.h: scripts/pnglibconf.h.prebuilt
|
||||
cp scripts/pnglibconf.h.prebuilt $@
|
||||
|
||||
.c$(O):
|
||||
$(CC) -c $(CFLAGS) -I$(ZLIBINC) $<
|
||||
|
||||
static: libpng$(A) pngtest$(EXE)
|
||||
|
||||
shared: $(LIBSOMAJ)
|
||||
$(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSO)
|
||||
|
||||
$(LIBSO): $(LIBSOMAJ)
|
||||
$(LN_SF) $(LIBSOMAJ) $(LIBSO)
|
||||
|
||||
$(LIBSOMAJ):
|
||||
$(CC) -shared -Wl,-soname,$(LIBSOMAJ) -o $(LIBSOMAJ)
|
||||
|
||||
libpng$(A): $(OBJS)
|
||||
$(AR_RC) $@ $(OBJS)
|
||||
$(RANLIB) $@
|
||||
|
||||
install-headers: png.h pngconf.h pnglibconf.h
|
||||
-@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
|
||||
-@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
|
||||
cp png.h pngconf.h pnglibconf.h $(DI)/$(LIBNAME)
|
||||
-@$(RM_F) $(DI)/png.h $(DI)/pngconf.h $(DI)/pnglibconf.h
|
||||
-@$(RM_F) $(DI)/libpng
|
||||
(cd $(DI); $(LN_SF) $(LIBNAME) libpng; $(LN_SF) $(LIBNAME)/* .)
|
||||
|
||||
install-static: install-headers libpng.a
|
||||
-@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
|
||||
cp libpng.a $(DL)/$(LIBNAME).a
|
||||
-@$(RM_F) $(DL)/libpng.a
|
||||
(cd $(DL); $(LN_SF) $(LIBNAME).a libpng.a)
|
||||
|
||||
libpng.pc:
|
||||
cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
|
||||
-e s!@exec_prefix@!$(exec_prefix)! \
|
||||
-e s!@libdir@!$(LIBPATH)! \
|
||||
-e s!@includedir@!$(INCPATH)! \
|
||||
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
|
||||
|
||||
libpng-config:
|
||||
( cat scripts/libpng-config-head.in; \
|
||||
echo prefix=\"$(prefix)\"; \
|
||||
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
|
||||
echo L_opts=\"-L$(LIBPATH)\"; \
|
||||
echo R_opts=\"-Wl,-rpath,$(LIBPATH)\"; \
|
||||
echo libs=\"-lpng17 -lz -lm\"; \
|
||||
cat scripts/libpng-config-body.in ) > libpng-config
|
||||
|
||||
install-shared: install-headers $(LIBSOMAJ) libpng.pc
|
||||
-@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
|
||||
-@$(RM_F) $(DL)/$(LIBSO)
|
||||
-@$(RM_F) $(DL)/$(OLDSO)
|
||||
cp $(LIBSO) $(DL)/$(LIBSOREL)
|
||||
(cd $(DL); \
|
||||
$(LN_SF) $(LIBSOREL) $(LIBSO); \
|
||||
$(LN_SF) $(LIBSO) $(OLDSO))
|
||||
|
||||
-@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
|
||||
-@$(RM_F) $(DL)/pkgconfig/$(LIBNAME).pc
|
||||
-@$(RM_F) $(DL)/pkgconfig/libpng.pc
|
||||
cp libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
|
||||
(cd $(DL)/pkgconfig; $(LN_SF) $(LIBNAME).pc libpng.pc)
|
||||
|
||||
install-man: libpng.3 libpngpf.3 png.5
|
||||
-@if [ ! -d $(DM) ]; then $(MKDIR_P) $(DM); fi
|
||||
-@if [ ! -d $(DM)/man3 ]; then $(MKDIR_P) $(DM)/man3; fi
|
||||
-@$(RM_F) $(DM)/man3/libpng.3
|
||||
-@$(RM_F) $(DM)/man3/libpngpf.3
|
||||
cp libpng.3 $(DM)/man3
|
||||
cp libpngpf.3 $(DM)/man3
|
||||
-@if [ ! -d $(DM)/man5 ]; then $(MKDIR_P) $(DM)/man5; fi
|
||||
-@$(RM_F) $(DM)/man5/png.5
|
||||
cp png.5 $(DM)/man5
|
||||
|
||||
install-config: libpng-config
|
||||
-@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
|
||||
-@$(RM_F) $(DB)/libpng-config
|
||||
-@$(RM_F) $(DB)/$(LIBNAME)-config
|
||||
cp libpng-config $(DB)/$(LIBNAME)-config
|
||||
(cd $(DB); $(LN_SF) $(LIBNAME)-config libpng-config)
|
||||
|
||||
install: install-static install-shared install-man install-config
|
||||
|
||||
test: pngtest$(EXE)
|
||||
./pngtest$(EXE)
|
||||
|
||||
pngtest$(EXE): pngtest$(O) libpng$(A)
|
||||
$(LD) $(LDFLAGS) -L$(ZLIBLIB) -o $@ pngtest$(O) libpng$(A) $(LIBS)
|
||||
|
||||
clean:
|
||||
$(RM_F) *$(O) libpng$(A) pngtest$(EXE) pngout.png pnglibconf.h $(LIBSO) \
|
||||
$(LIBSOMAJ) libpng-config
|
||||
|
||||
png.o png.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngerror.o pngerror.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrio.o pngrio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwio.o pngwio.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngmem.o pngmem.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngset.o pngset.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngget.o pngget.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngread.o pngread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrtran.o pngrtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngrutil.o pngrutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngtrans.o pngtrans.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwrite.o pngwrite.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwtran.o pngwtran.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngwutil.o pngwutil.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
pngpread.o pngpread.pic.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
|
||||
|
||||
pngtest.o: png.h pngconf.h pnglibconf.h
|
||||
@@ -13,11 +13,11 @@
|
||||
LOCALBASE?=/usr/local
|
||||
LIBDIR= ${LOCALBASE}/lib
|
||||
MANDIR= ${LOCALBASE}/man
|
||||
INCSDIR=${LOCALBASE}/include/libpng16
|
||||
INCSDIR=${LOCALBASE}/include/libpng17
|
||||
|
||||
LIB= png16
|
||||
LIB= png17
|
||||
SHLIB_MAJOR= 0
|
||||
SHLIB_MINOR= 1.6.0beta33
|
||||
SHLIB_MINOR= 1.7.0beta15
|
||||
SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
|
||||
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
|
||||
pngwtran.c pngmem.c pngerror.c pngpread.c
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
# For conditions of distribution and use, see the disclaimer
|
||||
# and license in png.h
|
||||
|
||||
# You should also run makefile.ne16bsd
|
||||
# You should also run makefile.ne17bsd
|
||||
|
||||
LOCALBASE?=/usr/local
|
||||
LIBDIR= ${LOCALBASE}/lib
|
||||
@@ -16,8 +16,8 @@ MANDIR= ${LOCALBASE}/man
|
||||
INCSDIR=${LOCALBASE}/include
|
||||
|
||||
LIB= png
|
||||
SHLIB_MAJOR= 16
|
||||
SHLIB_MINOR= 1.6.0beta33
|
||||
SHLIB_MAJOR= 17
|
||||
SHLIB_MINOR= 1.7.0beta15
|
||||
SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
|
||||
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
|
||||
pngwtran.c pngmem.c pngerror.c pngpread.c
|
||||
|
||||
@@ -10,8 +10,8 @@ PREFIX?= /usr/local
|
||||
LIBDIR= ${PREFIX}/lib
|
||||
MANDIR= ${PREFIX}/man/cat
|
||||
|
||||
SHLIB_MAJOR= 16
|
||||
SHLIB_MINOR= 1.6.0beta33
|
||||
SHLIB_MAJOR= 17
|
||||
SHLIB_MINOR= 1.7.0beta15
|
||||
|
||||
LIB= png
|
||||
SRCS= png.c pngerror.c pngget.c pngmem.c pngpread.c \
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
# and license in png.h
|
||||
|
||||
# Library name:
|
||||
LIBNAME = libpng16
|
||||
PNGMAJ = 16
|
||||
LIBNAME = libpng17
|
||||
PNGMAJ = 17
|
||||
|
||||
# Shared library names:
|
||||
LIBSO=$(LIBNAME).so
|
||||
@@ -38,7 +38,7 @@ ZLIBLIB=../zlib
|
||||
ZLIBINC=../zlib
|
||||
|
||||
CFLAGS= -dy -belf -I$(ZLIBINC) -O3
|
||||
LDFLAGS=-L. -L$(ZLIBLIB) -lpng16 -lz -lm
|
||||
LDFLAGS=-L. -L$(ZLIBLIB) -lpng17 -lz -lm
|
||||
|
||||
INCPATH=$(prefix)/include
|
||||
LIBPATH=$(exec_prefix)/lib
|
||||
@@ -86,7 +86,7 @@ libpng.pc:
|
||||
-e s!@exec_prefix@!$(exec_prefix)! \
|
||||
-e s!@libdir@!$(LIBPATH)! \
|
||||
-e s!@includedir@!$(INCPATH)! \
|
||||
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
|
||||
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
|
||||
|
||||
libpng-config:
|
||||
( cat scripts/libpng-config-head.in; \
|
||||
@@ -94,7 +94,7 @@ libpng-config:
|
||||
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
|
||||
echo ccopts=\"-belf\"; \
|
||||
echo L_opts=\"-L$(LIBPATH)\"; \
|
||||
echo libs=\"-lpng16 -lz -lm\"; \
|
||||
echo libs=\"-lpng17 -lz -lm\"; \
|
||||
cat scripts/libpng-config-body.in ) > libpng-config
|
||||
chmod +x libpng-config
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# makefile for libpng.a and libpng16.so, SGI IRIX with 'cc'
|
||||
# makefile for libpng.a and libpng17.so, SGI IRIX with 'cc'
|
||||
# Copyright (C) 2001-2002, 2006, 2010-2011 Glenn Randers-Pehrson
|
||||
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
#
|
||||
@@ -7,8 +7,8 @@
|
||||
# and license in png.h
|
||||
|
||||
# Library name:
|
||||
LIBNAME=libpng16
|
||||
PNGMAJ = 16
|
||||
LIBNAME=libpng17
|
||||
PNGMAJ = 17
|
||||
|
||||
# Shared library names:
|
||||
LIBSO=$(LIBNAME).so
|
||||
@@ -24,7 +24,7 @@ LN_SF=ln -sf
|
||||
RANLIB=echo
|
||||
RM_F=/bin/rm -f
|
||||
|
||||
# Where make install puts libpng.a, libpng16.so, and libpng16/png.h
|
||||
# Where make install puts libpng.a, libpng17.so, and libpng17/png.h
|
||||
# Prefix must be a full pathname.
|
||||
|
||||
prefix=/usr/local
|
||||
@@ -91,7 +91,7 @@ libpng.pc:
|
||||
-e s!@exec_prefix@!$(exec_prefix)! \
|
||||
-e s!@libdir@!$(LIBPATH)! \
|
||||
-e s!@includedir@!$(INCPATH)! \
|
||||
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
|
||||
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
|
||||
|
||||
libpng-config:
|
||||
( cat scripts/libpng-config-head.in; \
|
||||
@@ -102,7 +102,7 @@ libpng-config:
|
||||
echo ldopts=\"$(ABI)\"; \
|
||||
echo L_opts=\"-L$(LIBPATH)\"; \
|
||||
echo libdir=\"$(LIBPATH)\"; \
|
||||
echo libs=\"-lpng16 -lz -lm\"; \
|
||||
echo libs=\"-lpng17 -lz -lm\"; \
|
||||
cat scripts/libpng-config-body.in ) > libpng-config
|
||||
chmod +x libpng-config
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
# makefile for libpng.a and libpng16.so, SGI IRIX with 'cc'
|
||||
# makefile for libpng.a and libpng17.so, SGI IRIX with 'cc'
|
||||
# Copyright (C) 2001-2002, 2006, 2007, 2010-2011 Glenn Randers-Pehrson
|
||||
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
|
||||
#
|
||||
@@ -7,8 +7,8 @@
|
||||
# and license in png.h
|
||||
|
||||
# Library name:
|
||||
LIBNAME=libpng16
|
||||
PNGMAJ = 16
|
||||
LIBNAME=libpng17
|
||||
PNGMAJ = 17
|
||||
|
||||
# Shared library names:
|
||||
LIBSO=$(LIBNAME).so
|
||||
@@ -24,7 +24,7 @@ LN_SF=ln -sf
|
||||
RANLIB=echo
|
||||
RM_F=/bin/rm -f
|
||||
|
||||
# Where make install puts libpng.a, libpng16.so, and libpng16/png.h
|
||||
# Where make install puts libpng.a, libpng17.so, and libpng17/png.h
|
||||
# Prefix must be a full pathname.
|
||||
|
||||
prefix=/usr/local
|
||||
@@ -46,7 +46,7 @@ WARNMORE=-fullwarn
|
||||
# Note: -KPIC is the default anyhow
|
||||
#CFLAGS= $(ABI) -I$(ZLIBINC) -O $(WARNMORE) -KPIC # -g -DPNG_DEBUG=5
|
||||
CFLAGS=$(ABI) -I$(ZLIBINC) -O $(WARNMORE)
|
||||
LDFLAGS_A=$(ABI) -L. -L$(ZLIBLIB) -lpng16 -lz -lm
|
||||
LDFLAGS_A=$(ABI) -L. -L$(ZLIBLIB) -lpng17 -lz -lm
|
||||
LDFLAGS=$(ABI) -L. -L$(ZLIBLIB) -lpng -lz -lm
|
||||
LDSHARED=cc $(ABI) -shared -soname $(LIBSOMAJ) \
|
||||
-set_version sgi$(PNGMAJ).0
|
||||
@@ -92,7 +92,7 @@ libpng.pc:
|
||||
-e s!@exec_prefix@!$(exec_prefix)! \
|
||||
-e s!@libdir@!$(LIBPATH)! \
|
||||
-e s!@includedir@!$(INCPATH)! \
|
||||
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
|
||||
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
|
||||
|
||||
libpng-config:
|
||||
( cat scripts/libpng-config-head.in; \
|
||||
@@ -102,7 +102,7 @@ libpng-config:
|
||||
echo ldopts=\"$(ABI)\"; \
|
||||
echo L_opts=\"-L$(LIBPATH)\"; \
|
||||
echo libdir=\"$(LIBPATH)\"; \
|
||||
echo libs=\"-lpng16 -lz -lm\"; \
|
||||
echo libs=\"-lpng17 -lz -lm\"; \
|
||||
cat scripts/libpng-config-body.in ) > libpng-config
|
||||
chmod +x libpng-config
|
||||
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
# and license in png.h
|
||||
|
||||
# Library name:
|
||||
PNGMAJ = 16
|
||||
LIBNAME = libpng16
|
||||
PNGMAJ = 17
|
||||
LIBNAME = libpng17
|
||||
|
||||
# Shared library names:
|
||||
LIBSO=$(LIBNAME).so
|
||||
@@ -48,7 +48,7 @@ ZLIBINC=/usr/include
|
||||
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
|
||||
#CFLAGS=-I$(ZLIBINC) -W -Wall -O3 $(WARNMORE) -g -DPNG_DEBUG=5 -DPNG_NO_MMX_CODE
|
||||
CFLAGS=-I$(ZLIBINC) -O3 -DPNG_NO_MMX_CODE
|
||||
LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng16 -lz -lm
|
||||
LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng17 -lz -lm
|
||||
|
||||
INCPATH=$(prefix)/include
|
||||
LIBPATH=$(exec_prefix)/lib
|
||||
@@ -96,7 +96,7 @@ libpng.pc:
|
||||
-e s!@exec_prefix@!$(exec_prefix)! \
|
||||
-e s!@libdir@!$(LIBPATH)! \
|
||||
-e s!@includedir@!$(INCPATH)! \
|
||||
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc
|
||||
-e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
|
||||
|
||||
libpng-config:
|
||||
( cat scripts/libpng-config-head.in; \
|
||||
@@ -104,7 +104,7 @@ libpng-config:
|
||||
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
|
||||
echo L_opts=\"-L$(LIBPATH)\"; \
|
||||
echo R_opts=\"-R$(LIBPATH)\"; \
|
||||
echo libs=\"-lpng16 -lz -lm\"; \
|
||||
echo libs=\"-lpng17 -lz -lm\"; \
|
||||
cat scripts/libpng-config-body.in ) > libpng-config
|
||||
chmod +x libpng-config
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user