Compare commits

...

30 Commits

Author SHA1 Message Date
Glenn Randers-Pehrson
36b628b19e [libpng17] Imported from libpng-1.7.0alpha03.tar 2012-12-19 15:53:18 -06:00
Glenn Randers-Pehrson
2c31365fd4 [libpng16] Announce that git repository location at SourceForge has changed. 2012-12-18 21:45:58 -06:00
Glenn Randers-Pehrson
e1e3c1a2a2 [libpng17] Fixed typo in contrib/pngminim/encoder/README 2012-12-18 14:58:44 -06:00
John Bowler
b940e5dc5d [libpng17] Disassembled the version number in scripts/options.awk (necessary
for building on SunOs)
2012-12-17 23:36:08 -06:00
John Bowler
fbbbc620b8 [libpng16] 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.
2012-12-17 21:07:30 -06:00
Glenn Randers-Pehrson
9b99600c4d [libpng17] Fixed several more whitespace errors in libpng.3 2012-12-17 20:00:44 -06:00
Glenn Randers-Pehrson
3129d7426e [libpng16] Cleaned up whitespace in the synopsis portion of the manpage. 2012-12-17 19:21:14 -06:00
Glenn Randers-Pehrson
325ceea971 [libpng17] Bump version to 1.7.0alpha03 2012-12-17 12:25:13 -06:00
Glenn Randers-Pehrson
ac39fc3024 [libpng17] Bump version to 1.7.0alpha03 2012-12-17 12:16:32 -06:00
Glenn Randers-Pehrson
99343407e6 [libpng17] Add #ifdef PNG_WRITE_FILTERED_ROW around a use of prev_row. 2012-12-17 12:12:49 -06:00
Glenn Randers-Pehrson
3e23f45ba9 [libpng17] Document new PNG_ABORT behavior in libpng-1.7.x 2012-12-17 11:53:34 -06:00
John Bowler
72389dec42 [libpng17] 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.
2012-12-17 09:20:02 -06:00
Glenn Randers-Pehrson
1f0853f47e [libpng17] Bump version to 1.7.0alpha03 2012-12-16 19:43:18 -06:00
Glenn Randers-Pehrson
32a60a4885 [libpng17] Imported from libpng-1.7.0alpha02.tar 2012-12-16 19:43:10 -06:00
Glenn Randers-Pehrson
5e07dc6970 [libpng17] Updated documentation about functions deprecated in 1.6.0 2012-12-16 16:47:07 -06:00
John Bowler
4b90a8d416 [libpng17] Build fixes (trailing ;, missing/misplaced PNG_REMOVED) in png.h 2012-12-16 15:56:18 -06:00
John Bowler
d59c19b64c [libpng17] Removed more functions that were deprecated in libpng-1.6.0:
png_malloc_default png_free_default.
  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
2012-12-15 21:41:31 -06:00
Glenn Randers-Pehrson
bbabd977d1 [libpng17] Fixed some typos in comments; updated manual. 2012-12-15 17:12:48 -06:00
John Bowler
0cf9c7d63d [libpng17] Removed some duplicated code from png.c and contrib/tools/scale.c
and changed some png_warning() calls to png_app_error() calls in pngwutil.c
2012-12-15 16:04:28 -06:00
Glenn Randers-Pehrson
b4e241559e [libpng17] Removed no-longer-exported functions from scripts/symbols.def 2012-12-15 16:02:24 -06:00
Glenn Randers-Pehrson
1e15aee6be [libpng17] 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.
2012-12-15 15:40:56 -06:00
Glenn Randers-Pehrson
d59e60d0fb [libpng17] Bump version to 1.7.0alpha02 2012-12-15 12:33:51 -06:00
Glenn Randers-Pehrson
ec1d13a1d4 [libpng17] Imported from libpng-1.7.0alpha01.tar 2012-12-15 12:33:44 -06:00
Glenn Randers-Pehrson
d9002f94cb [libpng17] Rebuilt Makefile.in, configure, etc., with autoconf-2.69
and automake-1.12.5 in the tar distributions.
2012-12-15 10:12:36 -06:00
John Bowler
1fa858db48 [libpng17] Fixed cases of unquoted DESTDIR in Makefile.am. 2012-12-15 09:48:10 -06:00
John Bowler
0f2a5bac64 [libpng17] 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.
2012-12-14 23:12:16 -06:00
John Bowler
eac85878bf [libpng17] Clean up USER_LIMITS feature, removing members from png_struct
when not required.
2012-12-14 22:56:00 -06:00
John Bowler
240ac287eb [libpng17]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.
2012-12-14 22:31:50 -06:00
John Bowler
3e42c81193 [libpng17] 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 slighly
    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.
2012-12-14 22:17:54 -06:00
Glenn Randers-Pehrson
ac3b4d9b69 [libpng17] Bump version to 1.7.0alpha01 2012-12-10 16:21:25 -06:00
76 changed files with 3160 additions and 3297 deletions

613
ANNOUNCE
View File

@@ -1,5 +1,5 @@
Libpng 1.6.0beta33 - December 10, 2012 Libpng 1.7.0alpha03 - December 19, 2012
This is not intended to be a public release. It will be replaced 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. within a few weeks by a public version or by another test version.
@@ -9,555 +9,92 @@ Files available for download:
Source files with LF line endings (for Unix/Linux) and with a Source files with LF line endings (for Unix/Linux) and with a
"configure" script "configure" script
1.6.0beta33.tar.xz (LZMA-compressed, recommended) 1.7.0alpha03.tar.xz (LZMA-compressed, recommended)
1.6.0beta33.tar.gz 1.7.0alpha03.tar.gz
1.6.0beta33.tar.bz2 1.7.0alpha03.tar.bz2
Source files with CRLF line endings (for Windows), without the Source files with CRLF line endings (for Windows), without the
"configure" script "configure" script
lp160b33.7z (LZMA-compressed, recommended) lp170a03.7z (LZMA-compressed, recommended)
lp160b33.zip lp170a03.zip
Other information: Other information:
1.6.0beta33-README.txt 1.7.0alpha03-README.txt
1.6.0beta33-LICENSE.txt 1.7.0alpha03-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] Version 1.7.0alpha01 [December 15, 2012]
Removed machine-generated configure files from the GIT repository (they will Started 1.7.0 branch from libpng-1.6.0beta33.
continue to appear in the tarball distributions). Made 8-bit compose and rgb_to_grayscale accuracy improvements. These
Restored the new 'simplified' API, which was started in libpng-1.5.7beta02 changes cause 16-bit arithmetic to be used for 8-bit data in the gamma
but later deleted from libpng-1.5.7beta05. corrected compose and grayscale operations. The arithmetic errors have
Added example programs for the new 'simplified' API. three sources all of which are fixed in this commit:
Added ANSI-C (C90) headers and require them, and take advantage of the 1) 8-bit linear calculations produce massive errors for lower intensity
change. Also fixed some of the projects/* and contrib/* files that needed values.
updates for libpng16 and the move of pngvalid.c. 2) The old 16-bit "16 to 8" gamma table code erroneously wrote the lowest
With this change the required ANSI-C header files are assumed to exist: the output value into a table entry which corresponded to multiple output
implementation must provide float.h, limits.h, stdarg.h and stddef.h and values (so where the value written should have been the closest to the
libpng relies on limits.h and stddef.h existing and behaving as defined transformed input value.)
(the other two required headers aren't used). Non-ANSI systems that don't 3) In a number of cases the code to access the 16-bit table did not round;
have stddef.h or limits.h will have to provide an appropriate fake it did a simple shift, which was wrong and made the side effects of (2)
containing the relevant types and #defines. even worse.
The use of FAR/far has been eliminated and the definition of png_alloc_size_t The new gamma code does not have the 16-to-8 problem at the cost of slightly
is now controlled by a flag so that 'small size_t' systems can select it more calculations and the algorithm used to minimize the number of
if necessary. Libpng 1.6 may not currently work on such systems -- it calculations has been extended to all the 16-bit tables; it has advantages
seems likely that it will ask 'malloc' for more than 65535 bytes with any for any significant gamma correction.
image that has a sufficiently large row size (rather than simply failing Rearranged png_struct, remove unused members, change png_set_filter handling
to read such images). png_struct members rearranged - partly to reorder to avoid packing, partly
New tools directory containing tools used to generate libpng code. to put frequently accessed members at the start and partly to make
Fixed race conditions in parallel make builds. With higher degrees of the grouping more clear. png_set_filter code has been rewritten and the
parallelism during 'make' the use of the same temporary file names such code shared with png_write_start_row moved to a common function. Comments
as 'dfn*' can result in a race where a temporary file from one arm of the in png.h have been made more clear. Minor fixes to
build is deleted or overwritten in another arm. This changes the contrib/libtests/timepng.c and some of the png_*_tRNS logic, including
temporary files for suffix rules to always use $* and ensures that the more error detection in png_set_tRNS.
non-suffix rules use unique file names. 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] Version 1.7.0alpha02 [December 17, 2012]
Correct configure builds where build and source directories are separate. Removed functions that were deprecated in libpng-1.6.0:
The include path of 'config.h' was erroneously made relative in pngvalid.c png_reset_zstream(), png_info_init_3(), and png_data_freer() and its
in libpng 1.5.7. 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] Version 1.7.0alpha03 [December 19, 2012]
Start-up code size improvements, error handler flexibility. These changes Cleaned up and enhanced the configure option; libpng now correctly
alter how the tricky allocation of the initial png_struct and png_info links and tests against zlib with a prefix; tests have been clarified; and
structures are handled. png_info is now handled in pretty much the same irrelevant or obsolete things (as defined by the autotools man page) have
way as everything else, except that the allocations handle NULL return been removed.
silently. png_struct is changed in a similar way on allocation and on Documented new PNG_ABORT behavior in the manual and commentary in pngerror.c
deallocation a 'safety' error handler is put in place (which should never Cleaned up whitespace in the synopsis portion of the manpage "libpng.3"
be required). The error handler itself is changed to permit mismatches Fixed previous support for Z_PREFIX in configure builds, corrected sCAL APIs;
in the application and libpng error buffer size; however, this means a some of these use floating point arithmetic so they need to be disabled if
silent change to the API to return the jmp_buf if the size doesn't match floating point arithmetic is switched off. This is a quiet API change -
the size from the libpng compilation; libpng now allocates the memory and previously it appeared that the APIs were supported if fixed point
this may fail. Overall these changes result in slight code size arithmetic was used internally, however they required certain APIs (floor,
reductions; however, this is a reduction in code that is always executed modf, frexp, atof) that are part of C floating point support. Changed
so is particularly valuable. Overall on a 64-bit system the libpng DLL png_fixed and the gamma code specific version of the same to avoid floor(),
decreases in code size by 1733 bytes. pngerror.o increases in size by which may be a library function (not an intrinsic). Removed unused #if 0
about 465 bytes because of the new functionality. code.
Added png_convert_to_rfc1123_buffer() and deprecated png_convert_to_rfc1123() Disassembled the version number in scripts/options.awk (necessary for
to avoid including a spurious buffer in the png_struct. building on SunOs).
Version 1.6.0beta04 [December 30, 2011] ===========================================================================
Regenerated configure scripts with automake-1.11.2 NOTICE November 17, 2012:
Eliminated png_info_destroy(). It is now used only in png.c and only calls The location of the git repository at SourceForge has changed.
one other internal function and memset(). Visit http://libpng.sf.net/ for details.
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.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.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.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.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.6.0beta09 [February 1, 2012]
Reverted the prebuilt configure files to libpng-1.6.0beta05 condition.
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.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.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.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.6.0beta14 [February 27, 2012]
Added information about the new limits in the manual.
Updated Makefile.in
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.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.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.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.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.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.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.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.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.6.0beta24 [June 7, 2012]
Don't check palette indexes if num_palette is 0 (as it can be in MNG files).
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().
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit

70
CHANGES
View File

@@ -4311,6 +4311,76 @@ Version 1.6.0beta33 [December 10, 2012]
fall-through condition. fall-through condition.
Change png_warning() to png_app_warning() in png_write_tRNS(). 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).
===========================================================================
NOTICE November 17, 2012:
The location of the git repository at SourceForge has changed.
Visit http://libpng.sf.net/ for details.
===========================================================================
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement https://lists.sourceforge.net/lists/listinfo/png-mng-implement

View File

@@ -34,7 +34,7 @@ project(libpng C)
enable_testing() enable_testing()
set(PNGLIB_MAJOR 1) set(PNGLIB_MAJOR 1)
set(PNGLIB_MINOR 6) set(PNGLIB_MINOR 7)
set(PNGLIB_RELEASE 0) set(PNGLIB_RELEASE 0)
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR}) set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE}) set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
@@ -260,9 +260,9 @@ endif(NOT WIN32 OR CYGWIN OR MINGW)
# SET UP LINKS # SET UP LINKS
if(PNG_SHARED) if(PNG_SHARED)
set_target_properties(${PNG_LIB_NAME} PROPERTIES set_target_properties(${PNG_LIB_NAME} PROPERTIES
# VERSION 16.${PNGLIB_RELEASE}.1.6.0beta33 # VERSION 17.${PNGLIB_RELEASE}.1.7.0alpha03
VERSION 16.${PNGLIB_RELEASE}.0 VERSION 17.${PNGLIB_RELEASE}.0
SOVERSION 16 SOVERSION 17
CLEAN_DIRECT_OUTPUT 1) CLEAN_DIRECT_OUTPUT 1)
endif() endif()
if(PNG_STATIC) if(PNG_STATIC)
@@ -294,7 +294,7 @@ if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
# Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin # Create a symlink for libpng.dll.a => libpng17.dll.a on Cygwin
if(CYGWIN OR MINGW) if(CYGWIN OR MINGW)
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE}) get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE})
get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME) get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME)

View File

@@ -10,7 +10,7 @@ this sentence.
This code is released under the libpng license. This code is released under the libpng license.
libpng versions 1.2.6, August 15, 2004, through 1.6.0beta33, December 10, 2012, are libpng versions 1.2.6, August 15, 2004, through 1.7.0alpha03, December 19, 2012, are
Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.2.5 distributed according to the same disclaimer and license as libpng-1.2.5
with the following individual added to the list of Contributing Authors 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 Glenn Randers-Pehrson
glennrp at users.sourceforge.net glennrp at users.sourceforge.net
December 10, 2012 December 19, 2012

View File

@@ -43,7 +43,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 png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngusr.dfa
if PNG_ARM_NEON 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 endif
nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
@@ -119,6 +120,8 @@ scripts/sym.out scripts/vers.out: png.h pngconf.h pnglibconf.h
scripts/prefix.out: png.h pngconf.h pnglibconf.out scripts/prefix.out: png.h pngconf.h pnglibconf.out
scripts/symbols.out: png.h pngconf.h $(srcdir)/scripts/pnglibconf.h.prebuilt scripts/symbols.out: png.h pngconf.h $(srcdir)/scripts/pnglibconf.h.prebuilt
pnglibconf.out: config.h
libpng.sym: scripts/sym.out libpng.sym: scripts/sym.out
rm -f $@ rm -f $@
cp $? $@ cp $? $@
@@ -130,7 +133,7 @@ if DO_PNG_PREFIX
# Rename functions in scripts/prefix.out with a PNG_PREFIX 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 # Rename macros in scripts/macro.lst from PNG_PREFIXpng_ to PNG_ (the actual
# implementation of the macro). # 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 $@ rm -f $@
$(AWK) 's==0 && NR>1{print prev}\ $(AWK) 's==0 && NR>1{print prev}\
s==0{prev=$$0}\ s==0{prev=$$0}\
@@ -236,22 +239,24 @@ dist-hook:
# install the .../include headers as links to the new ones # install the .../include headers as links to the new ones
install-data-hook: install-data-hook:
cd $(DESTDIR)$(includedir); rm -f png.h pngconf.h pnglibconf.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)/png.h png.h
cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/pngconf.h \ cd '$(DESTDIR)$(includedir)'; $(LN_S) $(PNGLIB_BASENAME)/pngconf.h \
pngconf.h pngconf.h
cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/pnglibconf.h \ cd '$(DESTDIR)$(includedir)'; $(LN_S) $(PNGLIB_BASENAME)/pnglibconf.h \
pnglibconf.h pnglibconf.h
cd $(DESTDIR)$(pkgconfigdir); rm -f libpng.pc cd '$(DESTDIR)$(pkgconfigdir)'; rm -f libpng.pc
cd $(DESTDIR)$(pkgconfigdir); $(LN_S) $(PNGLIB_BASENAME).pc 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 # do evil things to libpng to cause libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ to be used
install-exec-hook: install-exec-hook:
cd $(DESTDIR)$(bindir); rm -f libpng-config cd '$(DESTDIR)$(bindir)'; rm -f libpng-config
cd $(DESTDIR)$(bindir); $(LN_S) $(PNGLIB_BASENAME)-config libpng-config cd '$(DESTDIR)$(bindir)';\
$(LN_S) $(PNGLIB_BASENAME)-config libpng-config
@set -x;\ @set -x;\
cd $(DESTDIR)$(libdir);\ cd '$(DESTDIR)$(libdir)';\
for ext in a la so so.@PNGLIB_MAJOR@@PNGLIB_MINOR@.@PNGLIB_RELEASE@ sl dylib dll.a; do\ for ext in a la so so.@PNGLIB_MAJOR@@PNGLIB_MINOR@.@PNGLIB_RELEASE@\
sl dylib dll.a; do\
rm -f libpng.$$ext;\ rm -f libpng.$$ext;\
if test -f $(PNGLIB_BASENAME).$$ext; then\ if test -f $(PNGLIB_BASENAME).$$ext; then\
$(LN_S) $(PNGLIB_BASENAME).$$ext libpng.$$ext;\ $(LN_S) $(PNGLIB_BASENAME).$$ext libpng.$$ext;\
@@ -259,9 +264,9 @@ install-exec-hook:
done done
uninstall-hook: uninstall-hook:
cd $(DESTDIR)$(includedir); rm -f png.h pngconf.h pnglibconf.h cd '$(DESTDIR)$(includedir)'; rm -f png.h pngconf.h pnglibconf.h
rm -f $(DESTDIR)$(pkgconfigdir)/libpng.pc rm -f '$(DESTDIR)$(pkgconfigdir)/libpng.pc'
rm -f $(DESTDIR)$(bindir)/libpng-config rm -f '$(DESTDIR)$(bindir)/libpng-config'
rm -f $(DESTDIR)$(libdir)/libpng.a rm -f '$(DESTDIR)$(libdir)/libpng.a'
rm -f $(DESTDIR)$(libdir)/libpng.la rm -f '$(DESTDIR)$(libdir)/libpng.la'
rm -f $(DESTDIR)$(libdir)/libpng.dll.a rm -f '$(DESTDIR)$(libdir)/libpng.dll.a'

2
README
View File

@@ -1,4 +1,4 @@
README for libpng version 1.6.0beta33 - December 10, 2012 (shared library 16.0) README for libpng version 1.7.0alpha03 - December 19, 2012 (shared library 17.0)
See the note about version numbers near the top of png.h See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng. See INSTALL for instructions on how to install libpng.

86
arm/arm_init.c Normal file
View File

@@ -0,0 +1,86 @@
/* arm_init.c - NEON optimised filter functions
*
* Copyright (c) 2012 Glenn Randers-Pehrson
* Written by Mans Rullgard, 2011.
* 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
*/
#include "../pngpriv.h"
/* __arm__ is defined by GCC, MSVC defines _M_ARM to the ARM version number */
#if defined __linux__ && defined __arm__
#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__ && __arm__ */
void
png_init_filter_functions_neon(png_structrp pp, unsigned int bpp)
{
#ifdef __arm__
#ifdef __linux__
if (!png_have_hwcap(HWCAP_NEON))
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;
}
#else
PNG_UNUSED(pp)
PNG_UNUSED(bpp)
#endif
}

View File

@@ -3,12 +3,14 @@
* *
* Copyright (c) 2011 Glenn Randers-Pehrson * Copyright (c) 2011 Glenn Randers-Pehrson
* Written by Mans Rullgard, 2011. * Written by Mans Rullgard, 2011.
* Last changed in libpng 1.5.7 [December 15, 2011]
* *
* This code is released under the libpng license. * This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer * For conditions of distribution and use, see the disclaimer
* and license in png.h * and license in png.h
*/ */
#ifdef __arm__
#if defined(__linux__) && defined(__ELF__) #if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */ .section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
#endif #endif
@@ -223,3 +225,4 @@ func png_read_filter_row_paeth3_neon, export=1
pop {r4,pc} pop {r4,pc}
endfunc endfunc
#endif

View File

@@ -18,7 +18,7 @@ AC_PREREQ([2.68])
dnl Version number stuff here: dnl Version number stuff here:
AC_INIT([libpng],[1.6.0beta33],[png-mng-implement@lists.sourceforge.net]) AC_INIT([libpng],[1.7.0alpha03],[png-mng-implement@lists.sourceforge.net])
AC_CONFIG_MACRO_DIR([scripts]) AC_CONFIG_MACRO_DIR([scripts])
# libpng does not follow GNU file name conventions (hence 'foreign') # libpng does not follow GNU file name conventions (hence 'foreign')
@@ -37,9 +37,9 @@ dnl automake, so the following is not necessary (and is not defined anyway):
dnl AM_PREREQ([1.11.2]) dnl AM_PREREQ([1.11.2])
dnl stop configure from automagically running automake dnl stop configure from automagically running automake
PNGLIB_VERSION=1.6.0beta33 PNGLIB_VERSION=1.7.0alpha03
PNGLIB_MAJOR=1 PNGLIB_MAJOR=1
PNGLIB_MINOR=6 PNGLIB_MINOR=7
PNGLIB_RELEASE=0 PNGLIB_RELEASE=0
dnl End of version number stuff dnl End of version number stuff
@@ -115,31 +115,140 @@ AC_ARG_ENABLE(werror,
# Checks for header files. # Checks for header files.
AC_HEADER_STDC AC_HEADER_STDC
AC_CHECK_HEADERS([malloc.h stdlib.h string.h strings.h]) # Headers used in pngpriv.h:
AC_CHECK_HEADERS([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])
# Additional requirements of contrib/libtests/tarith.c:
AC_CHECK_HEADERS([assert.h])
# Checks for typedefs, structures, and compiler characteristics. # Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST # Most of these have been removed from 1.7.0 because they checked for non-ANSI-C
AC_TYPE_SIZE_T # behaviors and the result were, anyway, not used by earlier versions of libpng.
AC_STRUCT_TM
AC_C_RESTRICT AC_C_RESTRICT
# Checks for library functions. # Checks for library functions; these need to be in order, least demanding to
AC_FUNC_STRTOD # most because the -l directives are added to the head of the list at each
AC_CHECK_FUNCS([memset], , AC_MSG_ERROR(memset not found in libc)) # check.
AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_MSG_ERROR(cannot find pow)) ) # ANSI-C functions: all are required but they don't have to be implemented in
AC_ARG_WITH(zlib-prefix, # libc, it is perfectly ok to configure with an extra, wrapper, library preset
AS_HELP_STRING([[[--with-zlib-prefix]]], # in LIBS. NOTE: this list may not be complete
[prefix that may have been used in installed zlib]), AC_CHECK_FUNCS([memset memcpy strncpy],,
[ZPREFIX=${withval}], AC_MSG_FAILURE([missing ANSI-C functions]))
[ZPREFIX='z_'])
AC_CHECK_LIB(z, zlibVersion, , # floor and ceil are required for FLOATING_POINT, but they can be turned off on
AC_CHECK_LIB(z, ${ZPREFIX}zlibVersion, , AC_MSG_ERROR(zlib not installed))) # 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 # 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 # 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. # library (typically), it's not an error if it is not found.
AC_CHECK_LIB([m], [feenableexcept]) AC_SEARCH_LIBS([feenableexcept],[m],AC_DEFINE([HAVE_FEENABLEEXCEPT],[1],
AC_CHECK_FUNCS([feenableexcept]) [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]) AC_MSG_CHECKING([if using Solaris linker])
SLD=`$LD --version 2>&1 | grep Solaris` SLD=`$LD --version 2>&1 | grep Solaris`
@@ -241,16 +350,18 @@ AC_SUBST([AM_CCASFLAGS], [-Wa,--noexecstack])
AC_ARG_ENABLE([arm-neon], AC_ARG_ENABLE([arm-neon],
AS_HELP_STRING([[[--enable-arm-neon]]], [Enable ARM NEON optimizations]), AS_HELP_STRING([[[--enable-arm-neon]]], [Enable ARM NEON optimizations]),
[if test "${enableval}" = "yes"; then [if test "${enableval}" = "yes"; then
AC_DEFINE([PNG_ARM_NEON], [1], [Enable ARM NEON optimizations]) AC_DEFINE([PNG_FILTER_OPTIMIZATIONS],
AC_DEFINE([PNG_ALIGNED_MEMORY_SUPPORTED], [1], [Align row buffers]) [png_init_filter_functions_neon],
[ARM NEON filter initialization function])
AC_DEFINE([PNG_ALIGNED_MEMORY_SUPPORTED], [1],
[Align row buffers])
fi]) fi])
AM_CONDITIONAL([PNG_ARM_NEON], [test "${enable_arm_neon:-no}" = yes]) AM_CONDITIONAL([PNG_ARM_NEON], [test "${enable_arm_neon:-no}" = yes])
AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]]) AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
# Config files, substituting as above # Config files, substituting as above
AC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in]) AC_CONFIG_FILES([Makefile libpng.pc])
AC_CONFIG_FILES([libpng-config:libpng-config.in], AC_CONFIG_FILES([libpng-config], [chmod +x libpng-config])
[chmod +x libpng-config])
AC_OUTPUT AC_OUTPUT

View File

@@ -23,9 +23,9 @@
# macros -------------------------------------------------------------------- # macros --------------------------------------------------------------------
PNGINC = -I/usr/local/include/libpng16 PNGINC = -I/usr/local/include/libpng17
PNGLIB = -L/usr/local/lib -lpng16 # dynamically linked against libpng PNGLIB = -L/usr/local/lib -lpng17 # dynamically linked against libpng
#PNGLIB = /usr/local/lib/libpng16.a # statically linked against libpng #PNGLIB = /usr/local/lib/libpng17.a # statically linked against libpng
# or: # or:
#PNGINC = -I../.. #PNGINC = -I../..
#PNGLIB = -L../.. -lpng #PNGLIB = -L../.. -lpng

View File

@@ -26,14 +26,14 @@
# macros -------------------------------------------------------------------- # macros --------------------------------------------------------------------
#PNGDIR = /usr/local/lib #PNGDIR = /usr/local/lib
#PNGINC = -I/usr/local/include/libpng16 #PNGINC = -I/usr/local/include/libpng17
#PNGLIBd = -L$(PNGDIR) -lpng16 # dynamically linked, installed libpng #PNGLIBd = -L$(PNGDIR) -lpng17 # dynamically linked, installed libpng
#PNGLIBs = $(PNGDIR)/libpng16.a # statically linked, installed libpng #PNGLIBs = $(PNGDIR)/libpng17.a # statically linked, installed libpng
# or: # or:
PNGDIR = ../..# this one is for libpng-x.y.z/contrib/gregbook builds PNGDIR = ../..# this one is for libpng-x.y.z/contrib/gregbook builds
#PNGDIR = ../libpng #PNGDIR = ../libpng
PNGINC = -I$(PNGDIR) PNGINC = -I$(PNGDIR)
PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng16 # dynamically linked PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng17 # dynamically linked
PNGLIBs = $(PNGDIR)/libpng.a # statically linked, local libpng PNGLIBs = $(PNGDIR)/libpng.a # statically linked, local libpng
ZDIR = /usr/local/lib ZDIR = /usr/local/lib

View File

@@ -39,8 +39,10 @@
*/ */
#ifdef PNG_FREESTANDING_TESTS #ifdef PNG_FREESTANDING_TESTS
# include <png.h> # include <png.h>
# include <zlib.h> /* For crc32 */
#else #else
# include "../../png.h" # include "../../png.h"
# include PNG_ZLIB_HEADER
#endif #endif
#ifdef PNG_WRITE_SUPPORTED /* else pngvalid can do nothing */ #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 # define png_const_structp png_structp
#endif #endif
#include <zlib.h> /* For crc32 */
#include <float.h> /* For floating point constants */ #include <float.h> /* For floating point constants */
#include <stdlib.h> /* For malloc */ #include <stdlib.h> /* For malloc */
#include <string.h> /* For memcpy, memset */ #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 static int
next_format(png_bytep colour_type, png_bytep bit_depth, 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) 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; return 1;
} }
@@ -1828,6 +1833,7 @@ typedef struct png_modifier
double maxout16; /* Maximum output value error */ double maxout16; /* Maximum output value error */
double maxabs16; /* Absolute sample error 0..1 */ double maxabs16; /* Absolute sample error 0..1 */
double maxcalc16;/* 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% */ double maxpc16; /* Percentage sample error 0..100% */
/* This is set by transforms that need to allow a higher limit, it is an /* 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? */ /* Run the odd-sized image and interlace read/write tests? */
unsigned int test_size :1; 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; 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 :1;
unsigned int use_input_precision_sbit :1; unsigned int use_input_precision_sbit :1;
unsigned int use_input_precision_16to8 :1; unsigned int use_input_precision_16to8 :1;
@@ -1880,8 +1891,8 @@ typedef struct png_modifier
*/ */
unsigned int calculations_use_input_precision :1; unsigned int calculations_use_input_precision :1;
/* If set assume that the calculations are done in 16 bits even if both input /* If set assume that the calculations are done in 16 bits even if the sample
* and output are 8 bit or less. * depth is 8 bits.
*/ */
unsigned int assume_16_bit_calculations :1; unsigned int assume_16_bit_calculations :1;
@@ -1936,6 +1947,7 @@ modifier_init(png_modifier *pm)
pm->test_uses_encoding = 0; pm->test_uses_encoding = 0;
pm->maxout8 = pm->maxpc8 = pm->maxabs8 = pm->maxcalc8 = 0; pm->maxout8 = pm->maxpc8 = pm->maxabs8 = pm->maxcalc8 = 0;
pm->maxout16 = pm->maxpc16 = pm->maxabs16 = pm->maxcalc16 = 0; pm->maxout16 = pm->maxpc16 = pm->maxabs16 = pm->maxcalc16 = 0;
pm->maxcalcG = 0;
pm->limit = 4E-3; pm->limit = 4E-3;
pm->log8 = pm->log16 = 0; /* Means 'off' */ pm->log8 = pm->log16 = 0; /* Means 'off' */
pm->error_gray_2 = pm->error_gray_4 = pm->error_gray_8 = 0; 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_sbit = 0;
pm->use_input_precision_16to8 = 0; pm->use_input_precision_16to8 = 0;
pm->calculations_use_input_precision = 0; pm->calculations_use_input_precision = 0;
pm->assume_16_bit_calculations = 0;
pm->test_gamma_threshold = 0; pm->test_gamma_threshold = 0;
pm->test_gamma_transform = 0; pm->test_gamma_transform = 0;
pm->test_gamma_sbit = 0; pm->test_gamma_sbit = 0;
@@ -1964,8 +1977,16 @@ modifier_init(png_modifier *pm)
} }
#ifdef PNG_READ_TRANSFORMS_SUPPORTED #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 /* 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 * 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 * bit precision. This only affects those of the following limits that pertain
@@ -1973,8 +1994,8 @@ modifier_init(png_modifier *pm)
* called directly. * called directly.
*/ */
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED #ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
static double digitize(PNG_CONST png_modifier *pm, double value, #if DIGITIZE
int sample_depth, int do_round) 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 /* '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 * 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 * rounding and 'do_round' should be 1, if it is 0 the digitized value will
* be truncated. * be truncated.
*/ */
PNG_CONST unsigned int digitization_factor = PNG_CONST unsigned int digitization_factor = (1U << depth) -1;
(pm->assume_16_bit_calculations || sample_depth == 16) ? 65535 : 255;
/* Limiting the range is done as a convenience to the caller - it's easier to /* 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. * do it once here than every time at the call site.
*/ */
if (value <= 0) if (value <= 0)
value = 0; value = 0;
else if (value >= 1) else if (value >= 1)
value = 1; value = 1;
@@ -1998,31 +2019,30 @@ static double digitize(PNG_CONST png_modifier *pm, double value,
return floor(value)/digitization_factor; return floor(value)/digitization_factor;
} }
#endif #endif
#endif /* RGB_TO_GRAY */
#if (defined PNG_READ_GAMMA_SUPPORTED) ||\ #ifdef PNG_READ_GAMMA_SUPPORTED
(defined PNG_READ_RGB_TO_GRAY_SUPPORTED)
static double abserr(PNG_CONST png_modifier *pm, int in_depth, int out_depth) 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 /* Absolute error permitted in linear values - affected by the bit depth of
* the calculations. * the calculations.
*/ */
if (pm->assume_16_bit_calculations || (out_depth == 16 && (in_depth == 16 || if (pm->assume_16_bit_calculations ||
!pm->calculations_use_input_precision))) (pm->calculations_use_input_precision ? in_depth : out_depth) == 16)
return pm->maxabs16; return pm->maxabs16;
else else
return pm->maxabs8; return pm->maxabs8;
} }
#endif
#ifdef PNG_READ_GAMMA_SUPPORTED
static double calcerr(PNG_CONST png_modifier *pm, int in_depth, int out_depth) static double calcerr(PNG_CONST png_modifier *pm, int in_depth, int out_depth)
{ {
/* Error in the linear composition arithmetic - only relevant when /* Error in the linear composition arithmetic - only relevant when
* composition actually happens (0 < alpha < 1). * composition actually happens (0 < alpha < 1).
*/ */
if (pm->assume_16_bit_calculations || (out_depth == 16 && (in_depth == 16 || if ((pm->calculations_use_input_precision ? in_depth : out_depth) == 16)
!pm->calculations_use_input_precision)))
return pm->maxcalc16; return pm->maxcalc16;
else if (pm->assume_16_bit_calculations)
return pm->maxcalcG;
else else
return pm->maxcalc8; 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 /* Percentage error permitted in the linear values. Note that the specified
* value is a percentage but this routine returns a simple number. * value is a percentage but this routine returns a simple number.
*/ */
if (pm->assume_16_bit_calculations || (out_depth == 16 && (in_depth == 16 || if (pm->assume_16_bit_calculations ||
!pm->calculations_use_input_precision))) (pm->calculations_use_input_precision ? in_depth : out_depth) == 16)
return pm->maxpc16 * .01; return pm->maxpc16 * .01;
else else
return pm->maxpc8 * .01; 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) if (out_depth == 4)
return .90644-.5; return .90644-.5;
if (out_depth == 16 && (in_depth == 16 || if ((pm->calculations_use_input_precision ? in_depth : out_depth) == 16)
!pm->calculations_use_input_precision))
return pm->maxout16; return pm->maxout16;
/* This is the case where the value was calculated at 8-bit precision then /* 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; return pm->log8;
} }
if (out_depth == 16 && (in_depth == 16 || if ((pm->calculations_use_input_precision ? in_depth : out_depth) == 16)
!pm->calculations_use_input_precision))
{ {
if (pm->log16 == 0) if (pm->log16 == 0)
return 65536; 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, static int output_quantization_factor(PNG_CONST png_modifier *pm, int in_depth,
int out_depth) int out_depth)
{ {
if (out_depth == 16 && in_depth != 16 if (out_depth == 16 && in_depth != 16 &&
&& pm->calculations_use_input_precision) pm->calculations_use_input_precision)
return 257; return 257;
else else
return 1; return 1;
@@ -3473,7 +3491,7 @@ make_transform_images(png_store *ps)
/* Use next_format to enumerate all the combinations we test, including /* Use next_format to enumerate all the combinations we test, including
* generating multiple low bit depth palette images. * 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; int interlace_type;
@@ -5784,12 +5802,9 @@ transform_image_validate(transform_display *dp, png_const_structp pp,
memset(out_palette, 0x5e, sizeof out_palette); memset(out_palette, 0x5e, sizeof out_palette);
/* assume-8-bit-calculations means assume that if the input has 8 bit /* use-input-precision means assume that if the input has 8 bit (or less)
* (or less) samples and the output has 16 bit samples the calculations * samples and the output has 16 bit samples the calculations will be done
* will be done with 8 bit precision, not 16. * with 8 bit precision, not 16.
*
* TODO: fix this in libpng; png_set_expand_16 should cause 16 bit
* calculations to be used throughout.
*/ */
if (in_ct == PNG_COLOR_TYPE_PALETTE || in_bd < 16) if (in_ct == PNG_COLOR_TYPE_PALETTE || in_bd < 16)
in_sample_depth = 8; in_sample_depth = 8;
@@ -5800,7 +5815,8 @@ transform_image_validate(transform_display *dp, png_const_structp pp,
!dp->pm->calculations_use_input_precision) !dp->pm->calculations_use_input_precision)
digitization_error = .5; 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 else
digitization_error = .5 * 257; digitization_error = .5 * 257;
@@ -6616,10 +6632,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) if (that->this.bit_depth == 16 || pm->assume_16_bit_calculations)
{ {
/* The 16 bit case ends up producing a maximum error of about /* The computations have the form:
* +/-5 in 65535, allow for +/-8 with the given gamma. *
* 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 else
@@ -6637,7 +6666,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 /* With no gamma correction a large error comes from the truncation of the
* calculation in the 8 bit case, allow for that here. * 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; that->pm->limit += 4E-3;
} }
} }
@@ -6782,9 +6811,14 @@ image_transform_png_set_rgb_to_gray_mod(PNG_CONST image_transform *this,
image_pixel_convert_PLTE(that); image_pixel_convert_PLTE(that);
/* Image now has RGB channels... */ /* Image now has RGB channels... */
# if DIGITIZE
{ {
PNG_CONST png_modifier *pm = display->pm; 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; int isgray;
double r, g, b; double r, g, b;
double rlo, rhi, glo, ghi, blo, bhi, graylo, grayhi; double rlo, rhi, glo, ghi, blo, bhi, graylo, grayhi;
@@ -6800,28 +6834,28 @@ image_transform_png_set_rgb_to_gray_mod(PNG_CONST image_transform *this,
*/ */
r = rlo = rhi = that->redf; r = rlo = rhi = that->redf;
rlo -= that->rede; rlo -= that->rede;
rlo = digitize(pm, rlo, sample_depth, 1/*round*/); rlo = digitize(rlo, calc_depth, 1/*round*/);
rhi += that->rede; rhi += that->rede;
rhi = digitize(pm, rhi, sample_depth, 1/*round*/); rhi = digitize(rhi, calc_depth, 1/*round*/);
g = glo = ghi = that->greenf; g = glo = ghi = that->greenf;
glo -= that->greene; glo -= that->greene;
glo = digitize(pm, glo, sample_depth, 1/*round*/); glo = digitize(glo, calc_depth, 1/*round*/);
ghi += that->greene; ghi += that->greene;
ghi = digitize(pm, ghi, sample_depth, 1/*round*/); ghi = digitize(ghi, calc_depth, 1/*round*/);
b = blo = bhi = that->bluef; b = blo = bhi = that->bluef;
blo -= that->bluee; blo -= that->bluee;
blo = digitize(pm, blo, sample_depth, 1/*round*/); blo = digitize(blo, calc_depth, 1/*round*/);
bhi += that->greene; bhi += that->greene;
bhi = digitize(pm, bhi, sample_depth, 1/*round*/); bhi = digitize(bhi, calc_depth, 1/*round*/);
isgray = r==g && g==b; isgray = r==g && g==b;
if (data.gamma != 1) if (data.gamma != 1)
{ {
PNG_CONST double power = 1/data.gamma; 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 /* 'abse' is the absolute error permitted in linear calculations. It
* is used here to capture the error permitted in the handling * is used here to capture the error permitted in the handling
@@ -6830,16 +6864,16 @@ image_transform_png_set_rgb_to_gray_mod(PNG_CONST image_transform *this,
* where the real errors are introduced. * where the real errors are introduced.
*/ */
r = pow(r, power); r = pow(r, power);
rlo = digitize(pm, pow(rlo, power)-abse, sample_depth, 1); rlo = digitize(pow(rlo, power)-abse, calc_depth, 1);
rhi = digitize(pm, pow(rhi, power)+abse, sample_depth, 1); rhi = digitize(pow(rhi, power)+abse, calc_depth, 1);
g = pow(g, power); g = pow(g, power);
glo = digitize(pm, pow(glo, power)-abse, sample_depth, 1); glo = digitize(pow(glo, power)-abse, calc_depth, 1);
ghi = digitize(pm, pow(ghi, power)+abse, sample_depth, 1); ghi = digitize(pow(ghi, power)+abse, calc_depth, 1);
b = pow(b, power); b = pow(b, power);
blo = digitize(pm, pow(blo, power)-abse, sample_depth, 1); blo = digitize(pow(blo, power)-abse, calc_depth, 1);
bhi = digitize(pm, pow(bhi, power)+abse, sample_depth, 1); bhi = digitize(pow(bhi, power)+abse, calc_depth, 1);
} }
/* Now calculate the actual gray values. Although the error in the /* Now calculate the actual gray values. Although the error in the
@@ -6856,18 +6890,18 @@ image_transform_png_set_rgb_to_gray_mod(PNG_CONST image_transform *this,
b * data.blue_coefficient; 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; 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) + 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) if (graylo <= 0)
graylo = 0; graylo = 0;
grayhi = digitize(pm, rhi * (data.red_coefficient+ce) + grayhi = digitize(rhi * (data.red_coefficient+ce) +
ghi * (data.green_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) if (grayhi >= 1)
grayhi = 1; grayhi = 1;
} }
@@ -6878,8 +6912,8 @@ image_transform_png_set_rgb_to_gray_mod(PNG_CONST image_transform *this,
PNG_CONST double power = data.gamma; PNG_CONST double power = data.gamma;
gray = pow(gray, power); gray = pow(gray, power);
graylo = digitize(pm, pow(graylo, power), sample_depth, 1); graylo = digitize(pow(graylo, power), sample_depth, 1);
grayhi = digitize(pm, pow(grayhi, power), sample_depth, 1); grayhi = digitize(pow(grayhi, power), sample_depth, 1);
} }
/* Now the error can be calculated. /* Now the error can be calculated.
@@ -6897,7 +6931,7 @@ image_transform_png_set_rgb_to_gray_mod(PNG_CONST image_transform *this,
err = fabs(graylo-gray); err = fabs(graylo-gray);
/* Check that this worked: */ /* Check that this worked: */
if (err > display->pm->limit) if (err > pm->limit)
{ {
size_t pos = 0; size_t pos = 0;
char buffer[128]; char buffer[128];
@@ -6905,12 +6939,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 = safecat(buffer, sizeof buffer, pos, "rgb_to_gray error ");
pos = safecatd(buffer, sizeof buffer, pos, err, 6); pos = safecatd(buffer, sizeof buffer, pos, err, 6);
pos = safecat(buffer, sizeof buffer, pos, " exceeds limit "); pos = safecat(buffer, sizeof buffer, pos, " exceeds limit ");
pos = safecatd(buffer, sizeof buffer, pos, pos = safecatd(buffer, sizeof buffer, pos, pm->limit, 6);
display->pm->limit, 6);
png_error(pp, buffer); 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->bluef = that->greenf = that->redf = gray;
that->bluee = that->greene = that->rede = err; that->bluee = that->greene = that->rede = err;
@@ -6959,7 +7101,7 @@ IT(rgb_to_gray);
* int background_gamma_code, int need_expand, * int background_gamma_code, int need_expand,
* png_fixed_point background_gamma) * 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) #define data ITDATA(background)
static image_pixel data; static image_pixel data;
@@ -6970,6 +7112,7 @@ image_transform_png_set_background_set(PNG_CONST image_transform *this,
{ {
png_byte colour_type, bit_depth; png_byte colour_type, bit_depth;
png_byte random_bytes[8]; /* 8 bytes - 64 bits - the biggest pixel */ png_byte random_bytes[8]; /* 8 bytes - 64 bits - the biggest pixel */
int expand;
png_color_16 back; png_color_16 back;
/* We need a background colour, because we don't know exactly what transforms /* We need a background colour, because we don't know exactly what transforms
@@ -6987,10 +7130,14 @@ image_transform_png_set_background_set(PNG_CONST image_transform *this,
{ {
colour_type = PNG_COLOR_TYPE_RGB; colour_type = PNG_COLOR_TYPE_RGB;
bit_depth = 8; bit_depth = 8;
expand = 0; /* passing in an RGB not a pixel index */
} }
else else
{
bit_depth = that->this.bit_depth; bit_depth = that->this.bit_depth;
expand = 1;
}
image_pixel_init(&data, random_bytes, colour_type, image_pixel_init(&data, random_bytes, colour_type,
bit_depth, 0/*x*/, 0/*unused: palette*/); bit_depth, 0/*x*/, 0/*unused: palette*/);
@@ -7011,11 +7158,9 @@ image_transform_png_set_background_set(PNG_CONST image_transform *this,
back.gray = (png_uint_16)data.red; back.gray = (png_uint_16)data.red;
# ifdef PNG_FLOATING_POINT_SUPPORTED # ifdef PNG_FLOATING_POINT_SUPPORTED
png_set_background(pp, &back, PNG_BACKGROUND_GAMMA_FILE, 1/*need expand*/, png_set_background(pp, &back, PNG_BACKGROUND_GAMMA_FILE, expand, 0);
0);
# else # else
png_set_background_fixed(pp, &back, PNG_BACKGROUND_GAMMA_FILE, png_set_background_fixed(pp, &back, PNG_BACKGROUND_GAMMA_FILE, expand, 0);
1/*need expand*/, 0);
# endif # endif
this->next->set(this->next, that, pp, pi); this->next->set(this->next, that, pp, pi);
@@ -7347,7 +7492,7 @@ perform_transform_test(png_modifier *pm)
png_byte bit_depth = 0; png_byte bit_depth = 0;
unsigned int palette_number = 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; png_uint_32 counter = 0;
size_t base_pos; size_t base_pos;
@@ -8032,14 +8177,25 @@ gamma_component_validate(PNG_CONST char *name, PNG_CONST validate_info *vi,
* passed. Don't do these additional tests here - just log the * passed. Don't do these additional tests here - just log the
* original [es_lo..es_hi] values. * 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 /* Ok, something is wrong - this actually happens in current libpng
* 16-to-8 processing. Assume that the input value (id, adjusted * 16-to-8 processing. Assume that the input value (id, adjusted
* for sbit) can be anywhere between value-.5 and value+.5 - quite a * for sbit) can be anywhere between value-.5 and value+.5 - quite a
* large range if sbit is low. * 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) if (tmp <= 0)
tmp = 0; tmp = 0;
@@ -8058,10 +8214,10 @@ gamma_component_validate(PNG_CONST char *name, PNG_CONST validate_info *vi,
if (is_lo < 0) if (is_lo < 0)
is_lo = 0; is_lo = 0;
tmp = (isbit + .5)/sbit_max; tmp = (isbit + SBIT_ERROR)/sbit_max;
if (tmp <= 0) if (tmp >= 1)
tmp = 0; tmp = 1;
else if (alpha >= 0 && vi->file_inverse > 0 && tmp < 1) else if (alpha >= 0 && vi->file_inverse > 0 && tmp < 1)
tmp = pow(tmp, vi->file_inverse); tmp = pow(tmp, vi->file_inverse);
@@ -8378,7 +8534,7 @@ gamma_image_validate(gamma_display *dp, png_const_structp pp,
* Because there is limited precision in the input it is arguable that * 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. * 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' * 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; PNG_CONST unsigned int samples_per_pixel = (out_ct & 2U) ? 3U : 1U;
int processing; int processing;
@@ -8720,7 +8876,7 @@ perform_gamma_threshold_tests(png_modifier *pm)
* fact this test is somewhat excessive since libpng doesn't make this * fact this test is somewhat excessive since libpng doesn't make this
* decision based on colour type or bit depth! * 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) if (palette_number == 0)
{ {
double test_gamma = 1.0; double test_gamma = 1.0;
@@ -8781,7 +8937,7 @@ static void perform_gamma_transform_tests(png_modifier *pm)
png_byte bit_depth = 0; png_byte bit_depth = 0;
unsigned int palette_number = 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; unsigned int i, j;
@@ -8811,7 +8967,7 @@ static void perform_gamma_sbit_tests(png_modifier *pm)
png_byte colour_type = 0, bit_depth = 0; png_byte colour_type = 0, bit_depth = 0;
unsigned int npalette = 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 && if ((colour_type & PNG_COLOR_MASK_ALPHA) == 0 &&
((colour_type == 3 && sbit < 8) || ((colour_type == 3 && sbit < 8) ||
(colour_type != 3 && sbit < bit_depth))) (colour_type != 3 && sbit < bit_depth)))
@@ -8846,6 +9002,7 @@ static void perform_gamma_scale16_tests(png_modifier *pm)
# ifndef PNG_MAX_GAMMA_8 # ifndef PNG_MAX_GAMMA_8
# define PNG_MAX_GAMMA_8 11 # define PNG_MAX_GAMMA_8 11
# endif # endif
# define SBIT_16_TO_8 PNG_MAX_GAMMA_8
/* Include the alpha cases here. Note that sbit matches the internal value /* Include the alpha cases here. Note that sbit matches the internal value
* used by the library - otherwise we will get spurious errors from the * used by the library - otherwise we will get spurious errors from the
* internal sbit style approximation. * internal sbit style approximation.
@@ -8863,28 +9020,28 @@ static void perform_gamma_scale16_tests(png_modifier *pm)
fabs(pm->gammas[j]/pm->gammas[i]-1) >= PNG_GAMMA_THRESHOLD) fabs(pm->gammas[j]/pm->gammas[i]-1) >= PNG_GAMMA_THRESHOLD)
{ {
gamma_transform_test(pm, 0, 16, 0, pm->interlace_type, 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*/); pm->use_input_precision_16to8, 1 /*scale16*/);
if (fail(pm)) if (fail(pm))
return; return;
gamma_transform_test(pm, 2, 16, 0, pm->interlace_type, 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*/); pm->use_input_precision_16to8, 1 /*scale16*/);
if (fail(pm)) if (fail(pm))
return; return;
gamma_transform_test(pm, 4, 16, 0, pm->interlace_type, 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*/); pm->use_input_precision_16to8, 1 /*scale16*/);
if (fail(pm)) if (fail(pm))
return; return;
gamma_transform_test(pm, 6, 16, 0, pm->interlace_type, 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*/); pm->use_input_precision_16to8, 1 /*scale16*/);
if (fail(pm)) if (fail(pm))
@@ -9030,7 +9187,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 /* Skip the non-alpha cases - there is no setting of a transparency colour at
* present. * 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) if ((colour_type & PNG_COLOR_MASK_ALPHA) != 0)
{ {
unsigned int i, j; unsigned int i, j;
@@ -9052,31 +9209,46 @@ perform_gamma_composition_tests(png_modifier *pm, int do_background,
static void static void
init_gamma_errors(png_modifier *pm) init_gamma_errors(png_modifier *pm)
{ {
pm->error_gray_2 = pm->error_gray_4 = pm->error_gray_8 = 0; /* Use -1 to catch tests that were not actually run */
pm->error_color_8 = 0; pm->error_gray_2 = pm->error_gray_4 = pm->error_gray_8 = -1.;
pm->error_indexed = 0; pm->error_color_8 = -1.;
pm->error_gray_16 = pm->error_color_16 = 0; pm->error_indexed = -1.;
pm->error_gray_16 = pm->error_color_16 = -1.;
} }
static void 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) 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) if (low_bit_depth)
{ {
printf(" 2 bit gray: %.5f\n", pm->error_gray_2); print_one(" 2 bit gray: ", pm->error_gray_2);
printf(" 4 bit gray: %.5f\n", pm->error_gray_4); print_one(" 4 bit gray: ", pm->error_gray_4);
printf(" 8 bit gray: %.5f\n", pm->error_gray_8); print_one(" 8 bit gray: ", pm->error_gray_8);
printf(" 8 bit color: %.5f\n", pm->error_color_8); print_one(" 8 bit color:", pm->error_color_8);
printf(" indexed: %.5f\n", pm->error_indexed); if (indexed)
print_one(" indexed: ", pm->error_indexed);
} }
#ifdef DO_16BIT print_one("16 bit gray: ", pm->error_gray_16);
printf(" 16 bit gray: %.5f\n", pm->error_gray_16); print_one("16 bit color:", pm->error_color_16);
printf(" 16 bit color: %.5f\n", pm->error_color_16);
#endif fflush(stdout);
} }
static void static void
@@ -9102,18 +9274,9 @@ perform_gamma_test(png_modifier *pm, int summary)
/* Now some real transforms. */ /* Now some real transforms. */
if (pm->test_gamma_transform) 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) if (summary)
{ {
fflush(stderr);
printf("Gamma correction error summary\n\n"); printf("Gamma correction error summary\n\n");
printf("The printed value is the maximum error in the pixel values\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"); printf("calculated by the libpng gamma correction code. The error\n");
@@ -9125,10 +9288,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("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("number (typically less than 5) for the 16 bit formats.\n");
printf("For performance reasons the value for 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"); printf("increases when the image file includes an sBIT chunk.\n");
fflush(stdout);
summarize_gamma_errors(pm, 0/*who*/, 1);
} }
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: */ /* The sbit tests produce much larger errors: */
@@ -9138,7 +9316,10 @@ perform_gamma_test(png_modifier *pm, int summary)
perform_gamma_sbit_tests(pm); perform_gamma_sbit_tests(pm);
if (summary) 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 */ #ifdef DO_16BIT /* Should be READ_16BIT_SUPPORTED */
@@ -9150,10 +9331,15 @@ perform_gamma_test(png_modifier *pm, int summary)
if (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 gray: %.5f\n", pm->error_gray_16);
printf(" 16 bit color: %.5f\n", pm->error_color_16); printf(" 16 bit color: %.5f\n", pm->error_color_16);
fflush(stdout);
} }
if (fail(pm))
return;
} }
#endif #endif
@@ -9177,7 +9363,10 @@ perform_gamma_test(png_modifier *pm, int summary)
pm->maxout8 = maxout8; pm->maxout8 = maxout8;
if (summary) if (summary)
summarize_gamma_errors(pm, "background", 1); summarize_gamma_errors(pm, "background", 1, 0/*indexed*/);
if (fail(pm))
return;
} }
#endif #endif
@@ -9202,7 +9391,10 @@ perform_gamma_test(png_modifier *pm, int summary)
pm->calculations_use_input_precision = 0; pm->calculations_use_input_precision = 0;
if (summary) if (summary)
summarize_gamma_errors(pm, "alpha mode", 1); summarize_gamma_errors(pm, "alpha mode", 1, 0/*indexed*/);
if (fail(pm))
return;
} }
#endif #endif
} }
@@ -9710,6 +9902,19 @@ int main(int argc, char **argv)
/* Default to error on warning: */ /* Default to error on warning: */
pm.this.treat_warnings_as_errors = 1; 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 */ /* Store the test gammas */
pm.gammas = gammas; pm.gammas = gammas;
pm.ngammas = (sizeof gammas) / (sizeof gammas[0]); pm.ngammas = (sizeof gammas) / (sizeof gammas[0]);
@@ -9720,13 +9925,16 @@ int main(int argc, char **argv)
pm.nencodings = (sizeof test_encodings) / (sizeof test_encodings[0]); pm.nencodings = (sizeof test_encodings) / (sizeof test_encodings[0]);
pm.sbitlow = 8U; /* because libpng doesn't do sBIT below 8! */ pm.sbitlow = 8U; /* because libpng doesn't do sBIT below 8! */
/* The following allows results to pass if they correspond to anything in the /* 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 * 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 * TODO: review this
*/ */
pm.use_input_precision_16to8 = 1U; 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). /* Some default values (set the behavior for 'make check' here).
* These values simply control the maximum error permitted in the gamma * These values simply control the maximum error permitted in the gamma
@@ -9737,11 +9945,12 @@ int main(int argc, char **argv)
*/ */
pm.maxout8 = .1; /* Arithmetic error in *encoded* value */ pm.maxout8 = .1; /* Arithmetic error in *encoded* value */
pm.maxabs8 = .00005; /* 1/20000 */ 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.maxpc8 = .499; /* I.e., .499% fractional error */
pm.maxout16 = .499; /* Error in *encoded* value */ pm.maxout16 = .499; /* Error in *encoded* value */
pm.maxabs16 = .00005;/* 1/20000 */ 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 /* 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 * perceive light level differences of 1% over a 100:1 range, so we need to
@@ -9888,13 +10097,16 @@ int main(int argc, char **argv)
pm.interlace_type = PNG_INTERLACE_ADAM7; pm.interlace_type = PNG_INTERLACE_ADAM7;
else if (strcmp(*argv, "--use-input-precision") == 0) 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) 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) 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) else if (strcmp(*argv, "--calculations-follow-bit-depth") == 0)
pm.calculations_use_input_precision = pm.calculations_use_input_precision =

View File

@@ -252,7 +252,7 @@ int main(int argc, char **argv)
while (fgets(filename, FILENAME_MAX+1, stdin)) while (fgets(filename, FILENAME_MAX+1, stdin))
{ {
int len = strlen(filename); size_t len = strlen(filename);
if (filename[len-1] == '\n') if (filename[len-1] == '\n')
{ {

View File

@@ -1,6 +1,6 @@
This demonstrates the use of PNG_USER_CONFIG and pngusr.h 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. and zlib.
Specify the location of the zlib source (1.2.1 or later) as ZLIBSRC Specify the location of the zlib source (1.2.1 or later) as ZLIBSRC

View File

@@ -8,9 +8,9 @@ LD=$(CC)
RM=rm -f RM=rm -f
#PNGPATH = /usr/local #PNGPATH = /usr/local
#PNGINC = -I$(PNGPATH)/include/libpng16 #PNGINC = -I$(PNGPATH)/include/libpng17
#PNGLIB = -L$(PNGPATH)/lib -lpng16 #PNGLIB = -L$(PNGPATH)/lib -lpng17
#PNGLIBS = $(PNGPATH)/lib/libpng16.a #PNGLIBS = $(PNGPATH)/lib/libpng17.a
PNGINC = -I../.. PNGINC = -I../..
PNGLIB = -L../.. -lpng PNGLIB = -L../.. -lpng
PNGLIBS = ../../libpng.a PNGLIBS = ../../libpng.a

238
contrib/tools/scale.c Normal file
View 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;
}

View File

@@ -39,7 +39,7 @@
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include <png.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) int main(int argc, const char **argv)
{ {

View File

@@ -1,6 +1,6 @@
libpng-manual.txt - A description on how to use and modify libpng libpng-manual.txt - A description on how to use and modify libpng
libpng version 1.6.0beta33 - December 10, 2012 libpng version 1.7.0alpha03 - December 19, 2012
Updated and distributed by Glenn Randers-Pehrson Updated and distributed by Glenn Randers-Pehrson
<glennrp at users.sourceforge.net> <glennrp at users.sourceforge.net>
Copyright (c) 1998-2011 Glenn Randers-Pehrson Copyright (c) 1998-2011 Glenn Randers-Pehrson
@@ -11,7 +11,7 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on: Based on:
libpng versions 0.97, January 1998, through 1.6.0beta33 - December 10, 2012 libpng versions 0.97, January 1998, through 1.7.0alpha03 - December 19, 2012
Updated and distributed by Glenn Randers-Pehrson Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2011 Glenn Randers-Pehrson Copyright (c) 1998-2011 Glenn Randers-Pehrson
@@ -42,10 +42,11 @@ 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 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 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 XII. Changes to Libpng from version 1.5.x to 1.6.x
XIII. Detecting libpng XIII. Changes to Libpng from version 1.6.x to 1.7.x
XIV. Source code repository XIV. Detecting libpng
XV. Coding style XV. Source code repository
XVI. Y2K Compliance in libpng XVI. Coding style
XVII. Y2K Compliance in libpng
I. Introduction I. Introduction
@@ -431,7 +432,7 @@ If you would rather avoid the complexity of setjmp/longjmp issues,
you can compile libpng with PNG_NO_SETJMP, in which case 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 more useful than abort(), as long as your function does not
return. return.
@@ -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, If you would rather avoid the complexity of setjmp/longjmp issues,
you can compile libpng with PNG_NO_SETJMP, in which case 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 more useful than abort(), as long as your function does not
return. return.
@@ -3083,8 +3084,8 @@ 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 although this isn't a requirement. Unlike the tIME chunk, the
"Creation Time" tEXt chunk is not expected to be automatically changed "Creation Time" tEXt chunk is not expected to be automatically changed
by the software. To facilitate the use of RFC 1123 dates, a function 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 png_convert_to_rfc1123_buffer(png_ptr, buffer, png_timep) is provided to
from PNG time to an RFC 1123 format string. The caller must provide convert from PNG time to an RFC 1123 format string. The caller must provide
a writeable buffer of at least 29 bytes. a writeable buffer of at least 29 bytes.
Writing unknown chunks Writing unknown chunks
@@ -3942,7 +3943,7 @@ Error handling in libpng is done through png_error() and png_warning().
Errors handled through png_error() are fatal, meaning that png_error() Errors handled through png_error() are fatal, meaning that png_error()
should never return to its caller. Currently, this is handled via should never return to its caller. Currently, this is handled via
setjmp() and longjmp() (unless you have compiled libpng with 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, but you could change this to do things like exit() if you should wish,
as long as your function does not return. as long as your function does not return.
@@ -4930,10 +4931,12 @@ The following API are now DEPRECATED:
png_info_init_3() png_info_init_3()
png_convert_to_rfc1123() which has been replaced png_convert_to_rfc1123() which has been replaced
with png_convert_to_rfc1123_buffer() with png_convert_to_rfc1123_buffer()
png_data_freer()
png_malloc_default() png_malloc_default()
png_free_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 png_get_io_chunk_name(), which has been replaced
with png_get_io_chunk_type(). The new with png_get_io_chunk_type(). The new
function returns a 32-bit integer instead of function returns a 32-bit integer instead of
@@ -4965,7 +4968,39 @@ 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 a pre-existing bug where the per-chunk 'keep' setting is ignored, and makes
it possible to skip IDAT chunks in the sequential reader. it possible to skip IDAT chunks in the sequential reader.
XIII. Detecting libpng 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(), 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 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 changed, and is unaffected by conditional compilation macros. It is the
@@ -4998,7 +5033,7 @@ simple verbal discriptions of bug fixes, reported either to the
SourceForge bug tracker, to the png-mng-implement at lists.sf.net SourceForge bug tracker, to the png-mng-implement at lists.sf.net
mailing list, or directly to glennrp. mailing list, or directly to glennrp.
XV. Coding style XVI. Coding style
Our coding style is similar to the "Allman" style, with curly Our coding style is similar to the "Allman" style, with curly
braces on separate lines: braces on separate lines:
@@ -5124,15 +5159,15 @@ Lines do not exceed 80 characters.
Other rules can be inferred by inspecting the libpng source. Other rules can be inferred by inspecting the libpng source.
XVI. Y2K Compliance in libpng XVII. Y2K Compliance in libpng
December 10, 2012 December 19, 2012
Since the PNG Development group is an ad-hoc body, we can't make Since the PNG Development group is an ad-hoc body, we can't make
an official declaration. an official declaration.
This is your unofficial assurance that libpng from version 0.71 and 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.0alpha03 are Y2K compliant. It is my belief that earlier
versions were also Y2K compliant. versions were also Y2K compliant.
Libpng only has two year fields. One is a 2-byte unsigned integer Libpng only has two year fields. One is a 2-byte unsigned integer

597
libpng.3

File diff suppressed because it is too large Load Diff

View File

@@ -1,21 +1,11 @@
.TH LIBPNGPF 3 "December 10, 2012" .TH LIBPNGPF 3 "December 19, 2012"
.SH NAME .SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.0beta33 libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0alpha03
(private functions) (private functions)
.SH SYNOPSIS .SH SYNOPSIS
\fB#include \fI"pngpriv.h" \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 that the private function prototypes are hidden in pngpriv.h and not accessible to applications. Look in pngpriv.h for the prototypes and a short description of each \fIfunction.
\fBAs of libpng version \fP\fI1.5.1\fP\fB, this section is no longer \fP\fImaintained\fP\fB, now \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
.SH DESCRIPTION .SH DESCRIPTION
The functions previously listed here are used privately by libpng and are not The functions previously listed here are used privately by libpng and are not

5
png.5
View File

@@ -1,4 +1,4 @@
.TH PNG 5 "December 10, 2012" .TH PNG 5 "December 19, 2012"
.SH NAME .SH NAME
png \- Portable Network Graphics (PNG) format png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION .SH DESCRIPTION
@@ -24,6 +24,7 @@ PNG specification (second edition), November 2003:
.IP .IP
.br .br
<http://www.w3.org/TR/2003/REC-PNG-20031110/ <http://www.w3.org/TR/2003/REC-PNG-20031110/
.LP
PNG 1.2 specification, July 1999: PNG 1.2 specification, July 1999:
.IP .IP
.br .br
@@ -58,7 +59,7 @@ Thomas Boutell and others (png-list).
.SH COPYRIGHT NOTICE .SH COPYRIGHT NOTICE
.LP .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. for conditions of use and distribution.
.LP .LP
The PNG Specification (Second Edition) is The PNG Specification (Second Edition) is

694
png.c
View File

@@ -1,7 +1,7 @@
/* png.c - location for general purpose libpng functions /* png.c - location for general purpose libpng functions
* *
* Last changed in libpng 1.6.0 [(PENDING RELEASE)] * Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Copyright (c) 1998-2012 Glenn Randers-Pehrson * Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -14,7 +14,7 @@
#include "pngpriv.h" #include "pngpriv.h"
/* Generate a compiler error if there is an old png.h in the search path. */ /* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_6_0beta33 Your_png_h_is_not_version_1_6_0beta33; typedef png_libpng_version_1_7_0alpha03 Your_png_h_is_not_version_1_7_0alpha03;
/* Tells libpng that we have already handled the first "num_bytes" bytes /* Tells libpng that we have already handled the first "num_bytes" bytes
* of the PNG file signature. If the PNG data is embedded into another * of the PNG file signature. If the PNG data is embedded into another
@@ -236,22 +236,21 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
*/ */
memset(&create_struct, 0, (sizeof create_struct)); memset(&create_struct, 0, (sizeof create_struct));
/* Added at libpng-1.2.6 */ /* These limits are only used on read at present, and if READ is not turned
# ifdef PNG_USER_LIMITS_SUPPORTED * on neither will USER_LIMITS be. The width/height and chunk malloc limits
* are constants, so if they cannot be set they don't get defined in
* png_struct, the user_chunk_cache limits is a down-counter, when it reaches
* 1 no more chunks will be handled. 0 means unlimited, consequently the
* limit is 1 more than the number of chunks that will be handled.
*/
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
create_struct.user_width_max = PNG_USER_WIDTH_MAX; create_struct.user_width_max = PNG_USER_WIDTH_MAX;
create_struct.user_height_max = PNG_USER_HEIGHT_MAX; create_struct.user_height_max = PNG_USER_HEIGHT_MAX;
create_struct.user_chunk_malloc_max = PNG_USER_CHUNK_MALLOC_MAX;
# ifdef PNG_USER_CHUNK_CACHE_MAX # endif
/* Added at libpng-1.2.43 and 1.4.0 */ # ifdef PNG_USER_LIMITS_SUPPORTED
create_struct.user_chunk_cache_max = PNG_USER_CHUNK_CACHE_MAX; /* Must exist even if the initial value is constant */
# endif create_struct.user_chunk_cache_max = PNG_USER_CHUNK_CACHE_MAX;
# ifdef PNG_USER_CHUNK_MALLOC_MAX
/* Added at libpng-1.2.43 and 1.4.1, required only for read but exists
* in png_struct regardless.
*/
create_struct.user_chunk_malloc_max = PNG_USER_CHUNK_MALLOC_MAX;
# endif
# endif # endif
/* The following two API calls simply set fields in png_struct, so it is safe /* The following two API calls simply set fields in png_struct, so it is safe
@@ -381,60 +380,6 @@ png_destroy_info_struct(png_const_structrp png_ptr, png_infopp info_ptr_ptr)
} }
} }
/* Initialize the info structure. This is now an internal function (0.89)
* and applications using it are urged to use png_create_info_struct()
* instead. Use deprecated in 1.6.0, internal use removed (used internally it
* is just a memset).
*
* NOTE: it is almost inconceivable that this API is used because it bypasses
* the user-memory mechanism and the user error handling/warning mechanisms in
* those cases where it does anything other than a memset.
*/
PNG_FUNCTION(void,PNGAPI
png_info_init_3,(png_infopp ptr_ptr, png_size_t png_info_struct_size),
PNG_DEPRECATED)
{
png_inforp info_ptr = *ptr_ptr;
png_debug(1, "in png_info_init_3");
if (info_ptr == NULL)
return;
if ((sizeof (png_info)) > png_info_struct_size)
{
*ptr_ptr = NULL;
/* The following line is why this API should not be used: */
free(info_ptr);
info_ptr = png_voidcast(png_inforp, png_malloc_base(NULL,
(sizeof *info_ptr)));
*ptr_ptr = info_ptr;
}
/* Set everything to 0 */
memset(info_ptr, 0, (sizeof *info_ptr));
}
/* The following API is not called internally */
void PNGAPI
png_data_freer(png_const_structrp png_ptr, png_inforp info_ptr,
int freer, png_uint_32 mask)
{
png_debug(1, "in png_data_freer");
if (png_ptr == NULL || info_ptr == NULL)
return;
if (freer == PNG_DESTROY_WILL_FREE_DATA)
info_ptr->free_me |= mask;
else if (freer == PNG_USER_WILL_FREE_DATA)
info_ptr->free_me &= ~mask;
else
png_error(png_ptr, "Unknown freer parameter in png_data_freer");
}
void PNGAPI void PNGAPI
png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask, png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
int num) int num)
@@ -473,9 +418,10 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
/* Free any tRNS entry */ /* Free any tRNS entry */
if ((mask & PNG_FREE_TRNS) & info_ptr->free_me) if ((mask & PNG_FREE_TRNS) & info_ptr->free_me)
{ {
info_ptr->valid &= ~PNG_INFO_tRNS;
png_free(png_ptr, info_ptr->trans_alpha); png_free(png_ptr, info_ptr->trans_alpha);
info_ptr->trans_alpha = NULL; info_ptr->trans_alpha = NULL;
info_ptr->valid &= ~PNG_INFO_tRNS; info_ptr->num_trans = 0;
} }
#endif #endif
@@ -732,29 +678,6 @@ png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime)
return 1; return 1;
} }
# if PNG_LIBPNG_VER < 10700
/* To do: remove the following from libpng-1.7 */
/* Original API that uses a private buffer in png_struct.
* Deprecated because it causes png_struct to carry a spurious temporary
* buffer (png_struct::time_buffer), better to have the caller pass this in.
*/
png_const_charp PNGAPI
png_convert_to_rfc1123(png_structrp png_ptr, png_const_timep ptime)
{
if (png_ptr != NULL)
{
/* The only failure above if png_ptr != NULL is from an invalid ptime */
if (!png_convert_to_rfc1123_buffer(png_ptr->time_buffer, ptime))
png_warning(png_ptr, "Ignoring invalid time value");
else
return png_ptr->time_buffer;
}
return NULL;
}
# endif
# endif /* PNG_TIME_RFC1123_SUPPORTED */ # endif /* PNG_TIME_RFC1123_SUPPORTED */
#endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */ #endif /* defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) */
@@ -768,13 +691,13 @@ png_get_copyright(png_const_structrp png_ptr)
#else #else
# ifdef __STDC__ # ifdef __STDC__
return PNG_STRING_NEWLINE \ return PNG_STRING_NEWLINE \
"libpng version 1.6.0beta33 - December 10, 2012" PNG_STRING_NEWLINE \ "libpng version 1.7.0alpha03 - December 19, 2012" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2012 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2012 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \ "Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \ "Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE; PNG_STRING_NEWLINE;
# else # else
return "libpng version 1.6.0beta33 - December 10, 2012\ return "libpng version 1.7.0alpha03 - December 19, 2012\
Copyright (c) 1998-2012 Glenn Randers-Pehrson\ Copyright (c) 1998-2012 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
@@ -867,19 +790,6 @@ png_chunk_unknown_handling(png_const_structrp png_ptr, png_uint_32 chunk_name)
#endif /* READ_UNKNOWN_CHUNKS */ #endif /* READ_UNKNOWN_CHUNKS */
#endif /* SET_UNKNOWN_CHUNKS */ #endif /* SET_UNKNOWN_CHUNKS */
#ifdef PNG_READ_SUPPORTED
/* This function, added to libpng-1.0.6g, is untested. */
int PNGAPI
png_reset_zstream(png_structrp png_ptr)
{
if (png_ptr == NULL)
return Z_STREAM_ERROR;
/* WARNING: this resets the window bits to the maximum! */
return (inflateReset(&png_ptr->zstream));
}
#endif /* PNG_READ_SUPPORTED */
/* This function was added to libpng-1.0.7 */ /* This function was added to libpng-1.0.7 */
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_access_version_number(void) png_access_version_number(void)
@@ -888,8 +798,6 @@ png_access_version_number(void)
return((png_uint_32)PNG_LIBPNG_VER); return((png_uint_32)PNG_LIBPNG_VER);
} }
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED) #if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
/* Ensure that png_ptr->zstream.msg holds some appropriate error message string. /* Ensure that png_ptr->zstream.msg holds some appropriate error message string.
* If it doesn't 'ret' is used to set it to something appropriate, even in cases * If it doesn't 'ret' is used to set it to something appropriate, even in cases
@@ -2287,7 +2195,7 @@ void /* PRIVATE */
png_colorspace_set_rgb_coefficients(png_structrp png_ptr) png_colorspace_set_rgb_coefficients(png_structrp png_ptr)
{ {
/* Set the rgb_to_gray coefficients from the colorspace. */ /* Set the rgb_to_gray coefficients from the colorspace. */
if (!png_ptr->rgb_to_gray_coefficients_set && if ((png_ptr->colorspace.flags & PNG_COLORSPACE_RGB_TO_GRAY_SET) == 0 &&
(png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0) (png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
{ {
/* png_set_background has not been called, get the coefficients from the Y /* png_set_background has not been called, get the coefficients from the Y
@@ -3068,24 +2976,32 @@ png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii,
png_error(png_ptr, "ASCII conversion buffer too small"); png_error(png_ptr, "ASCII conversion buffer too small");
} }
# endif /* FIXED_POINT */ # endif /* FIXED_POINT */
#endif /* READ_SCAL */ #endif /* SCAL */
#if defined(PNG_FLOATING_POINT_SUPPORTED) && \ #if !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && (\
!defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \ defined(PNG_FLOATING_POINT_SUPPORTED) && \
(defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \ (defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \
defined(PNG_sCAL_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || \ defined(PNG_sCAL_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || \
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)) || \ defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)) || \
(defined(PNG_sCAL_SUPPORTED) && \ (defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) &&\
defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)) defined(PNG_sCAL_SUPPORTED)))
png_fixed_point png_fixed_point
png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text) png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text)
{ {
double r = floor(100000 * fp + .5); if (fp < 0)
{
if (fp > -21474.836485)
return (png_fixed_point)(100000*fp - .5);
}
if (r > 2147483647. || r < -2147483648.) else
png_fixed_error(png_ptr, text); {
if (fp < 21474.836475)
return (png_fixed_point)(100000*fp + .5);
}
return (png_fixed_point)r; /* Overflow */
png_fixed_error(png_ptr, text);
} }
#endif #endif
@@ -3263,6 +3179,7 @@ png_gamma_significant(png_fixed_point gamma_val)
#ifdef PNG_READ_GAMMA_SUPPORTED #ifdef PNG_READ_GAMMA_SUPPORTED
/* A local convenience routine. */ /* A local convenience routine. */
#ifndef PNG_FLOATING_ARITHMETIC_SUPPORTED
static png_fixed_point static png_fixed_point
png_product2(png_fixed_point a, png_fixed_point b) png_product2(png_fixed_point a, png_fixed_point b)
{ {
@@ -3283,6 +3200,7 @@ png_product2(png_fixed_point a, png_fixed_point b)
return 0; /* overflow */ return 0; /* overflow */
} }
#endif
/* The inverse of the above. */ /* The inverse of the above. */
png_fixed_point png_fixed_point
@@ -3661,161 +3579,332 @@ png_gamma_correct(png_structrp png_ptr, unsigned int value,
return png_gamma_16bit_correct(value, gamma_val); return png_gamma_16bit_correct(value, gamma_val);
} }
/* Internal function to build a single 16-bit table - the table consists of #define PNG_GAMMA_TABLE_8 0 /* 8-bit entries in png_byte */
* 'num' 256 entry subtables, where 'num' is determined by 'shift' - the amount #define PNG_GAMMA_TABLE_8_IN_16 1 /* 8-bit entries * 257 in png_uint_16 */
* to shift the input values right (or 16-number_of_signifiant_bits). #define PNG_GAMMA_TABLE_16 2 /* 16-bit entries in png_uint_16 */
*
* The caller is responsible for ensuring that the table gets cleaned up on typedef struct
* png_error (i.e. if one of the mallocs below fails) - i.e. the *table argument
* should be somewhere that will be cleaned.
*/
static void
png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable,
PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val)
{ {
/* Various values derived from 'shift': */ png_fixed_point gamma;
PNG_CONST unsigned int num = 1U << (8U - shift); png_uint_32 mult;
PNG_CONST unsigned int max = (1U << (16U - shift))-1U; unsigned int add;
PNG_CONST unsigned int max_by_2 = 1U << (15U-shift); unsigned int shift; /* input value is (i * mult + add) >> shift */
unsigned int i; unsigned int output; /* One of the above values */
int adjust; /* Divide or multiple output by 257 */
png_voidp table; /* Lookup table */
} gamma_table_data;
png_uint_16pp table = *ptable = static unsigned int
(png_uint_16pp)png_calloc(png_ptr, num * (sizeof (png_uint_16p))); write_gamma_table_entry(const gamma_table_data *data, png_uint_32 i)
/* Calculate and write a single entry into table[i], the value of the entry
* written is returned.
*/
{
png_uint_32 in = (i * data->mult + data->add) >> data->shift;
unsigned int out;
for (i = 0; i < num; i++) /* If the output is TABLE_8 with no adjust, or the output is not with an
* adjust, use 8-bit correction.
*/
if ((data->output == PNG_GAMMA_TABLE_8) != (data->adjust != 0))
{ {
png_uint_16p sub_table = table[i] = out = png_gamma_8bit_correct((unsigned int)in, data->gamma);
(png_uint_16p)png_malloc(png_ptr, 256 * (sizeof (png_uint_16)));
/* The 'threshold' test is repeated here because it can arise for one of if (data->adjust != 0)
* the 16-bit tables even if the others don't hit it. out *= 257U;
*/ }
if (png_gamma_significant(gamma_val))
else /* 16-bit correction */
{
out = png_gamma_16bit_correct((unsigned int)in, data->gamma);
if (data->adjust != 0)
out = PNG_DIV257(out);
}
if (data->output == PNG_GAMMA_TABLE_8)
((png_bytep)data->table)[i] = (png_byte)out;
else
((png_uint_16p)data->table)[i] = (png_uint_16)out;
return out;
}
static void
write_gamma_table(const gamma_table_data *data, png_uint_32 lo,
unsigned int loval, png_uint_32 hi, unsigned int hival)
/* Fill in gamma table entries between lo and hi, exclusive. The entries at
* table[lo] and table[hi] have already been written, the intervening entries
* are written.
*/
{
if (hi > lo+1) /* Else nothing to fill in */
{
if (hival == loval)
{ {
/* The old code would overflow at the end and this would cause the /* All intervening entries must be the same. */
* 'pow' function to return a result >1, resulting in an if (data->output == PNG_GAMMA_TABLE_8)
* arithmetic error. This code follows the spec exactly; ig is
* the recovered input sample, it always has 8-16 bits.
*
* We want input * 65535/max, rounded, the arithmetic fits in 32
* bits (unsigned) so long as max <= 32767.
*/
unsigned int j;
for (j = 0; j < 256; j++)
{ {
png_uint_32 ig = (j << (8-shift)) + i; png_bytep table8 = ((png_bytep)data->table);
# ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
/* Inline the 'max' scaling operation: */
double d = floor(65535*pow(ig/(double)max, gamma_val*.00001)+.5);
sub_table[j] = (png_uint_16)d;
# else
if (shift)
ig = (ig * 65535U + max_by_2)/max;
sub_table[j] = png_gamma_16bit_correct(ig, gamma_val); while (++lo < hi)
# endif table8[lo] = (png_byte)loval;
}
else
{
png_uint_16p table16 = ((png_uint_16p)data->table);
while (++lo < hi)
table16[lo] = (png_uint_16)loval;
} }
} }
else else
{ {
/* We must still build a table, but do it the fast way. */ png_uint_32 mid = (lo+hi) >> 1;
unsigned int j; unsigned int midval = write_gamma_table_entry(data, mid);
for (j = 0; j < 256; j++) /* The algorithm used is to divide the entries to be written in half
{ * and fill in the middle. For all practical tables with significant
png_uint_32 ig = (j << (8-shift)) + i; * gamma this will result in a performance gain because the expensive
* gamma correction arithmetic is avoided for some entries.
if (shift) */
ig = (ig * 65535U + max_by_2)/max; write_gamma_table(data, lo, loval, mid, midval);
write_gamma_table(data, mid, midval, hi, hival);
sub_table[j] = (png_uint_16)ig;
}
} }
} }
} }
/* NOTE: this function expects the *inverse* of the overall gamma transformation static void *
* required. png_build_gamma_table(png_structrp png_ptr, png_fixed_point gamma_val,
*/ unsigned int output/*as above*/, unsigned int input_depth, int use_shift)
static void /* Build a gamma lookup table to encode input_depth bit input values.
png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable, * The table will have 2^input_depth entries plus an extra one if use_shift
PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val) * is specified. With shift the table is accessed:
*
* table[(original-value + rounding) >> shift]
*
* And an extra entry exists to accomodate overflow of original-value on
* rounding. If use_shift is not specified the table is accessed with an
* input_depth bit value and the original values must have been correctly
* scaled to this range (not using a shift!)
*
* Each table entry contains input-value^gamma_val rounded to the output
* precision. This is 8 bit precision unless output is specified as
* PNG_GAMMA_TABLE_16, in which case it is 16-bit precision. For
* PNG_GAMMA_TABLE_8_IN_16 the 8-bit value is scaled to 16-bits by
* multiplying by 257.
*/
{ {
PNG_CONST unsigned int num = 1U << (8U - shift); png_uint_32 size;
PNG_CONST unsigned int max = (1U << (16U - shift))-1U; unsigned int hival;
unsigned int i; gamma_table_data data;
png_uint_32 last;
png_uint_16pp table = *ptable = /* If use_shift is true or if the input or output is not 8-bit the gamma
(png_uint_16pp)png_calloc(png_ptr, num * (sizeof (png_uint_16p))); * correction will use the 16-bit correction code. This requires a value in
* the range 0..65535. For use_shift the value is simply:
/* 'num' is the number of tables and also the number of low bits of low
* bits of the input 16-bit value used to select a table. Each table is
* itself index by the high 8 bits of the value.
*/
for (i = 0; i < num; i++)
table[i] = (png_uint_16p)png_malloc(png_ptr,
256 * (sizeof (png_uint_16)));
/* 'gamma_val' is set to the reciprocal of the value calculated above, so
* pow(out,g) is an *input* value. 'last' is the last input value set.
* *
* In the loop 'i' is used to find output values. Since the output is * input << shift
* 8-bit there are only 256 possible values. The tables are set up to
* select the closest possible output value for each input by finding
* the input value at the boundary between each pair of output values
* and filling the table up to that boundary with the lower output
* value.
* *
* The boundary values are 0.5,1.5..253.5,254.5. Since these are 9-bit * For the scaling case the value is:
* values the code below uses a 16-bit value in i; the values start at *
* 128.5 (for 0.5) and step by 257, for a total of 254 values (the last * round(input * 65535 / ((1<<input_depth)-1)
* entries are filled with 255). Start i at 128 and fill all 'last' *
* table entries <= 'max' * Both these expressions can be rewritten as:
*
* (input * mult + add) >> shift;
*
* With 'mult' and 'add' chosen to minimize the error for all input values
* in the range 0..((1<<input_depth)-1). The following table does this for
* the scaling case. In fact all the answers are except except for the
* 13-bit case, where the maximum error (from the exact value) is 0.500183.
*
* This table can be produced using the code in contrib/tools/scale.c
*/ */
last = 0; static const struct
for (i = 0; i < 255; ++i) /* 8-bit output value */
{ {
/* Find the corresponding maximum input value */ png_uint_32 mult;
png_uint_16 out = (png_uint_16)(i * 257U); /* 16-bit output value */ png_uint_16 add;
png_byte shift;
} multadd65535[16] =
{
{ 65535, 0, 0 }, /* 65535/1 */
{ 21845, 0, 0 }, /* 65535/3 */
{ 37449, 0, 2 }, /* 65535/7 */
{ 4369, 0, 0 }, /* 65535/15 */
{ 33825, 0, 4 }, /* 65535/31 */
{ 266301, 121, 8 }, /* 65535/63 */
{ 1056817, 970, 11 }, /* 65535/127 */
{ 257, 0, 0 }, /* 65535/255 */
{ 262653, 1020, 11 }, /* 65535/511 */
{ 1049585, 8165, 14 }, /* 65535/1023 */
{ 2098145, 31774, 16 }, /* 65535/2047 */
{ 65551, 2055, 12 }, /* 65535/4095 */
{ 65543, 4100, 13 }, /* 65535/8191 ERROR: .5+0.000183128*/
{ 65539, 8193, 14 }, /* 65535/16383 */
{ 32769, 0, 14 }, /* 65535/32767 */
{ 1, 0, 0 } /* 65535/65535 */
# if 0 /* inverse */
{ 1, 0, 15 }, /* 1/65535 */
{ 3, 32769, 16 }, /* 3/65535 */
{ 28673, 134188470, 28 }, /* 7/65535 */
{ 15, 32775, 16 }, /* 15/65535 */
{ 31745, 33522654, 26 }, /* 31/65535 */
{ 64513, 33552693, 26 }, /* 63/65535 */
{ 65025, 16776620, 25 }, /* 127/65535 */
{ 255, 32895, 16 }, /* 255/65535 */
{ 65409, 4194134, 23 }, /* 511/65535 */
{ 65473, 2097037, 22 }, /* 1023/65535 */
{ 65505, 1048544, 21 }, /* 2047/65535 */
{ 65521, 524167, 20 }, /* 4095/65535 */
{ 65529, 262136, 19 }, /* 8191/65535 */
{ 65533, 131065, 18 }, /* 16383/65535 */
{ 1, 0, 1 }, /* 32767/65535 */
{ 1, 0, 0 } /* 65535/65535 */
# endif
};
/* Find the boundary value in 16 bits: */ /* When both the input and output are 8-bit (i.e. the output is not
png_uint_32 bound = png_gamma_16bit_correct(out+128U, gamma_val); * PNG_GAMMA_TABLE_16 and the input_depth is <9) the 8-bit gamma correction
* code can be used, it is slightly faster. This requires values scaled to
* 255, not 65535:
*/
static const struct
{
png_uint_16 mult;
png_byte add;
png_byte shift;
} multadd255[8] =
{
{ 255, 0, 0 }, /* 255/1 */
{ 85, 0, 0 }, /* 255/3 */
{ 73, 0, 1 }, /* 255/7 */
{ 17, 0, 0 }, /* 255/15 */
{ 527, 23, 6 }, /* 255/31 */
{ 259, 33, 6 }, /* 255/63 */
{ 129, 0, 6 }, /* 255/127 */
{ 1, 0, 0 } /* 255/255 */
# if 0 /* inverse */
{ 1, 0, 7 }, /* 1/255 */
{ 3, 129, 8 }, /* 3/255 */
{ 225, 4060, 13 }, /* 7/255 */
{ 15, 135, 8 }, /* 15/255 */
{ 249, 1014, 11 }, /* 31/255 */
{ 253, 505, 10 }, /* 63/255 */
{ 1, 0, 1 }, /* 127/255 */
{ 1, 0, 0 } /* 255/255 */
# endif
};
/* Adjust (round) to (16-shift) bits: */ /* Basic table size, increased by one below in the use_shift case where the
bound = (bound * max + 32768U)/65535U + 1U; * input is rounded.
*/
size = 1U << input_depth;
data.gamma = gamma_val;
data.output = output;
while (last < bound) if (output < PNG_GAMMA_TABLE_16 && input_depth <= 8)
{
/* The 8-bit correction can only be used if both input and output have no
* more than 8 bits of precision.
*/
data.adjust = output > PNG_GAMMA_TABLE_8;
if (use_shift)
{ {
table[last & (0xffU >> shift)][last >> (8U - shift)] = out; /* The multiplier does the shift: */
last++; data.mult = 1U << (8-input_depth);
data.add = 0;
data.shift = 0;
if (input_depth < 8) ++size;
}
else
{
data.mult = multadd255[input_depth-1].mult;
data.add = multadd255[input_depth-1].add;
data.shift = multadd255[input_depth-1].shift;
} }
} }
/* And fill in the final entries. */ else
while (last < (num << 8))
{ {
table[last & (0xff >> shift)][last >> (8U - shift)] = 65535U; /* 16-bit correction is used for cases where input or output require more
last++; * than 8 bits.
*/
data.adjust = output == PNG_GAMMA_TABLE_8;
if (use_shift)
{
data.mult = 1U << (16-input_depth);
data.add = 0;
data.shift = 0;
if (input_depth < 16) ++size;
}
else
{
data.mult = multadd65535[input_depth-1].mult;
data.add = multadd65535[input_depth-1].add;
data.shift = multadd65535[input_depth-1].shift;
}
} }
}
/* Build a single 8-bit table: same as the 16-bit case but much simpler (and if (output == PNG_GAMMA_TABLE_8)
* typically much faster). Note that libpng currently does no sBIT processing {
* (apparently contrary to the spec) so a 256 entry table is always generated. data.table = png_malloc(png_ptr, size * sizeof (png_byte));
*/ ((png_bytep)data.table)[0] = 0;
static void hival = ((png_bytep)data.table)[size-1] = 255;
png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable, }
PNG_CONST png_fixed_point gamma_val)
{
unsigned int i;
png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256);
if (png_gamma_significant(gamma_val)) for (i=0; i<256; i++) else
table[i] = png_gamma_8bit_correct(i, gamma_val); {
/* Output is 16 bits, although it may only have 8 bits of precision */
data.table = png_malloc(png_ptr, size * sizeof (png_uint_16));
((png_uint_16p)data.table)[0] = 0;
hival = ((png_uint_16p)data.table)[size-1] = 65535;
}
else for (i=0; i<256; ++i) if (png_gamma_significant(gamma_val))
table[i] = (png_byte)i; write_gamma_table(&data, 0, 0, size-1, hival);
else /* gamma_val not significant */
{
if (output == PNG_GAMMA_TABLE_8)
{
png_uint_32 i;
png_bytep table8 = ((png_bytep)data.table);
if (data.adjust)
for (i=1; i<size-1; ++i)
table8[i] = (png_byte)PNG_DIV257((i * data.mult + data.add) >>
data.shift);
else
for (i=1; i<size-1; ++i)
table8[i] = (png_byte)((i * data.mult + data.add) >> data.shift);
}
else
{
png_uint_32 i;
png_uint_16p table16 = ((png_uint_16p)data.table);
if (data.adjust)
for (i=1; i<size-1; ++i)
table16[i] = (png_uint_16)(((i * data.mult + data.add) >>
data.shift) * 257U);
else
for (i=1; i<size-1; ++i)
table16[i] = (png_uint_16)((i * data.mult + data.add) >>
data.shift);
}
}
return data.table;
} }
/* Used from png_read_destroy and below to release the memory used by the gamma /* Used from png_read_destroy and below to release the memory used by the gamma
@@ -3827,17 +3916,8 @@ png_destroy_gamma_table(png_structrp png_ptr)
png_free(png_ptr, png_ptr->gamma_table); png_free(png_ptr, png_ptr->gamma_table);
png_ptr->gamma_table = NULL; png_ptr->gamma_table = NULL;
if (png_ptr->gamma_16_table != NULL)
{
int i;
int istop = (1 << (8 - png_ptr->gamma_shift));
for (i = 0; i < istop; i++)
{
png_free(png_ptr, png_ptr->gamma_16_table[i]);
}
png_free(png_ptr, png_ptr->gamma_16_table); png_free(png_ptr, png_ptr->gamma_16_table);
png_ptr->gamma_16_table = NULL; png_ptr->gamma_16_table = NULL;
}
#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ #if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
@@ -3847,28 +3927,10 @@ png_destroy_gamma_table(png_structrp png_ptr)
png_free(png_ptr, png_ptr->gamma_to_1); png_free(png_ptr, png_ptr->gamma_to_1);
png_ptr->gamma_to_1 = NULL; png_ptr->gamma_to_1 = NULL;
if (png_ptr->gamma_16_from_1 != NULL)
{
int i;
int istop = (1 << (8 - png_ptr->gamma_shift));
for (i = 0; i < istop; i++)
{
png_free(png_ptr, png_ptr->gamma_16_from_1[i]);
}
png_free(png_ptr, png_ptr->gamma_16_from_1); png_free(png_ptr, png_ptr->gamma_16_from_1);
png_ptr->gamma_16_from_1 = NULL; png_ptr->gamma_16_from_1 = NULL;
}
if (png_ptr->gamma_16_to_1 != NULL)
{
int i;
int istop = (1 << (8 - png_ptr->gamma_shift));
for (i = 0; i < istop; i++)
{
png_free(png_ptr, png_ptr->gamma_16_to_1[i]);
}
png_free(png_ptr, png_ptr->gamma_16_to_1); png_free(png_ptr, png_ptr->gamma_16_to_1);
png_ptr->gamma_16_to_1 = NULL; png_ptr->gamma_16_to_1 = NULL;
}
#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ #endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
} }
@@ -3878,7 +3940,7 @@ png_destroy_gamma_table(png_structrp png_ptr)
* we don't need to allocate > 64K chunks for a full 16-bit table. * we don't need to allocate > 64K chunks for a full 16-bit table.
*/ */
void /* PRIVATE */ void /* PRIVATE */
png_build_gamma_table(png_structrp png_ptr, int bit_depth) png_build_gamma_tables(png_structrp png_ptr, int bit_depth)
{ {
png_debug(1, "in png_build_gamma_table"); png_debug(1, "in png_build_gamma_table");
@@ -3896,27 +3958,44 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth)
if (bit_depth <= 8) if (bit_depth <= 8)
{ {
png_build_8bit_table(png_ptr, &png_ptr->gamma_table, png_ptr->gamma_table = png_voidcast(png_bytep, png_build_gamma_table(
png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->colorspace.gamma, png_ptr, png_ptr->screen_gamma > 0 ?
png_ptr->screen_gamma) : PNG_FP_1); png_reciprocal2(png_ptr->colorspace.gamma, png_ptr->screen_gamma) :
PNG_FP_1, PNG_GAMMA_TABLE_8, 8/*input depth*/, 0/*scale*/));
#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ #if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
if (png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) if (png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY))
{ {
png_build_8bit_table(png_ptr, &png_ptr->gamma_to_1, /* This sets the accuracy of 8-bit composition and the 8-bit RGB to gray
png_reciprocal(png_ptr->colorspace.gamma)); * conversion - PNG_MAX_GAMMA_8 (the number of bits in the sixteen bit
* value that are considered significant.)
*/
png_ptr->gamma_to_1 = png_voidcast(png_uint_16p, png_build_gamma_table(
png_ptr, png_reciprocal(png_ptr->colorspace.gamma),
PNG_GAMMA_TABLE_16, 8/*input depth*/, 0/*scale*/));
png_build_8bit_table(png_ptr, &png_ptr->gamma_from_1, png_ptr->gamma_from_1 = png_voidcast(png_bytep, png_build_gamma_table(
png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) : png_ptr, png_ptr->screen_gamma > 0 ?
png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */); png_reciprocal(png_ptr->screen_gamma) :
png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */,
PNG_GAMMA_TABLE_8, PNG_MAX_GAMMA_8/*input depth*/, 1/*shift*/));
png_ptr->gamma_shift = 16-PNG_MAX_GAMMA_8;
} }
#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ #endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
} }
else else
{ {
png_byte shift, sig_bit; png_byte shift, sig_bit;
int table_type;
# ifdef PNG_16BIT_SUPPORTED
table_type = PNG_GAMMA_TABLE_16;
# else
table_type = PNG_GAMMA_TABLE_8_IN_16;
# endif
if (png_ptr->color_type & PNG_COLOR_MASK_COLOR) if (png_ptr->color_type & PNG_COLOR_MASK_COLOR)
{ {
@@ -3931,24 +4010,6 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth)
else else
sig_bit = png_ptr->sig_bit.gray; sig_bit = png_ptr->sig_bit.gray;
/* 16-bit gamma code uses this equation:
*
* ov = table[(iv & 0xff) >> gamma_shift][iv >> 8]
*
* Where 'iv' is the input color value and 'ov' is the output value -
* pow(iv, gamma).
*
* Thus the gamma table consists of up to 256 256 entry tables. The table
* is selected by the (8-gamma_shift) most significant of the low 8 bits of
* the color value then indexed by the upper 8 bits:
*
* table[low bits][high 8 bits]
*
* So the table 'n' corresponds to all those 'iv' of:
*
* <all high 8-bit values><n << gamma_shift>..<(n+1 << gamma_shift)-1>
*
*/
if (sig_bit > 0 && sig_bit < 16U) if (sig_bit > 0 && sig_bit < 16U)
shift = (png_byte)(16U - sig_bit); /* shift == insignificant bits */ shift = (png_byte)(16U - sig_bit); /* shift == insignificant bits */
@@ -3959,51 +4020,40 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth)
{ {
/* PNG_MAX_GAMMA_8 is the number of bits to keep - effectively /* PNG_MAX_GAMMA_8 is the number of bits to keep - effectively
* the significant bits in the *input* when the output will * the significant bits in the *input* when the output will
* eventually be 8 bits. By default it is 11. * eventually be 8 bits.
*/ */
if (shift < (16U - PNG_MAX_GAMMA_8)) if (shift < (16U - PNG_MAX_GAMMA_8))
shift = (16U - PNG_MAX_GAMMA_8); shift = (16U - PNG_MAX_GAMMA_8);
}
if (shift > 8U) table_type = PNG_GAMMA_TABLE_8_IN_16;
shift = 8U; /* Guarantees at least one table! */ }
png_ptr->gamma_shift = shift; png_ptr->gamma_shift = shift;
#ifdef PNG_16BIT_SUPPORTED png_ptr->gamma_16_table = png_voidcast(png_uint_16p, png_build_gamma_table(
/* NOTE: prior to 1.5.4 this test used to include PNG_BACKGROUND (now png_ptr, png_ptr->screen_gamma > 0 ? png_reciprocal2(
* PNG_COMPOSE). This effectively smashed the background calculation for png_ptr->colorspace.gamma, png_ptr->screen_gamma) : PNG_FP_1,
* 16-bit output because the 8-bit table assumes the result will be reduced table_type, (16-shift)/*input depth*/, 1/*shift*/));
* to 8 bits.
*/
if (png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8))
#endif
png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift,
png_ptr->screen_gamma > 0 ? png_product2(png_ptr->colorspace.gamma,
png_ptr->screen_gamma) : PNG_FP_1);
#ifdef PNG_16BIT_SUPPORTED
else
png_build_16bit_table(png_ptr, &png_ptr->gamma_16_table, shift,
png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->colorspace.gamma,
png_ptr->screen_gamma) : PNG_FP_1);
#endif
#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ #if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED) defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
if (png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) if (png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY))
{ {
png_build_16bit_table(png_ptr, &png_ptr->gamma_16_to_1, shift, png_ptr->gamma_16_to_1 = png_voidcast(png_uint_16p,
png_reciprocal(png_ptr->colorspace.gamma)); png_build_gamma_table(png_ptr,
png_reciprocal(png_ptr->colorspace.gamma), PNG_GAMMA_TABLE_16,
(16-shift)/*input depth*/, 1/*shift*/));
/* Notice that the '16 from 1' table should be full precision, however /* Notice that the '16 from 1' table should be full precision, however
* the lookup on this table still uses gamma_shift, so it can't be. * the lookup on this table still uses gamma_shift, so it can't be.
* TODO: fix this. * TODO: fix this.
*/ */
png_build_16bit_table(png_ptr, &png_ptr->gamma_16_from_1, shift, png_ptr->gamma_16_from_1 = png_voidcast(png_uint_16p,
png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) : png_build_gamma_table(png_ptr, png_ptr->screen_gamma > 0 ?
png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */); png_reciprocal(png_ptr->screen_gamma) :
png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */,
PNG_GAMMA_TABLE_16, (16-shift)/*input depth*/, 1/*shift*/));
} }
#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ #endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
} }

130
png.h
View File

@@ -1,7 +1,7 @@
/* png.h - header file for PNG reference library /* png.h - header file for PNG reference library
* *
* libpng version 1.6.0beta33 - December 10, 2012 * libpng version 1.7.0alpha03 - December 19, 2012
* Copyright (c) 1998-2012 Glenn Randers-Pehrson * Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -11,7 +11,7 @@
* Authors and maintainers: * Authors and maintainers:
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * 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.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.0alpha03 - December 19, 2012: Glenn
* See also "Contributing Authors", below. * See also "Contributing Authors", below.
* *
* Note about libpng version numbers: * Note about libpng version numbers:
@@ -166,7 +166,8 @@
* 1.5.7beta01-05 15 10507 15.so.15.7[.0] * 1.5.7beta01-05 15 10507 15.so.15.7[.0]
* 1.5.7rc01-03 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.5.7 15 10507 15.so.15.7[.0]
* 1.6.0beta01-32 16 10600 16.so.16.0[.0] * 1.6.0beta01-33 16 10600 16.so.16.0[.0]
* 1.7.0alpha01-03 17 10700 17.so.17.0[.0]
* *
* Henceforth the source version will match the shared-library major * Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be * and minor numbers; the shared-library major version number will be
@@ -198,7 +199,7 @@
* *
* This code is released under the libpng license. * This code is released under the libpng license.
* *
* libpng versions 1.2.6, August 15, 2004, through 1.6.0beta33, December 10, 2012, are * libpng versions 1.2.6, August 15, 2004, through 1.7.0alpha03, December 19, 2012, are
* Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are * Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are
* distributed according to the same disclaimer and license as libpng-1.2.5 * distributed according to the same disclaimer and license as libpng-1.2.5
* with the following individual added to the list of Contributing Authors: * with the following individual added to the list of Contributing Authors:
@@ -310,13 +311,13 @@
* Y2K compliance in libpng: * Y2K compliance in libpng:
* ========================= * =========================
* *
* December 10, 2012 * December 19, 2012
* *
* Since the PNG Development group is an ad-hoc body, we can't make * Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration. * an official declaration.
* *
* This is your unofficial assurance that libpng from version 0.71 and * 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.0alpha03 are Y2K compliant. It is my belief that
* earlier versions were also Y2K compliant. * earlier versions were also Y2K compliant.
* *
* Libpng only has two year fields. One is a 2-byte unsigned integer * Libpng only has two year fields. One is a 2-byte unsigned integer
@@ -376,23 +377,23 @@
*/ */
/* Version information for png.h - this should match the version in png.c */ /* 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.0alpha03"
#define PNG_HEADER_VERSION_STRING \ #define PNG_HEADER_VERSION_STRING \
" libpng version 1.6.0beta33 - December 10, 2012\n" " libpng version 1.7.0alpha03 - December 19, 2012\n"
#define PNG_LIBPNG_VER_SONUM 16 #define PNG_LIBPNG_VER_SONUM 17
#define PNG_LIBPNG_VER_DLLNUM 16 #define PNG_LIBPNG_VER_DLLNUM 17
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ /* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1 #define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 6 #define PNG_LIBPNG_VER_MINOR 7
#define PNG_LIBPNG_VER_RELEASE 0 #define PNG_LIBPNG_VER_RELEASE 0
/* This should match the numeric part of the final component of /* This should match the numeric part of the final component of
* PNG_LIBPNG_VER_STRING, omitting any leading zero: * PNG_LIBPNG_VER_STRING, omitting any leading zero:
*/ */
#define PNG_LIBPNG_VER_BUILD 33 #define PNG_LIBPNG_VER_BUILD 03
/* Release Status */ /* Release Status */
#define PNG_LIBPNG_BUILD_ALPHA 1 #define PNG_LIBPNG_BUILD_ALPHA 1
@@ -409,7 +410,7 @@
#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with #define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with
PNG_LIBPNG_BUILD_PRIVATE */ PNG_LIBPNG_BUILD_PRIVATE */
#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_BETA #define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_ALPHA
/* Careful here. At one time, Guy wanted to use 082, but that would be octal. /* Careful here. At one time, Guy wanted to use 082, but that would be octal.
* We must not include leading zeros. * We must not include leading zeros.
@@ -417,7 +418,7 @@
* version 1.0.0 was mis-numbered 100 instead of 10000). From * 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 * 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 /* Library configuration: these options cannot be changed after
* the library has been built. * the library has been built.
@@ -522,7 +523,7 @@ extern "C" {
/* This triggers a compiler error in png.c, if png.c and png.h /* This triggers a compiler error in png.c, if png.c and png.h
* do not agree upon the version number. * do not agree upon the version number.
*/ */
typedef char* png_libpng_version_1_6_0beta33; typedef char* png_libpng_version_1_7_0alpha03;
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info. /* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
* *
@@ -1054,8 +1055,8 @@ PNG_EXPORTA(9, void, png_longjmp, (png_const_structrp png_ptr, int val),
PNG_NORETURN); PNG_NORETURN);
#ifdef PNG_READ_SUPPORTED #ifdef PNG_READ_SUPPORTED
/* Reset the compression stream */ /* Reset the compression stream -- Removed from libpng-1.7.0 */
PNG_EXPORTA(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED); PNG_REMOVED(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED)
#endif #endif
/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ /* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */
@@ -1094,12 +1095,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_EXPORTA(18, png_infop, png_create_info_struct, (png_const_structrp png_ptr),
PNG_ALLOCATED); PNG_ALLOCATED);
/* DEPRECATED: this function allowed init structures to be created using the /* Removed from libpng-1.7.0 */
* default allocation method (typically malloc). Use is deprecated in 1.6.0 and PNG_REMOVED(19, void, png_info_init_3, (png_infopp info_ptr,
* the API will be removed in the future. png_size_t png_info_struct_size), PNG_DEPRECATED)
*/
PNG_EXPORTA(19, void, png_info_init_3, (png_infopp info_ptr,
png_size_t png_info_struct_size), PNG_DEPRECATED);
/* Writes all the PNG information before the image. */ /* Writes all the PNG information before the image. */
PNG_EXPORT(20, void, png_write_info_before_PLTE, PNG_EXPORT(20, void, png_write_info_before_PLTE,
@@ -1116,13 +1114,10 @@ PNG_EXPORT(22, void, png_read_info,
#ifdef PNG_TIME_RFC1123_SUPPORTED #ifdef PNG_TIME_RFC1123_SUPPORTED
/* Convert to a US string format: there is no localization support in this /* Convert to a US string format: there is no localization support in this
* routine. The original implementation used a 29 character buffer in * 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 PNG_REMOVED(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr,
/* To do: remove this from libpng17 (and from libpng17/png.c and pngstruct.h) */ png_const_timep ptime),PNG_DEPRECATED)
PNG_EXPORTA(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr,
png_const_timep ptime),PNG_DEPRECATED);
#endif
PNG_EXPORT(241, int, png_convert_to_rfc1123_buffer, (char out[29], PNG_EXPORT(241, int, png_convert_to_rfc1123_buffer, (char out[29],
png_const_timep ptime)); png_const_timep ptime));
#endif #endif
@@ -1619,22 +1614,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, PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,
int filters)); 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. /* 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_NONE 0
#define PNG_FILTER_VALUE_SUB 1 #define PNG_FILTER_VALUE_SUB 1
@@ -1643,6 +1624,26 @@ PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,
#define PNG_FILTER_VALUE_PAETH 4 #define PNG_FILTER_VALUE_PAETH 4
#define PNG_FILTER_VALUE_LAST 5 #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 */ #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* EXPERIMENTAL */
/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_ /* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_
* defines, either the default (minimum-sum-of-absolute-differences), or * defines, either the default (minimum-sum-of-absolute-differences), or
@@ -1928,16 +1929,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. * 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 * 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_REMOVED(99, void, png_data_freer, (png_const_structrp png_ptr,
png_inforp info_ptr, int freer, png_uint_32 mask), PNG_DEPRECATED); png_inforp info_ptr, int freer, png_uint_32 mask), PNG_DEPRECATED)
/* Assignments for png_data_freer */ /* Flags for png_free_data */
#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 */
#define PNG_FREE_HIST 0x0008 #define PNG_FREE_HIST 0x0008
#define PNG_FREE_ICCP 0x0010 #define PNG_FREE_ICCP 0x0010
#define PNG_FREE_SPLT 0x0020 #define PNG_FREE_SPLT 0x0020
@@ -1955,10 +1953,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 */ #define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED
PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr, /* These were deprecated in libpng 1.6.0 and have been removed from libpng
png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED); * 1.7.0; the functionality should be accessed by calling malloc or free
PNG_EXPORTA(101, void, png_free_default, (png_const_structrp png_ptr, * directly or, if png_error handling is required, calling png_malloc.
png_voidp ptr), PNG_DEPRECATED); */
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 #endif
#ifdef PNG_ERROR_TEXT_SUPPORTED #ifdef PNG_ERROR_TEXT_SUPPORTED
@@ -2327,15 +2329,14 @@ PNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr,
#endif #endif
#ifdef PNG_sCAL_SUPPORTED #ifdef PNG_sCAL_SUPPORTED
PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr, #ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
png_const_inforp info_ptr, int *unit, double *width, double *height)) /* NOTE: these API are currently implemented using floating point arithmetic,
#if (defined PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ * consequently they can only be used on systems with floating point support.
(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.
* In any case the range of values supported by png_fixed_point is small and it * 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. * 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_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed,
(png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit,
png_fixed_point *width, png_fixed_point *height)) png_fixed_point *width, png_fixed_point *height))
@@ -2344,8 +2345,13 @@ PNG_EXPORT(169, png_uint_32, png_get_sCAL_s,
(png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit,
png_charpp swidth, png_charpp sheight)); 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_FP_EXPORT(170, void, png_set_sCAL, (png_const_structrp png_ptr,
png_inforp info_ptr, int unit, double width, double height)) 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_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr,
png_inforp info_ptr, int unit, png_fixed_point width, png_inforp info_ptr, int unit, png_fixed_point width,
png_fixed_point height)) png_fixed_point height))

View File

@@ -1,7 +1,7 @@
/* pngconf.h - machine configurable file for libpng /* pngconf.h - machine configurable file for libpng
* *
* libpng version 1.6.0beta33 - December 10, 2012 * libpng version 1.7.0alpha03 - December 19, 2012
* *
* Copyright (c) 1998-2012 Glenn Randers-Pehrson * Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)

View File

@@ -1,7 +1,7 @@
/* pngerror.c - stub functions for i/o and memory allocation /* pngerror.c - stub functions for i/o and memory allocation
* *
* Last changed in libpng 1.6.0 [(PENDING RELEASE)] * Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Copyright (c) 1998-2012 Glenn Randers-Pehrson * Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (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: case PNG_NUMBER_FORMAT_02u:
/* Expects at least 2 digits. */ /* Expects at least 2 digits. */
mincount = 2; mincount = 2;
/* FALL THROUGH */ /* fall through */
case PNG_NUMBER_FORMAT_u: case PNG_NUMBER_FORMAT_u:
*--end = digits[number % 10]; *--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: case PNG_NUMBER_FORMAT_02x:
/* This format expects at least two digits */ /* This format expects at least two digits */
mincount = 2; mincount = 2;
/* FALL THROUGH */ /* fall through */
case PNG_NUMBER_FORMAT_x: case PNG_NUMBER_FORMAT_x:
*--end = digits[number & 0xf]; *--end = digits[number & 0xf];
@@ -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_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_FUNCTION(void,
png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN) 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); png_ptr->longjmp_fn(*png_ptr->jmp_buf_ptr, val);
#endif #endif
/* Here if not setjmp support or if png_ptr is null. */ /* If control reaches this point, png_longjmp() must not return. The only
PNG_ABORT(); * 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 #ifdef PNG_WARNINGS_SUPPORTED

View File

@@ -1,7 +1,7 @@
/* pngget.c - retrieval of values from info struct /* pngget.c - retrieval of values from info struct
* *
* Last changed in libpng 1.6.0 [(PENDING RELEASE)] * Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Copyright (c) 1998-2012 Glenn Randers-Pehrson * Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -843,9 +843,8 @@ png_get_pCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
#endif #endif
#ifdef PNG_sCAL_SUPPORTED #ifdef PNG_sCAL_SUPPORTED
# ifdef PNG_FIXED_POINT_SUPPORTED # ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
# if (defined PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ # ifdef PNG_FIXED_POINT_SUPPORTED
(defined PNG_FLOATING_POINT_SUPPORTED)
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr, png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
int *unit, png_fixed_point *width, png_fixed_point *height) int *unit, png_fixed_point *width, png_fixed_point *height)
@@ -866,9 +865,8 @@ png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
return(0); return(0);
} }
# endif /* FLOATING_ARITHMETIC */ # endif /* FIXED_POINT */
# endif /* FIXED_POINT */ # ifdef PNG_FLOATING_POINT_SUPPORTED
# ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr, png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
int *unit, double *width, double *height) int *unit, double *width, double *height)
@@ -884,7 +882,9 @@ png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
return(0); return(0);
} }
# endif /* FLOATING POINT */ # endif /* FLOATING POINT */
# endif /* FLOATING_ARITHMETIC */
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr, png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr,
int *unit, png_charpp width, png_charpp height) int *unit, png_charpp width, png_charpp height)

View File

@@ -110,31 +110,11 @@ png_malloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
ret = png_malloc_base(png_ptr, size); ret = png_malloc_base(png_ptr, size);
if (ret == NULL) if (ret == NULL)
png_error(png_ptr, "Out of memory"); /* 'm' means png_malloc */ png_error(png_ptr, "Out of memory");
return ret; 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() /* 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 * function will issue a png_warning and return NULL instead of issuing a
* png_error, if it fails to allocate the requested memory. * png_error, if it fails to allocate the requested memory.
@@ -170,17 +150,8 @@ png_free(png_const_structrp png_ptr, png_voidp ptr)
png_ptr->free_fn(png_constcast(png_structrp,png_ptr), ptr); png_ptr->free_fn(png_constcast(png_structrp,png_ptr), ptr);
else 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 */ #endif /* PNG_USER_MEM_SUPPORTED */
free(ptr);
free(ptr);
} }
#ifdef PNG_USER_MEM_SUPPORTED #ifdef PNG_USER_MEM_SUPPORTED

View File

@@ -6,7 +6,7 @@
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (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. * This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer * For conditions of distribution and use, see the disclaimer
@@ -334,17 +334,25 @@ typedef const png_uint_16p * png_const_uint_16pp;
/* Other defines specific to compilers can go here. Try to keep /* Other defines specific to compilers can go here. Try to keep
* them inside an appropriate ifdef/endif pair for portability. * them inside an appropriate ifdef/endif pair for portability.
*/ */
#if defined(PNG_FLOATING_POINT_SUPPORTED) ||\ #if defined PNG_sCAL_SUPPORTED && defined PNG_FLOATING_POINT_SUPPORTED
defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)
/* png.c requires the following ANSI-C constants if the conversion of /* png.c requires the following ANSI-C constants if the conversion of
* floating point to ASCII is implemented therein: * 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_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_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) * DBL_MAX Maximum floating point number (can be set to an arbitrary value)
*/ */
# include <float.h> # include <float.h>
#endif /* sCAL && FLOATING_POINT */
#if defined PNG_FLOATING_ARITHMETIC_SUPPORTED ||\
defined PNG_FLOATING_POINT_SUPPORTED
/* Certain floating point functions are used internally; only floor and ceil
* if FLOATING_POINT is supported, but if FLOATING_ARITHMETIC is used then
* pow and exp are needed too.
*/
# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \ # if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC) defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
/* We need to check that <math.h> hasn't already been included earlier /* We need to check that <math.h> hasn't already been included earlier
@@ -363,32 +371,7 @@ typedef const png_uint_16p * png_const_uint_16pp;
*/ */
# include <m68881.h> # include <m68881.h>
# endif # endif
#endif #endif /* FLOATING_ARITHMETIC || FLOATING_POINT */
/* 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. */ /* These macros may need to be architecture dependent. */
#define PNG_ALIGN_NONE 0 /* do not use data alignment */ #define PNG_ALIGN_NONE 0 /* do not use data alignment */
@@ -458,7 +441,7 @@ typedef const png_uint_16p * png_const_uint_16pp;
#define PNG_HAVE_CHUNK_HEADER 0x100 #define PNG_HAVE_CHUNK_HEADER 0x100
#define PNG_WROTE_tIME 0x200 #define PNG_WROTE_tIME 0x200
#define PNG_WROTE_INFO_BEFORE_PLTE 0x400 #define PNG_WROTE_INFO_BEFORE_PLTE 0x400
#define PNG_BACKGROUND_IS_GRAY 0x800 /* 0x800 (unused) */
#define PNG_HAVE_PNG_SIGNATURE 0x1000 #define PNG_HAVE_PNG_SIGNATURE 0x1000
#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */ #define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */
/* 0x4000 (unused) */ /* 0x4000 (unused) */
@@ -472,10 +455,10 @@ typedef const png_uint_16p * png_const_uint_16pp;
#define PNG_SWAP_BYTES 0x0010 #define PNG_SWAP_BYTES 0x0010
#define PNG_INVERT_MONO 0x0020 #define PNG_INVERT_MONO 0x0020
#define PNG_QUANTIZE 0x0040 #define PNG_QUANTIZE 0x0040
#define PNG_COMPOSE 0x0080 /* Was PNG_BACKGROUND */ #define PNG_COMPOSE 0x0080 /* Was PNG_BACKGROUND */
#define PNG_BACKGROUND_EXPAND 0x0100 /* 0x0100 unused */
#define PNG_EXPAND_16 0x0200 /* Added to libpng 1.5.2 */ #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_16_TO_8 0x0400 /* Becomes 'chop' in 1.5.4 */
#define PNG_RGBA 0x0800 #define PNG_RGBA 0x0800
#define PNG_EXPAND 0x1000 #define PNG_EXPAND 0x1000
#define PNG_GAMMA 0x2000 #define PNG_GAMMA 0x2000
@@ -490,13 +473,13 @@ typedef const png_uint_16p * png_const_uint_16pp;
#define PNG_RGB_TO_GRAY_WARN 0x400000 #define PNG_RGB_TO_GRAY_WARN 0x400000
#define PNG_RGB_TO_GRAY 0x600000 /* two bits, RGB_TO_GRAY_ERR|WARN */ #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_ENCODE_ALPHA 0x800000 /* Added to libpng-1.5.4 */
#define PNG_ADD_ALPHA 0x1000000 /* Added to libpng-1.2.7 */ #define PNG_ADD_ALPHA 0x1000000 /* Added to libpng-1.2.7 */
#define PNG_EXPAND_tRNS 0x2000000 /* Added to libpng-1.2.9 */ #define PNG_EXPAND_tRNS 0x2000000 /* Added to libpng-1.2.9 */
#define PNG_SCALE_16_TO_8 0x4000000 /* Added to libpng-1.5.4 */ #define PNG_SCALE_16_TO_8 0x4000000 /* Added to libpng-1.5.4 */
/* 0x8000000 unused */ /* 0x8000000 unused */
/* 0x10000000 unused */ /* 0x10000000 unused */
/* 0x20000000 unused */ /* 0x20000000 unused */
/* 0x40000000 unused */ /* 0x40000000 unused */
/* Flags for png_create_struct */ /* Flags for png_create_struct */
#define PNG_STRUCT_PNG 0x0001 #define PNG_STRUCT_PNG 0x0001
#define PNG_STRUCT_INFO 0x0002 #define PNG_STRUCT_INFO 0x0002
@@ -529,8 +512,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_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_WARNINGS_WARN 0x200000 /* Added to libpng-1.6.0 */
#define PNG_FLAG_APP_ERRORS_WARN 0x400000 /* Added to libpng-1.6.0 */ #define PNG_FLAG_APP_ERRORS_WARN 0x400000 /* Added to libpng-1.6.0 */
/* 0x800000 unused */ #define PNG_FLAG_BACKGROUND_IS_GRAY 0x800000
/* 0x1000000 unused */ #define PNG_FLAG_BACKGROUND_EXPAND 0x1000000
/* 0x2000000 unused */ /* 0x2000000 unused */
/* 0x4000000 unused */ /* 0x4000000 unused */
/* 0x8000000 unused */ /* 0x8000000 unused */
@@ -733,6 +716,16 @@ PNG_INTERNAL_FUNCTION(void,png_free_buffer_list,(png_structrp png_ptr,
/* Free the buffer list used by the compressed write code. */ /* Free the buffer list used by the compressed write code. */
#endif #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) && \ #if defined(PNG_FLOATING_POINT_SUPPORTED) && \
!defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \ !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \
(defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \ (defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \
@@ -1802,7 +1795,7 @@ PNG_INTERNAL_FUNCTION(png_byte,png_gamma_8bit_correct,(unsigned int value,
png_fixed_point gamma_value),PNG_EMPTY); png_fixed_point gamma_value),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_destroy_gamma_table,(png_structrp png_ptr), PNG_INTERNAL_FUNCTION(void,png_destroy_gamma_table,(png_structrp png_ptr),
PNG_EMPTY); 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); int bit_depth),PNG_EMPTY);
#endif #endif
@@ -1862,6 +1855,16 @@ PNG_INTERNAL_FUNCTION(void, png_image_free, (png_imagep image), PNG_EMPTY);
#endif /* SIMPLIFIED READ/WRITE */ #endif /* SIMPLIFIED READ/WRITE */
#ifdef PNG_FILTER_OPTIMIZATIONS
PNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structrp png_ptr,
unsigned int bpp), PNG_EMPTY);
/* This is the initialization function for hardware specific optimizations,
* one implementation (for ARM NEON machines) is contained in
* arm/filter_neon.c. It need not be defined - the generic code will be used
* if not.
*/
#endif
/* Maintainer: Put new private prototypes here ^ */ /* Maintainer: Put new private prototypes here ^ */
#include "pngdebug.h" #include "pngdebug.h"

View File

@@ -1,7 +1,7 @@
/* pngrio.c - functions for data input /* pngrio.c - functions for data input
* *
* Last changed in libpng 1.6.0 [(PENDING RELEASE)] * Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Copyright (c) 1998-2012 Glenn Randers-Pehrson * Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (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; png_ptr->read_data_fn = read_data_fn;
#endif #endif
#ifdef PNG_WRITE_SUPPORTED
/* It is an error to write to a read device */ /* It is an error to write to a read device */
if (png_ptr->write_data_fn != NULL) 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" "Can't set both read_data_fn and write_data_fn in the"
" same structure"); " same structure");
} }
#endif
#ifdef PNG_WRITE_FLUSH_SUPPORTED #ifdef PNG_WRITE_FLUSH_SUPPORTED
png_ptr->output_flush_fn = NULL; png_ptr->output_flush_fn = NULL;

1126
pngrtran.c

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
/* pngrutil.c - utilities to read a PNG file /* pngrutil.c - utilities to read a PNG file
* *
* Last changed in libpng 1.6.0 [(PENDING RELEASE)] * Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Copyright (c) 1998-2012 Glenn Randers-Pehrson * Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -18,8 +18,6 @@
#ifdef PNG_READ_SUPPORTED #ifdef PNG_READ_SUPPORTED
#define png_strtod(p,a,b) strtod(a,b)
png_uint_32 PNGAPI png_uint_32 PNGAPI
png_get_uint_31(png_const_structrp png_ptr, png_const_bytep buf) png_get_uint_31(png_const_structrp png_ptr, png_const_bytep buf)
{ {
@@ -562,7 +560,7 @@ png_decompress_chunk(png_structrp png_ptr,
*/ */
png_alloc_size_t limit = PNG_SIZE_MAX; png_alloc_size_t limit = PNG_SIZE_MAX;
# ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED # ifdef PNG_SET_USER_LIMITS_SUPPOPRTED
if (png_ptr->user_chunk_malloc_max > 0 && if (png_ptr->user_chunk_malloc_max > 0 &&
png_ptr->user_chunk_malloc_max < limit) png_ptr->user_chunk_malloc_max < limit)
limit = png_ptr->user_chunk_malloc_max; limit = png_ptr->user_chunk_malloc_max;
@@ -1582,7 +1580,8 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if (--png_ptr->user_chunk_cache_max == 1) 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); png_crc_finish(png_ptr, length);
return; return;
} }
@@ -1832,6 +1831,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_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans,
&(png_ptr->trans_color)); &(png_ptr->trans_color));
png_ptr->trans_alpha = info_ptr->trans_alpha;
} }
#endif #endif
@@ -2370,7 +2371,7 @@ png_handle_tEXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if (--png_ptr->user_chunk_cache_max == 1) if (--png_ptr->user_chunk_cache_max == 1)
{ {
png_crc_finish(png_ptr, length); 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; return;
} }
} }
@@ -2449,7 +2450,7 @@ png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if (--png_ptr->user_chunk_cache_max == 1) if (--png_ptr->user_chunk_cache_max == 1)
{ {
png_crc_finish(png_ptr, length); 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; return;
} }
} }
@@ -2558,7 +2559,7 @@ png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if (--png_ptr->user_chunk_cache_max == 1) if (--png_ptr->user_chunk_cache_max == 1)
{ {
png_crc_finish(png_ptr, length); 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; return;
} }
} }
@@ -2698,7 +2699,7 @@ png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length)
png_ptr->unknown_chunk.data = NULL; png_ptr->unknown_chunk.data = NULL;
} }
# ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED # ifdef PNG_SET_USER_LIMITS_SUPPOPRTED
if (png_ptr->user_chunk_malloc_max > 0 && if (png_ptr->user_chunk_malloc_max > 0 &&
png_ptr->user_chunk_malloc_max < limit) png_ptr->user_chunk_malloc_max < limit)
limit = png_ptr->user_chunk_malloc_max; limit = png_ptr->user_chunk_malloc_max;
@@ -2893,7 +2894,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
{ {
case 2: case 2:
png_ptr->user_chunk_cache_max = 1; 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 */ /* FALL THROUGH */
case 1: case 1:
/* NOTE: prior to 1.6.0 this case resulted in an unknown critical /* NOTE: prior to 1.6.0 this case resulted in an unknown critical
@@ -3863,68 +3864,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 static void
png_init_filter_functions(png_structrp pp) 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; unsigned int bpp = (pp->pixel_depth + 7) >> 3;
@@ -3938,8 +3887,16 @@ png_init_filter_functions(png_structrp pp)
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
png_read_filter_row_paeth_multibyte_pixel; png_read_filter_row_paeth_multibyte_pixel;
#ifdef PNG_ARM_NEON #ifdef PNG_FILTER_OPTIMIZATIONS
png_init_filter_functions_neon(pp, bpp); /* 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 #endif
} }
@@ -3947,6 +3904,10 @@ void /* PRIVATE */
png_read_filter_row(png_structrp pp, png_row_infop row_info, png_bytep row, png_read_filter_row(png_structrp pp, png_row_infop row_info, png_bytep row,
png_const_bytep prev_row, int filter) 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) if (pp->read_filter[0] == NULL)
png_init_filter_functions(pp); png_init_filter_functions(pp);
if (filter > PNG_FILTER_VALUE_NONE && filter < PNG_FILTER_VALUE_LAST) if (filter > PNG_FILTER_VALUE_NONE && filter < PNG_FILTER_VALUE_LAST)
@@ -4410,7 +4371,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
png_error(png_ptr, "This image requires a row greater than 64KB"); png_error(png_ptr, "This image requires a row greater than 64KB");
#endif #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_row_buf);
png_free(png_ptr, png_ptr->big_prev_row); png_free(png_ptr, png_ptr->big_prev_row);
@@ -4447,7 +4408,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
png_ptr->row_buf = png_ptr->big_row_buf + 31; png_ptr->row_buf = png_ptr->big_row_buf + 31;
png_ptr->prev_row = png_ptr->big_prev_row + 31; png_ptr->prev_row = png_ptr->big_prev_row + 31;
#endif #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 #ifdef PNG_MAX_MALLOC_64K

130
pngset.c
View File

@@ -1,7 +1,7 @@
/* pngset.c - storage of image information into info struct /* pngset.c - storage of image information into info struct
* *
* Last changed in libpng 1.6.0 [(PENDING RELEASE)] * Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Copyright (c) 1998-2012 Glenn Randers-Pehrson * Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -431,7 +431,8 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
info_ptr->free_me |= PNG_FREE_SCAL; 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 void PNGAPI
png_set_sCAL(png_const_structrp png_ptr, png_inforp info_ptr, int unit, png_set_sCAL(png_const_structrp png_ptr, png_inforp info_ptr, int unit,
double width, double height) double width, double height)
@@ -910,52 +911,89 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
if (png_ptr == NULL || info_ptr == NULL) if (png_ptr == NULL || info_ptr == NULL)
return; 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; int max_num;
* 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).
*/
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 */ /* Do this just in case the old data was not owned by libpng: */
png_ptr->trans_alpha = info_ptr->trans_alpha = png_voidcast(png_bytep, info_ptr->valid &= ~PNG_INFO_tRNS;
png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH)); info_ptr->trans_alpha = NULL;
info_ptr->num_trans = 0;
if (num_trans > 0 && num_trans <= PNG_MAX_PALETTE_LENGTH) /* Expect png_set_PLTE to happen before png_set_tRNS, so num_palette will
memcpy(info_ptr->trans_alpha, trans_alpha, (png_size_t)num_trans); * 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, 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 && if (trans_color != NULL)
trans_color->gray > sample_max) || {
(info_ptr->color_type == PNG_COLOR_TYPE_RGB && int sample_max = (1 << info_ptr->bit_depth);
(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");
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) else
num_trans = 1; png_chunk_report(png_ptr,
} "tRNS chunk has out-of-range samples for bit_depth",
PNG_CHUNK_ERROR);
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;
} }
} }
#endif #endif
@@ -1487,19 +1525,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 * rejected by png_set_IHDR(). To accept any PNG datastream
* regardless of dimensions, set both limits to 0x7ffffffL. * regardless of dimensions, set both limits to 0x7ffffffL.
*/ */
if (png_ptr == NULL) if (png_ptr != NULL)
return; {
png_ptr->user_width_max = user_width_max;
png_ptr->user_width_max = user_width_max; png_ptr->user_height_max = user_height_max;
png_ptr->user_height_max = user_height_max; }
} }
/* This function was added to libpng 1.4.0 */ /* This function was added to libpng 1.4.0 */
void PNGAPI void PNGAPI
png_set_chunk_cache_max (png_structrp png_ptr, png_uint_32 user_chunk_cache_max) png_set_chunk_cache_max (png_structrp png_ptr, png_uint_32 user_chunk_cache_max)
{ {
if (png_ptr) if (png_ptr != NULL)
png_ptr->user_chunk_cache_max = user_chunk_cache_max; png_ptr->user_chunk_cache_max = user_chunk_cache_max;
} }
/* This function was added to libpng 1.4.1 */ /* This function was added to libpng 1.4.1 */
@@ -1507,7 +1545,7 @@ void PNGAPI
png_set_chunk_malloc_max (png_structrp png_ptr, png_set_chunk_malloc_max (png_structrp png_ptr,
png_alloc_size_t user_chunk_malloc_max) 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; png_ptr->user_chunk_malloc_max = user_chunk_malloc_max;
} }
#endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */ #endif /* ?PNG_SET_USER_LIMITS_SUPPORTED */

View File

@@ -28,7 +28,7 @@
/* We must ensure that zlib uses 'const' in declarations. */ /* We must ensure that zlib uses 'const' in declarations. */
# define ZLIB_CONST # define ZLIB_CONST
#endif #endif
#include "zlib.h" #include PNG_ZLIB_HEADER
#ifdef const #ifdef const
/* zlib.h sometimes #defines const to nothing, undo this. */ /* zlib.h sometimes #defines const to nothing, undo this. */
# undef const # undef const
@@ -48,10 +48,10 @@
/* zlib.h declares a magic type 'uInt' that limits the amount of data that zlib /* 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 * 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 * 65535), this define allows us to discover how big it is, but limited by the
* maximuum for png_size_t. The value can be overriden in a library build * maximum for size_t. The value can be overridden in a library build (pngusr.h,
* (pngusr.h, or set it in CPPFLAGS) and it works to set it to a considerably * or set it in CPPFLAGS) and it works to set it to a considerably lower value
* lower value (e.g. 255 works). A lower value may help memory usage (slightly) * (e.g. 255 works). A lower value may help memory usage (slightly) and may
* and may even improve performance on some systems (and degrade it on others.) * even improve performance on some systems (and degrade it on others.)
*/ */
#ifndef ZLIB_IO_MAX #ifndef ZLIB_IO_MAX
# define ZLIB_IO_MAX ((uInt)-1) # define ZLIB_IO_MAX ((uInt)-1)
@@ -137,313 +137,235 @@ typedef const png_colorspace * PNG_RESTRICT png_const_colorspacerp;
#define PNG_COLORSPACE_FROM_sRGB 0x0020 #define PNG_COLORSPACE_FROM_sRGB 0x0020
#define PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB 0x0040 #define PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB 0x0040
#define PNG_COLORSPACE_MATCHES_sRGB 0x0080 /* exact match on profile */ #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_INVALID 0x8000
#define PNG_COLORSPACE_CANCEL(flags) (0xffff ^ (flags)) #define PNG_COLORSPACE_CANCEL(flags) (0xffff ^ (flags))
#endif /* COLORSPACE || GAMMA */ #endif /* COLORSPACE || GAMMA */
struct png_struct_def struct png_struct_def
{ {
#ifdef PNG_SETJMP_SUPPORTED /* Rearranged in libpng 1.7 to attempt to lessen padding; in general
jmp_buf jmp_buf_local; /* New name in 1.6.0 for jmp_buf in png_struct */ * (char), (short), (int) and pointer types are kept separate, however
png_longjmp_ptr longjmp_fn;/* setjmp non-local goto function. */ * associated members under the control of the same #define are still
jmp_buf *jmp_buf_ptr; /* passed to longjmp_fn */ * together.
size_t jmp_buf_size; /* size of the above, if allocated */ *
#endif * First the frequently accessed fields. Many processors perform arithmetic
png_error_ptr error_fn; /* function for printing errors and aborting */ * in the address pipeline, but frequently the amount of addition or
#ifdef PNG_WARNINGS_SUPPORTED * subtraction is limited. By putting these fields at the head of png_struct
png_error_ptr warning_fn; /* function for printing warnings */ * the hope is that such processors will generate code that is both smaller
#endif * and faster.
png_voidp error_ptr; /* user supplied struct for error functions */ */
png_rw_ptr write_data_fn; /* function for writing output data */ png_colorp palette; /* palette from the input file */
png_rw_ptr read_data_fn; /* function for reading input data */ size_t rowbytes; /* size of row in bytes */
png_voidp io_ptr; /* ptr to application struct for I/O functions */ 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 */
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED int maximum_pixel_depth; /* pixel depth used for the row buffers */
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
/* 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 */
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED #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 #endif
png_uint_16 num_palette; /* number of color entries in palette */
png_uint_16 num_trans; /* number of transparency values */ 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 filter; /* file filter type (always 0) */
png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */ png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
png_byte pass; /* current interlace pass (0 - 6) */ png_byte pass; /* current interlace pass (0 - 6) */
png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */ png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */
png_byte color_type; /* color type of file */ png_byte color_type; /* color type of file */
png_byte bit_depth; /* bit depth 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 pixel_depth; /* number of bits per pixel */
png_byte channels; /* number of channels in file */ 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 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; png_byte transformed_pixel_depth;
/* pixel depth after read/write transforms */ /* 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 can have very high alignment requirements on some systems, so put
* it first.
*/
jmp_buf jmp_buf_local;
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 #endif
#if defined(PNG_bKGD_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) ||\ /* Error/warning callbacks */
defined(PNG_READ_ALPHA_MODE_SUPPORTED) png_error_ptr error_fn; /* print an error message and abort */
png_byte background_gamma_type; #ifdef PNG_WARNINGS_SUPPORTED
png_fixed_point background_gamma; png_error_ptr warning_fn; /* print a warning and continue */
png_color_16 background; /* background color in screen gamma space */ #endif
#ifdef PNG_READ_GAMMA_SUPPORTED png_voidp error_ptr; /* user supplied data for the above */
png_color_16 background_1; /* background normalized to gamma 1.0 */
/* 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
#endif /* PNG_bKGD_SUPPORTED */
#ifdef PNG_WRITE_FLUSH_SUPPORTED #ifdef PNG_WRITE_FLUSH_SUPPORTED
png_flush_ptr output_flush_fn; /* Function for flushing output */ 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_dist; /* how many rows apart to flush, 0 - no flush */
png_uint_32 flush_rows; /* number of rows written since last 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 */
#endif #endif
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED #ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
png_byte heuristic_method; /* heuristic for row filter selection */ png_bytep prev_filters; /* filter type(s) of previous row(s) */
png_byte num_prev_filters; /* number of weights for previous rows */
png_bytep prev_filters; /* filter type(s) of previous row(s) */
png_uint_16p filter_weights; /* weight(s) for previous line(s) */ png_uint_16p filter_weights; /* weight(s) for previous line(s) */
png_uint_16p inv_filter_weights; /* 1/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 filter_costs; /* relative filter calculation cost */
png_uint_16p inv_filter_costs; /* 1/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 #endif
#if PNG_LIBPNG_VER < 10700 #ifdef PNG_WRITE_SUPPORTED
/* To do: remove this from libpng-1.7 */ png_byte usr_bit_depth; /* bit depth of users row */
#ifdef PNG_TIME_RFC1123_SUPPORTED png_byte usr_channels; /* channels at start of write */
char time_buffer[29]; /* String to hold RFC 1123 time text */
#endif
#endif #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 #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; png_voidp user_chunk_ptr;
#endif
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED #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
#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 #ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
/* Temporary storage for unknown chunk that the library doesn't recognize, /* Temporary storage for unknown chunk that the library doesn't recognize,
* used while reading the chunk. * used while reading the chunk.
@@ -451,33 +373,175 @@ struct png_struct_def
png_unknown_chunk unknown_chunk; png_unknown_chunk unknown_chunk;
#endif #endif
/* New member added in libpng-1.2.26 */ #ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
png_size_t old_big_row_buf_size; 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
/* 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 #ifdef PNG_READ_SUPPORTED
/* New member added in libpng-1.2.30 */ /* These, and IDAT_read_size below, control how much input and output (at
png_bytep read_buffer; /* buffer for reading chunk data */ * most) is available to zlib.
png_alloc_size_t read_buffer_size; /* current size of the buffer */ */
png_uint_32 idat_size; /* current IDAT size for read */
png_alloc_size_t read_buffer_size; /* current size of the buffer */
#endif #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 #ifdef PNG_SEQUENTIAL_READ_SUPPORTED
uInt IDAT_read_size; /* limit on read buffer size for IDAT */ 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
#endif #endif
}; };
#endif /* PNGSTRUCT_H */ #endif /* PNGSTRUCT_H */

View File

@@ -1,7 +1,7 @@
/* pngtest.c - a simple test program to test libpng /* pngtest.c - a simple test program to test libpng
* *
* Last changed in libpng 1.6.0 [(PENDING RELEASE)] * Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Copyright (c) 1998-2012 Glenn Randers-Pehrson * Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -44,7 +44,7 @@
#include "png.h" #include "png.h"
#ifdef PNG_READ_SUPPORTED /* else nothing can be done */ #ifdef PNG_READ_SUPPORTED /* else nothing can be done */
#include "zlib.h" #include PNG_ZLIB_HEADER /* defined by pnglibconf.h */
/* Copied from pngpriv.h but only used in error messages below. */ /* Copied from pngpriv.h but only used in error messages below. */
#ifndef PNG_ZBUF_SIZE #ifndef PNG_ZBUF_SIZE
# define PNG_ZBUF_SIZE 8192 # define PNG_ZBUF_SIZE 8192
@@ -100,10 +100,6 @@ static int unsupported_chunks = 0; /* chunk unsupported by libpng in input */
static int error_count = 0; /* count calls to png_error */ static int error_count = 0; /* count calls to png_error */
static int warning_count = 0; /* count calls to png_warning */ 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 */ /* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */
#ifndef png_jmpbuf #ifndef png_jmpbuf
# define png_jmpbuf(png_ptr) png_ptr->jmpbuf # define png_jmpbuf(png_ptr) png_ptr->jmpbuf
@@ -1173,7 +1169,8 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
} }
#endif #endif
#ifdef PNG_sCAL_SUPPORTED #ifdef PNG_sCAL_SUPPORTED
#ifdef PNG_FLOATING_POINT_SUPPORTED #if defined PNG_FLOATING_POINT_SUPPORTED && \
defined PNG_FLOATING_ARITHMETIC_SUPPORTED
{ {
int unit; int unit;
double scal_width, scal_height; double scal_width, scal_height;
@@ -1949,4 +1946,4 @@ main(void)
#endif #endif
/* Generate a compiler error if there is an old png.h in the search path. */ /* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_6_0beta33 Your_png_h_is_not_version_1_6_0beta33; typedef png_libpng_version_1_7_0alpha03 Your_png_h_is_not_version_1_7_0alpha03;

View File

@@ -1,7 +1,7 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers) /* pngtrans.c - transforms the data in a row (used by both readers and writers)
* *
* Last changed in libpng 1.6.0 [(PENDING RELEASE)] * Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Copyright (c) 1998-2012 Glenn Randers-Pehrson * Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (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) if (png_ptr->bit_depth < 8)
{ {
png_ptr->transformations |= PNG_PACK; png_ptr->transformations |= PNG_PACK;
png_ptr->usr_bit_depth = 8; # ifdef PNG_WRITE_SUPPORTED
png_ptr->usr_bit_depth = 8;
# endif
} }
} }
#endif #endif

View File

@@ -1,7 +1,7 @@
/* pngwio.c - functions for data output /* pngwio.c - functions for data output
* *
* Last changed in libpng 1.6.0 [(PENDING RELEASE)] * Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Copyright (c) 1998-2012 Glenn Randers-Pehrson * Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (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
#endif /* PNG_WRITE_FLUSH_SUPPORTED */ #endif /* PNG_WRITE_FLUSH_SUPPORTED */
#ifdef PNG_READ_SUPPORTED
/* It is an error to read while writing a png file */ /* It is an error to read while writing a png file */
if (png_ptr->read_data_fn != NULL) 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" "Can't set both read_data_fn and write_data_fn in the"
" same structure"); " same structure");
} }
#endif
} }
#endif /* PNG_WRITE_SUPPORTED */ #endif /* PNG_WRITE_SUPPORTED */

View File

@@ -1,7 +1,7 @@
/* pngwrite.c - general routines to write a PNG file /* pngwrite.c - general routines to write a PNG file
* *
* Last changed in libpng 1.6.0 [(PENDING RELEASE)] * Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Copyright (c) 1998-2012 Glenn Randers-Pehrson * Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -216,8 +216,13 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
if ((png_ptr->transformations & PNG_INVERT_ALPHA) && if ((png_ptr->transformations & PNG_INVERT_ALPHA) &&
info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{ {
int j; int j, jend;
for (j = 0; j<(int)info_ptr->num_trans; j++)
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] = info_ptr->trans_alpha[j] =
(png_byte)(255 - info_ptr->trans_alpha[j]); (png_byte)(255 - info_ptr->trans_alpha[j]);
} }
@@ -927,42 +932,52 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) && if ((png_ptr->mng_features_permitted & PNG_FLAG_MNG_FILTER_64) &&
(method == PNG_INTRAPIXEL_DIFFERENCING)) (method == PNG_INTRAPIXEL_DIFFERENCING))
method = PNG_FILTER_TYPE_BASE; method = PNG_FILTER_TYPE_BASE;
#endif #endif
if (method == PNG_FILTER_TYPE_BASE)
{ /* The only supported method, except for the check above, is
switch (filters & (PNG_ALL_FILTERS | 0x07)) * 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 png_app_error(png_ptr, "png_set_filter: invalid filters mask/value");
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;
#ifdef PNG_WRITE_FILTER_SUPPORTED /* For compatibility with the previous behavior assume a mask value was
case PNG_FILTER_VALUE_SUB: * passed and ignore the non-mask bits.
png_ptr->do_filter = PNG_FILTER_SUB; break; */
filters &= PNG_ALL_FILTERS;
case PNG_FILTER_VALUE_UP: /* For a possibly foolish consistency (it shouldn't matter) set
png_ptr->do_filter = PNG_FILTER_UP; break; * PNG_FILTER_NONE rather than 0.
*/
case PNG_FILTER_VALUE_AVG: if (filters == 0)
png_ptr->do_filter = PNG_FILTER_AVG; break; filters = PNG_FILTER_NONE;
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 */
} }
# 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 /* 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 * 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 * that have been selected. If prev_row isn't already allocated, then
@@ -971,75 +986,45 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
* wants to start and stop using particular filters during compression, * wants to start and stop using particular filters during compression,
* it should start out with all of the filters, and then add and * it should start out with all of the filters, and then add and
* remove them after the start of compression. * 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) if (png_ptr->row_buf != NULL)
{ {
#ifdef PNG_WRITE_FILTER_SUPPORTED /* Repeat the checks in png_write_start_row; 1 pixel high or wide
if ((png_ptr->do_filter & PNG_FILTER_SUB) && png_ptr->sub_row == NULL) * 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, /* This is the error case, however it is benign - the previous row
(png_ptr->rowbytes + 1)); * is not available so the filter can't be used. Just warn here.
png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB; */
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) /* Allocate any required buffers that have not already been allocated.
{ */
if (png_ptr->prev_row == NULL) png_write_alloc_filter_row_buffers(png_ptr, filters);
{
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;
} }
} # endif /* PNG_WRITE_FILTER_SUPPORTED */
else
png_error(png_ptr, "Unknown custom filter method"); /* 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" /* This allows us to influence the way in which libpng chooses the "best"

View File

@@ -1,7 +1,7 @@
/* pngwutil.c - utilities to write a PNG file /* pngwutil.c - utilities to write a PNG file
* *
* Last changed in libpng 1.6.0 [(PENDING RELEASE)] * Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Copyright (c) 1998-2012 Glenn Randers-Pehrson * Copyright (c) 1998-2012 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@@ -1425,10 +1425,11 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
if (color_type == PNG_COLOR_TYPE_PALETTE) 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, /* This is an error which can only be reliably detected late. */
"Invalid number of transparent colors specified"); png_app_error(png_ptr,
"Invalid number of transparent colors specified");
return; return;
} }
@@ -1442,7 +1443,8 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
/* One 16 bit value */ /* One 16 bit value */
if (tran->gray >= (1 << png_ptr->bit_depth)) 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"); "Ignoring attempt to write tRNS chunk out-of-range for bit_depth");
return; return;
@@ -1464,7 +1466,8 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
if (buf[0] | buf[2] | buf[4]) if (buf[0] | buf[2] | buf[4])
#endif #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"); "Ignoring attempt to write 16-bit tRNS chunk when bit_depth is 8");
return; return;
} }
@@ -1474,7 +1477,8 @@ png_write_tRNS(png_structrp png_ptr, png_const_bytep trans_alpha,
else 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 #endif
@@ -1931,6 +1935,47 @@ png_write_tIME(png_structrp png_ptr, png_const_timep mod_time)
} }
#endif #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 */ /* Initializes the row writing capability of libpng */
void /* PRIVATE */ void /* PRIVATE */
png_write_start_row(png_structrp png_ptr) png_write_start_row(png_structrp png_ptr)
@@ -1951,11 +1996,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}; static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
#endif #endif
#ifdef PNG_WRITE_FILTER_SUPPORTED
int filters;
#endif
png_alloc_size_t buf_size; png_alloc_size_t buf_size;
int usr_pixel_depth; int usr_pixel_depth;
png_debug(1, "in png_write_start_row"); 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; usr_pixel_depth = png_ptr->usr_channels * png_ptr->usr_bit_depth;
buf_size = PNG_ROWBYTES(usr_pixel_depth, png_ptr->width) + 1; buf_size = PNG_ROWBYTES(usr_pixel_depth, png_ptr->width) + 1;
@@ -1964,49 +2016,34 @@ png_write_start_row(png_structrp png_ptr)
png_ptr->maximum_pixel_depth = (png_byte)usr_pixel_depth; png_ptr->maximum_pixel_depth = (png_byte)usr_pixel_depth;
/* Set up row buffer */ /* 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; png_ptr->row_buf[0] = PNG_FILTER_VALUE_NONE;
#ifdef PNG_WRITE_FILTER_SUPPORTED #ifdef PNG_WRITE_FILTER_SUPPORTED
/* Set up filtering buffer, if using this filter */ filters = png_ptr->do_filter;
if (png_ptr->do_filter & PNG_FILTER_SUB)
{
png_ptr->sub_row = (png_bytep)png_malloc(png_ptr, png_ptr->rowbytes + 1);
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->width == 1)
if (png_ptr->do_filter & (PNG_FILTER_AVG | PNG_FILTER_UP | PNG_FILTER_PAETH)) filters &= ~(PNG_FILTER_SUB|PNG_FILTER_AVG|PNG_FILTER_PAETH);
{
/* Set up previous row buffer */
png_ptr->prev_row = (png_bytep)png_calloc(png_ptr, buf_size);
if (png_ptr->do_filter & PNG_FILTER_UP) if (filters == 0)
{ filters = PNG_FILTER_NONE;
png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
png_ptr->rowbytes + 1);
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_write_alloc_filter_row_buffers(png_ptr, filters);
{
png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
png_ptr->rowbytes + 1);
png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG; png_ptr->do_filter = (png_byte)filters; /* in case it was changed above */
} #else
png_ptr->do_filter = PNG_FILTER_NONE;
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;
}
}
#endif /* PNG_WRITE_FILTER_SUPPORTED */ #endif /* PNG_WRITE_FILTER_SUPPORTED */
#ifdef PNG_WRITE_INTERLACING_SUPPORTED #ifdef PNG_WRITE_INTERLACING_SUPPORTED
@@ -2994,6 +3031,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); png_compress_IDAT(png_ptr, filtered_row, full_row_length, Z_NO_FLUSH);
#ifdef PNG_WRITE_FILTER_SUPPORTED
/* Swap the current and previous rows */ /* Swap the current and previous rows */
if (png_ptr->prev_row != NULL) if (png_ptr->prev_row != NULL)
{ {
@@ -3003,6 +3041,7 @@ png_write_filtered_row(png_structrp png_ptr, png_bytep filtered_row,
png_ptr->prev_row = png_ptr->row_buf; png_ptr->prev_row = png_ptr->row_buf;
png_ptr->row_buf = tptr; png_ptr->row_buf = tptr;
} }
#endif /* PNG_WRITE_FILTER_SUPPORTED */
/* Finish row - updates counters and flushes zlib if last row */ /* Finish row - updates counters and flushes zlib if last row */
png_write_finish_row(png_ptr); png_write_finish_row(png_ptr);

View File

@@ -30,7 +30,7 @@
Name="VCCustomBuildTool"/> Name="VCCustomBuildTool"/>
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
OutputFile="$(OutDir)/libpng16.dll" OutputFile="$(OutDir)/libpng17.dll"
LinkIncremental="1"/> LinkIncremental="1"/>
<Tool <Tool
Name="VCMIDLTool"/> Name="VCMIDLTool"/>
@@ -78,7 +78,7 @@
Name="VCCustomBuildTool"/> Name="VCCustomBuildTool"/>
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
OutputFile="$(OutDir)/libpng16d.dll" OutputFile="$(OutDir)/libpng17d.dll"
GenerateDebugInformation="TRUE"/> GenerateDebugInformation="TRUE"/>
<Tool <Tool
Name="VCMIDLTool"/> Name="VCMIDLTool"/>
@@ -126,7 +126,7 @@
Name="VCCustomBuildTool"/> Name="VCCustomBuildTool"/>
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
OutputFile="$(OutDir)/libpng16vb.dll" OutputFile="$(OutDir)/libpng17vb.dll"
LinkIncremental="1"/> LinkIncremental="1"/>
<Tool <Tool
Name="VCMIDLTool"/> Name="VCMIDLTool"/>

View File

@@ -130,7 +130,7 @@ $(TargetPath) ..\..\pngtest.png $(IntDir)\pngout.png"
Name="VCLinkerTool" Name="VCLinkerTool"
OutputFile="$(OutDir)/pngtest.exe" OutputFile="$(OutDir)/pngtest.exe"
LinkIncremental="1" LinkIncremental="1"
IgnoreDefaultLibraryNames="$(IntDir)\libpng16b.lib" IgnoreDefaultLibraryNames="$(IntDir)\libpng17b.lib"
SubSystem="1" SubSystem="1"
TargetMachine="1"/> TargetMachine="1"/>
<Tool <Tool

View File

@@ -63,23 +63,23 @@
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<CustomBuildBeforeTargets> <CustomBuildBeforeTargets>
</CustomBuildBeforeTargets> </CustomBuildBeforeTargets>
<TargetName>$(ProjectName)16</TargetName> <TargetName>$(ProjectName)17</TargetName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Library|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug Library|Win32'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<CustomBuildBeforeTargets /> <CustomBuildBeforeTargets />
<TargetName>$(ProjectName)16</TargetName> <TargetName>$(ProjectName)17</TargetName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<CustomBuildBeforeTargets> <CustomBuildBeforeTargets>
</CustomBuildBeforeTargets> </CustomBuildBeforeTargets>
<TargetName>$(ProjectName)16</TargetName> <TargetName>$(ProjectName)17</TargetName>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Library|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release Library|Win32'">
<LinkIncremental>false</LinkIncremental> <LinkIncremental>false</LinkIncremental>
<CustomBuildBeforeTargets /> <CustomBuildBeforeTargets />
<TargetName>$(ProjectName)16</TargetName> <TargetName>$(ProjectName)17</TargetName>
</PropertyGroup> </PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile> <ClCompile>
@@ -107,7 +107,7 @@
<SubSystem>Windows</SubSystem> <SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>zlib.lib</AdditionalDependencies> <AdditionalDependencies>zlib.lib</AdditionalDependencies>
<Version>16</Version> <Version>17</Version>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
@@ -164,7 +164,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>zlib.lib</AdditionalDependencies> <AdditionalDependencies>zlib.lib</AdditionalDependencies>
<Version>16</Version> <Version>17</Version>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>

View File

@@ -96,7 +96,7 @@
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libpng16.lib</AdditionalDependencies> <AdditionalDependencies>libpng17.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link> </Link>
<CustomBuildStep> <CustomBuildStep>
@@ -129,7 +129,7 @@
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies> <AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link> </Link>
<CustomBuildStep> <CustomBuildStep>
@@ -164,7 +164,7 @@
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration> <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<AdditionalDependencies>libpng16.lib</AdditionalDependencies> <AdditionalDependencies>libpng17.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link> </Link>
<CustomBuildStep> <CustomBuildStep>
@@ -199,7 +199,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies> <AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration> <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link> </Link>

View File

@@ -96,7 +96,7 @@
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies> <AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link> </Link>
<CustomBuildStep> <CustomBuildStep>
@@ -129,7 +129,7 @@
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies> <AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link> </Link>
<CustomBuildStep> <CustomBuildStep>
@@ -163,7 +163,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies> <AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration> <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link> </Link>
@@ -199,7 +199,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies> <AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration> <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link> </Link>

View File

@@ -96,7 +96,7 @@
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies> <AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link> </Link>
<CustomBuildStep> <CustomBuildStep>
@@ -129,7 +129,7 @@
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies> <AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
</Link> </Link>
<CustomBuildStep> <CustomBuildStep>
@@ -163,7 +163,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies> <AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration> <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link> </Link>
@@ -199,7 +199,7 @@
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding> <EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences> <OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>libpng16.lib;zlib.lib</AdditionalDependencies> <AdditionalDependencies>libpng17.lib;zlib.lib</AdditionalDependencies>
<AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(OutDir)</AdditionalLibraryDirectories>
<LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration> <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
</Link> </Link>

View File

@@ -1,7 +1,7 @@
VisualStudio instructions VisualStudio instructions
libpng version 1.6.0beta33 - December 10, 2012 libpng version 1.7.0alpha03 - December 19, 2012
Copyright (c) 1998-2010 Glenn Randers-Pehrson 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 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 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. from a file handle you pass in.
If you do not want to use the DLL, for example for a very small application, If you do not want to use the DLL, for example for a very small application,

View File

@@ -2,7 +2,7 @@
<!-- <!--
* zlib.props - location of zlib source * zlib.props - location of zlib source
* *
* libpng version 1.6.0beta33 - December 10, 2012 * libpng version 1.7.0alpha03 - December 19, 2012
* *
* Copyright (c) 1998-2011 Glenn Randers-Pehrson * Copyright (c) 1998-2011 Glenn Randers-Pehrson
* *

View File

@@ -1,9 +1,9 @@
Makefiles for libpng version 1.6.0beta33 - December 10, 2012 Makefiles for libpng version 1.7.0alpha03 - December 19, 2012
pnglibconf.h.prebuilt => Stores configuration settings pnglibconf.h.prebuilt => Stores configuration settings
makefile.linux => Linux/ELF makefile makefile.linux => Linux/ELF makefile
(gcc, creates libpng16.so.16.1.6.0beta33) (gcc, creates libpng17.so.17.1.7.0alpha03)
makefile.gcc => Generic makefile (gcc, creates static libpng.a) makefile.gcc => Generic makefile (gcc, creates static libpng.a)
makefile.knr => Archaic UNIX Makefile that converts files with makefile.knr => Archaic UNIX Makefile that converts files with
ansi2knr (Requires ansi2knr.c from ansi2knr (Requires ansi2knr.c from
@@ -20,7 +20,7 @@ pnglibconf.h.prebuilt => Stores configuration settings
makefile.dec => DEC Alpha UNIX makefile makefile.dec => DEC Alpha UNIX makefile
makefile.dj2 => DJGPP 2 makefile makefile.dj2 => DJGPP 2 makefile
makefile.elf => Linux/ELF makefile symbol versioning, makefile.elf => Linux/ELF makefile symbol versioning,
(gcc, creates libpng16.so.16.1.6.0beta33) (gcc, creates libpng17.so.17.1.7.0alpha03)
makefile.freebsd => FreeBSD makefile makefile.freebsd => FreeBSD makefile
makefile.gcc => Generic gcc makefile makefile.gcc => Generic gcc makefile
makefile.hpgcc => HPUX makefile using gcc 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.os2 => OS/2 Makefile (gcc and emx, requires libpng.def)
makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc makefile.sco => For SCO OSr5 ELF and Unixware 7 with Native cc
makefile.sggcc => Silicon Graphics (gcc, makefile.sggcc => Silicon Graphics (gcc,
creates libpng16.so.16.1.6.0beta33) creates libpng17.so.17.1.7.0alpha03)
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib) makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
makefile.solaris => Solaris 2.X makefile (gcc, makefile.solaris => Solaris 2.X makefile (gcc,
creates libpng16.so.16.1.6.0beta33) creates libpng17.so.17.1.7.0alpha03)
makefile.so9 => Solaris 9 makefile (gcc, makefile.so9 => Solaris 9 makefile (gcc,
creates libpng16.so.16.1.6.0beta33) creates libpng17.so.17.1.7.0alpha03)
makefile.std => Generic UNIX makefile (cc, creates static libpng.a) makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
makefile.sunos => Sun makefile makefile.sunos => Sun makefile
makefile.32sunu => Sun Ultra 32-bit makefile makefile.32sunu => Sun Ultra 32-bit makefile

View File

@@ -25,7 +25,7 @@ S-OS2 DESCRIPTION "PNG image compression library"-E
S-OS2 CODE PRELOAD MOVEABLE DISCARDABLE-E S-OS2 CODE PRELOAD MOVEABLE DISCARDABLE-E
S--E S--E
S-EXPORTS-E S-EXPORTS-E
S-;Version 1.5.0beta58-E S-;Version libpng 1. PNG_JOIN 7. PNG_JOIN 0-E
/* NOTE: PNG_JOIN is interpreted by the calling script as a signal to /* 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 * join the two things on either side, so we can do symbol

View File

@@ -11,7 +11,7 @@
# Modeled after libxml-config. # Modeled after libxml-config.
version=1.6.0beta33 version=1.7.0alpha03
prefix="" prefix=""
libdir="" libdir=""
libs="" libs=""

View File

@@ -1,10 +1,10 @@
prefix=@prefix@ prefix=@prefix@
exec_prefix=@exec_prefix@ exec_prefix=@exec_prefix@
libdir=@libdir@ libdir=@libdir@
includedir=@includedir@/libpng16 includedir=@includedir@/libpng17
Name: libpng Name: libpng
Description: Loads and saves PNG files Description: Loads and saves PNG files
Version: 1.6.0beta33 Version: 1.7.0alpha03
Libs: -L${libdir} -lpng16 Libs: -L${libdir} -lpng17
Cflags: -I${includedir} Cflags: -I${includedir}

View File

@@ -9,8 +9,8 @@
# and license in png.h # and license in png.h
# Library name: # Library name:
LIBNAME=libpng16 LIBNAME=libpng17
PNGMAJ = 16 PNGMAJ = 17
# Shared library names: # Shared library names:
LIBSO=$(LIBNAME).so LIBSO=$(LIBNAME).so
@@ -29,7 +29,7 @@ RM_F=/bin/rm -f
SUN_CC_FLAGS=-fast -xtarget=ultra SUN_CC_FLAGS=-fast -xtarget=ultra
SUN_LD_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 prefix=/a
exec_prefix=$(prefix) exec_prefix=$(prefix)
@@ -95,7 +95,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \ -e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \ -e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \ -e s!@includedir@!$(INCPATH)! \
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc -e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
libpng-config: libpng-config:
( cat scripts/libpng-config-head.in; \ ( cat scripts/libpng-config-head.in; \
@@ -106,7 +106,7 @@ libpng-config:
echo R_opts=\"-R$(LIBPATH)\"; \ echo R_opts=\"-R$(LIBPATH)\"; \
echo ccopts=\"-xtarget=ultra\"; \ echo ccopts=\"-xtarget=ultra\"; \
echo ldopts=\"-xtarget=ultra\"; \ echo ldopts=\"-xtarget=ultra\"; \
echo libs=\"-lpng16 -lz -lm\"; \ echo libs=\"-lpng17 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config chmod +x libpng-config

View File

@@ -9,8 +9,8 @@
# and license in png.h # and license in png.h
# Library name: # Library name:
LIBNAME=libpng16 LIBNAME=libpng17
PNGMAJ = 16 PNGMAJ = 17
# Shared library names: # Shared library names:
LIBSO=$(LIBNAME).so LIBSO=$(LIBNAME).so
@@ -29,7 +29,7 @@ RM_F=/bin/rm -f
SUN_CC_FLAGS=-fast -xtarget=ultra -xarch=v9 SUN_CC_FLAGS=-fast -xtarget=ultra -xarch=v9
SUN_LD_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 prefix=/a
exec_prefix=$(prefix) exec_prefix=$(prefix)
@@ -47,7 +47,7 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
CFLAGS=-I$(ZLIBINC) $(SUN_CC_FLAGS) \ CFLAGS=-I$(ZLIBINC) $(SUN_CC_FLAGS) \
# $(WARNMORE) -g -DPNG_DEBUG=5 # $(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 INCPATH=$(prefix)/include
LIBPATH=$(exec_prefix)/lib LIBPATH=$(exec_prefix)/lib
@@ -95,7 +95,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \ -e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \ -e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \ -e s!@includedir@!$(INCPATH)! \
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc -e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
libpng-config: libpng-config:
( cat scripts/libpng-config-head.in; \ ( cat scripts/libpng-config-head.in; \
@@ -106,7 +106,7 @@ libpng-config:
echo R_opts=\"-R$(LIBPATH)\"; \ echo R_opts=\"-R$(LIBPATH)\"; \
echo ccopts=\"-xtarget=ultra -xarch=v9\"; \ echo ccopts=\"-xtarget=ultra -xarch=v9\"; \
echo ldopts=\"-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 cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config chmod +x libpng-config

View File

@@ -21,8 +21,8 @@ RANLIB = ranlib
RM_F = rm -f RM_F = rm -f
LN_SF = ln -f -s LN_SF = ln -f -s
LIBNAME=libpng16 LIBNAME=libpng17
PNGMAJ = 16 PNGMAJ = 17
prefix=/usr/local prefix=/usr/local
INCPATH=$(prefix)/include INCPATH=$(prefix)/include
@@ -47,7 +47,7 @@ CRELEASE = -O2
LDRELEASE = -s LDRELEASE = -s
WARNMORE=-W -Wall WARNMORE=-W -Wall
CFLAGS = -I$(ZLIBINC) $(WARNMORE) $(CRELEASE) CFLAGS = -I$(ZLIBINC) $(WARNMORE) $(CRELEASE)
LDFLAGS = -L. -L$(ZLIBLIB) -lpng16 -lz -lm $(LDRELEASE) LDFLAGS = -L. -L$(ZLIBLIB) -lpng17 -lz -lm $(LDRELEASE)
# File extensions # File extensions
O=.o O=.o

View File

@@ -9,8 +9,8 @@
# and license in png.h # and license in png.h
# Library name: # Library name:
LIBNAME=libpng16 LIBNAME=libpng17
PNGMAJ = 16 PNGMAJ = 17
# Shared library names: # Shared library names:
LIBSO=$(LIBNAME).so 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,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz
LDFLAGS=-L. -Wl,-soname=$(LIBSOMAJ) -L$(ZLIBLIB) -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 prefix=/usr/local
exec_prefix=$(prefix) exec_prefix=$(prefix)
INCPATH=$(prefix)/include INCPATH=$(prefix)/include
@@ -91,13 +91,13 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \ -e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \ -e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \ -e s!@includedir@!$(INCPATH)! \
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc -e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
libpng-config: libpng-config:
( cat scripts/libpng-config-head.in; \ ( cat scripts/libpng-config-head.in; \
echo prefix=\"$(prefix)\"; \ echo prefix=\"$(prefix)\"; \
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo libs=\"-lpng16 -lz \"; \ echo libs=\"-lpng17 -lz \"; \
cat scripts/libpng-config-body.in ) > libpng-config cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config chmod +x libpng-config
@@ -110,7 +110,7 @@ $(LIBSOMAJ): $(OBJSDLL)
$(LIBSOMAJ) $(OBJSDLL) $(LDFLAGS) $(LIBSOMAJ) $(OBJSDLL) $(LDFLAGS)
pngtest: pngtest.o $(LIBSO) 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 test: pngtest
./pngtest ./pngtest

View File

@@ -22,16 +22,16 @@
# make clean # make clean
VERMAJ = 1 VERMAJ = 1
VERMIN = 6 VERMIN = 7
VERMIC = 0 VERMIC = 0
VER = $(VERMAJ).$(VERMIN).$(VERMIC) VER = $(VERMAJ).$(VERMIN).$(VERMIC)
NAME = libpng NAME = libpng
PACKAGE = $(NAME)-$(VER) PACKAGE = $(NAME)-$(VER)
BIN = libpng16-0.dll BIN = libpng17-0.dll
LIB = libpng16.a libpng16.dll.a libpng.a libpng.dll.a 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 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" MANIFESTVERBIN = "Libpng-$(VER): Binary files"
MANIFESTVERDEV = "Libpng-$(VER): Developer files" MANIFESTVERDEV = "Libpng-$(VER): Developer files"

View File

@@ -9,7 +9,7 @@
# For conditions of distribution and use, see the disclaimer # For conditions of distribution and use, see the disclaimer
# and license in png.h # 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 # and pnglibconf.h
prefix=/usr/local prefix=/usr/local
exec_prefix=$(prefix) exec_prefix=$(prefix)
@@ -19,8 +19,8 @@ ZLIBLIB=/usr/lib
ZLIBINC=/usr/include ZLIBINC=/usr/include
# Library name: # Library name:
LIBNAME = libpng16 LIBNAME = libpng17
PNGMAJ = 16 PNGMAJ = 17
# Shared library names: # Shared library names:
LIBSO=$(LIBNAME).dylib 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 -O3 -funroll-loops
CFLAGS=-I$(ZLIBINC) -W -Wall -O -funroll-loops $(ARCH) 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 INCPATH=$(prefix)/include
LIBPATH=$(exec_prefix)/lib LIBPATH=$(exec_prefix)/lib
@@ -87,14 +87,14 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \ -e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \ -e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \ -e s!@includedir@!$(INCPATH)! \
-e s!-lpng16!-lpng16\ -lz! > libpng.pc -e s!-lpng17!-lpng17\ -lz! > libpng.pc
libpng-config: libpng-config:
( cat scripts/libpng-config-head.in; \ ( cat scripts/libpng-config-head.in; \
echo prefix=\"$(prefix)\"; \ echo prefix=\"$(prefix)\"; \
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo L_opts=\"-L$(LIBPATH)\"; \ echo L_opts=\"-L$(LIBPATH)\"; \
echo libs=\"-lpng16 -lz\"; \ echo libs=\"-lpng17 -lz\"; \
cat scripts/libpng-config-body.in ) > libpng-config cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config chmod +x libpng-config
@@ -104,7 +104,7 @@ $(LIBSO): $(LIBSOMAJ)
$(LIBSOMAJ): $(OBJSDLL) $(LIBSOMAJ): $(OBJSDLL)
$(CC) -dynamiclib \ $(CC) -dynamiclib \
-install_name $(LIBPATH)/$(LIBSOMAJ) \ -install_name $(LIBPATH)/$(LIBSOMAJ) \
-current_version 16 -compatibility_version 16 \ -current_version 17 -compatibility_version 17 \
$(ARCH) -o $(LIBSOMAJ) \ $(ARCH) -o $(LIBSOMAJ) \
$(OBJSDLL) -L$(ZLIBLIB) -lz $(OBJSDLL) -L$(ZLIBLIB) -lz

View File

@@ -7,8 +7,8 @@
# and license in png.h # and license in png.h
# Library name: # Library name:
PNGMAJ = 16 PNGMAJ = 17
LIBNAME = libpng16 LIBNAME = libpng17
# Shared library names: # Shared library names:
LIBSO=$(LIBNAME).so LIBSO=$(LIBNAME).so
@@ -75,7 +75,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \ -e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \ -e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \ -e s!@includedir@!$(INCPATH)! \
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc -e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
libpng-config: libpng-config:
( cat scripts/libpng-config-head.in; \ ( cat scripts/libpng-config-head.in; \
@@ -83,7 +83,7 @@ libpng-config:
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo ccopts=\"-std\"; \ echo ccopts=\"-std\"; \
echo L_opts=\"-L$(LIBPATH)\"; \ echo L_opts=\"-L$(LIBPATH)\"; \
echo libs=\"-lpng16 -lz -lm\"; \ echo libs=\"-lpng17 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config chmod +x libpng-config

View File

@@ -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 # Copyright (C) 1998, 1999, 2002, 2006, 2008, 2010-2011 Greg Roelofs
# and Glenn Randers-Pehrson # and Glenn Randers-Pehrson
# Copyright (C) 1996, 1997 Andreas Dilger # Copyright (C) 1996, 1997 Andreas Dilger
@@ -10,19 +10,19 @@
# Modified for Debian by Junichi Uekawa and Josselin Mouette # Modified for Debian by Junichi Uekawa and Josselin Mouette
# Major modifications are: # Major modifications are:
# * link libpng explicitly with libz and libm # * 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 # * versioned symbols
# Library name: # Library name:
LIBNAME = libpng16 LIBNAME = libpng17
PNGMAJ = 16 PNGMAJ = 17
# Shared library names: # Shared library names:
LIBSO=$(LIBNAME).so LIBSO=$(LIBNAME).so
LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ) LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ)
LIBSOREL=$(LIBSOMAJ).$(RELEASE) LIBSOREL=$(LIBSOMAJ).$(RELEASE)
OLDSO=libpng.so OLDSO=libpng.so
OLDSOMAJ=libpng.so.16 OLDSOMAJ=libpng.so.17
# Utilities: # Utilities:
AR_RC=ar rc AR_RC=ar rc
@@ -32,8 +32,8 @@ LN_SF=ln -sf
RANLIB=ranlib RANLIB=ranlib
RM_F=/bin/rm -f RM_F=/bin/rm -f
# where "make install" puts libpng16.a, libpng16.so*, # where "make install" puts libpng17.a, libpng17.so*,
# libpng16/png.h, libpng16/pngconf.h, and libpng16/pnglibconf.h # libpng17/png.h, libpng17/pngconf.h, and libpng17/pnglibconf.h
# Prefix must be a full pathname. # Prefix must be a full pathname.
prefix=/usr/local prefix=/usr/local
exec_prefix=$(prefix) exec_prefix=$(prefix)
@@ -57,7 +57,7 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
CFLAGS=-W -Wall -D_REENTRANT -O2 \ CFLAGS=-W -Wall -D_REENTRANT -O2 \
$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 $(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5
LDFLAGS=-L. -lpng16 LDFLAGS=-L. -lpng17
LDFLAGS_A=libpng.a -lz -lm LDFLAGS_A=libpng.a -lz -lm
LIBADDFLAGS=-lz -lm LIBADDFLAGS=-lz -lm
@@ -108,11 +108,11 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \ -e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \ -e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \ -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 libpng.syms: png.h pngconf.h pnglibconf.h
$(CC) $(CFLAGS) -E -DPNG_BUILDSYMS -DPNG_INTERNAL png.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)\ { for (i=1;i+2<=NF;++i)\
if ($$(i)=="PNG_FUNCTION_EXPORT" && $$(i+2)=="END")\ if ($$(i)=="PNG_FUNCTION_EXPORT" && $$(i+2)=="END")\
print $$(i+1) ";";\ print $$(i+1) ";";\
@@ -129,8 +129,8 @@ libpng-config:
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo L_opts=\"\"; \ echo L_opts=\"\"; \
echo R_opts=\"\"; \ echo R_opts=\"\"; \
echo libs=\"-lpng16\"; \ echo libs=\"-lpng17\"; \
echo all_libs=\"-lpng16 $(LIBADDFLAGS)\"; \ echo all_libs=\"-lpng17 $(LIBADDFLAGS)\"; \
cat scripts/libpng-config-body.in ) > libpng-config cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config chmod +x libpng-config

View File

@@ -6,7 +6,7 @@
# and license in png.h # and license in png.h
PREFIX?= /usr/local PREFIX?= /usr/local
SHLIB_VER?= 16 SHLIB_VER?= 17
LIB= png LIB= png
SHLIB_MAJOR= ${SHLIB_VER} SHLIB_MAJOR= ${SHLIB_VER}

View File

@@ -19,8 +19,8 @@ ZLIBINC=/opt/zlib/include
# SHAREDLIB=libz.sl # SHAREDLIB=libz.sl
# Library name: # Library name:
LIBNAME = libpng16 LIBNAME = libpng17
PNGMAJ = 16 PNGMAJ = 17
# Shared library names: # Shared library names:
LIBSO=$(LIBNAME).sl LIBSO=$(LIBNAME).sl
@@ -44,7 +44,7 @@ CCFLAGS=-I$(ZLIBINC) -O -Ae -Wl,+vnocompatwarnings +DD64 \
LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -lm 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 prefix=/opt/libpng
exec_prefix=$(prefix) exec_prefix=$(prefix)
INCPATH=$(prefix)/include INCPATH=$(prefix)/include
@@ -93,7 +93,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \ -e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \ -e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \ -e s!@includedir@!$(INCPATH)! \
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc -e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
libpng-config: libpng-config:
( cat scripts/libpng-config-head.in; \ ( cat scripts/libpng-config-head.in; \
@@ -101,7 +101,7 @@ libpng-config:
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo ccopts=\"-Ae +DA1.1 +DS2.0\"; \ echo ccopts=\"-Ae +DA1.1 +DS2.0\"; \
echo L_opts=\"-L$(LIBPATH)\"; \ echo L_opts=\"-L$(LIBPATH)\"; \
echo libs=\"-lpng16 -lz -lm\"; \ echo libs=\"-lpng17 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config chmod +x libpng-config

View File

@@ -9,8 +9,8 @@
# and license in png.h # and license in png.h
# Library name: # Library name:
LIBNAME = libpng16 LIBNAME = libpng17
PNGMAJ = 16 PNGMAJ = 17
# Shared library names: # Shared library names:
LIBSO=$(LIBNAME).sl 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 \ CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops -DPNG_NO_MMX_CODE \
$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 $(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=-L. -L$(ZLIBLIB) -lpng16 -lz -lm LDFLAGS=-L. -L$(ZLIBLIB) -lpng17 -lz -lm
INCPATH=$(prefix)/include INCPATH=$(prefix)/include
LIBPATH=$(exec_prefix)/lib LIBPATH=$(exec_prefix)/lib
@@ -100,13 +100,13 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \ -e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \ -e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \ -e s!@includedir@!$(INCPATH)! \
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc -e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
libpng-config: libpng-config:
( cat scripts/libpng-config-head.in; \ ( cat scripts/libpng-config-head.in; \
echo prefix=\"$(prefix)\"; \ echo prefix=\"$(prefix)\"; \
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo libs=\"-lpng16 -lz -lm\"; \ echo libs=\"-lpng17 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config chmod +x libpng-config

View File

@@ -19,8 +19,8 @@ ZLIBINC=/opt/zlib/include
# SHAREDLIB=libz.sl # SHAREDLIB=libz.sl
# Library name: # Library name:
LIBNAME = libpng16 LIBNAME = libpng17
PNGMAJ = 16 PNGMAJ = 17
# Shared library names: # Shared library names:
LIBSO=$(LIBNAME).sl LIBSO=$(LIBNAME).sl
@@ -36,7 +36,7 @@ LN_SF=ln -sf
RANLIB=ranlib RANLIB=ranlib
RM_F=/bin/rm -f 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 prefix=/opt/libpng
exec_prefix=$(prefix) exec_prefix=$(prefix)
INCPATH=$(prefix)/include INCPATH=$(prefix)/include
@@ -90,7 +90,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \ -e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \ -e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \ -e s!@includedir@!$(INCPATH)! \
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc -e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
libpng-config: libpng-config:
( cat scripts/libpng-config-head.in; \ ( cat scripts/libpng-config-head.in; \
@@ -98,7 +98,7 @@ libpng-config:
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo ccopts=\"-Ae +DA1.1 +DS2.0\"; \ echo ccopts=\"-Ae +DA1.1 +DS2.0\"; \
echo L_opts=\"-L$(LIBPATH)\"; \ echo L_opts=\"-L$(LIBPATH)\"; \
echo libs=\"-lpng16 -lz -lm\"; \ echo libs=\"-lpng17 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config chmod +x libpng-config

View File

@@ -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 # Copyright (C) 1998, 1999, 2002, 2006, 2008, 2010-2011 Greg Roelofs and
# Glenn Randers-Pehrson # Glenn Randers-Pehrson
# Copyright (C) 1996, 1997 Andreas Dilger # Copyright (C) 1996, 1997 Andreas Dilger
@@ -8,8 +8,8 @@
# and license in png.h # and license in png.h
# Library name: # Library name:
LIBNAME = libpng16 LIBNAME = libpng17
PNGMAJ = 16 PNGMAJ = 17
RELEASE = 0 RELEASE = 0
# Shared library names: # Shared library names:
@@ -26,8 +26,8 @@ LN_SF=ln -sf
RANLIB=ranlib RANLIB=ranlib
RM_F=/bin/rm -f RM_F=/bin/rm -f
# where "make install" puts libpng16.a, libpng16.so*, # where "make install" puts libpng17.a, libpng17.so*,
# libpng16/png.h, libpng16/pngconf.h, and libpng16/pnglibconf.h # libpng17/png.h, libpng17/pngconf.h, and libpng17/pnglibconf.h
# Prefix must be a full pathname. # Prefix must be a full pathname.
prefix=/usr/local prefix=/usr/local
exec_prefix=$(prefix) exec_prefix=$(prefix)
@@ -51,7 +51,7 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops \ CFLAGS=-I$(ZLIBINC) -W -Wall -O3 -funroll-loops \
$(ALIGN) # $(WARNMORE) -g -DPNG_DEBUG=5 $(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 LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm
INCPATH=$(prefix)/include INCPATH=$(prefix)/include
@@ -100,7 +100,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \ -e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \ -e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \ -e s!@includedir@!$(INCPATH)! \
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc -e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
libpng-config: libpng-config:
( cat scripts/libpng-config-head.in; \ ( cat scripts/libpng-config-head.in; \
@@ -108,7 +108,7 @@ libpng-config:
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo L_opts=\"-L$(LIBPATH)\"; \ echo L_opts=\"-L$(LIBPATH)\"; \
echo R_opts=\"-Wl,-rpath,$(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 cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config chmod +x libpng-config

View File

@@ -13,11 +13,11 @@
LOCALBASE?=/usr/local LOCALBASE?=/usr/local
LIBDIR= ${LOCALBASE}/lib LIBDIR= ${LOCALBASE}/lib
MANDIR= ${LOCALBASE}/man MANDIR= ${LOCALBASE}/man
INCSDIR=${LOCALBASE}/include/libpng16 INCSDIR=${LOCALBASE}/include/libpng17
LIB= png16 LIB= png17
SHLIB_MAJOR= 0 SHLIB_MAJOR= 0
SHLIB_MINOR= 1.6.0beta33 SHLIB_MINOR= 1.7.0alpha03
SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
pngwtran.c pngmem.c pngerror.c pngpread.c pngwtran.c pngmem.c pngerror.c pngpread.c

View File

@@ -8,7 +8,7 @@
# For conditions of distribution and use, see the disclaimer # For conditions of distribution and use, see the disclaimer
# and license in png.h # and license in png.h
# You should also run makefile.ne16bsd # You should also run makefile.ne17bsd
LOCALBASE?=/usr/local LOCALBASE?=/usr/local
LIBDIR= ${LOCALBASE}/lib LIBDIR= ${LOCALBASE}/lib
@@ -16,8 +16,8 @@ MANDIR= ${LOCALBASE}/man
INCSDIR=${LOCALBASE}/include INCSDIR=${LOCALBASE}/include
LIB= png LIB= png
SHLIB_MAJOR= 16 SHLIB_MAJOR= 17
SHLIB_MINOR= 1.6.0beta33 SHLIB_MINOR= 1.7.0alpha03
SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \ SRCS= png.c pngset.c pngget.c pngrutil.c pngtrans.c pngwutil.c \
pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \ pngread.c pngrio.c pngwio.c pngwrite.c pngrtran.c \
pngwtran.c pngmem.c pngerror.c pngpread.c pngwtran.c pngmem.c pngerror.c pngpread.c

View File

@@ -10,8 +10,8 @@ PREFIX?= /usr/local
LIBDIR= ${PREFIX}/lib LIBDIR= ${PREFIX}/lib
MANDIR= ${PREFIX}/man/cat MANDIR= ${PREFIX}/man/cat
SHLIB_MAJOR= 16 SHLIB_MAJOR= 17
SHLIB_MINOR= 1.6.0beta33 SHLIB_MINOR= 1.7.0alpha03
LIB= png LIB= png
SRCS= png.c pngerror.c pngget.c pngmem.c pngpread.c \ SRCS= png.c pngerror.c pngget.c pngmem.c pngpread.c \

View File

@@ -10,8 +10,8 @@
# and license in png.h # and license in png.h
# Library name: # Library name:
LIBNAME = libpng16 LIBNAME = libpng17
PNGMAJ = 16 PNGMAJ = 17
# Shared library names: # Shared library names:
LIBSO=$(LIBNAME).so LIBSO=$(LIBNAME).so
@@ -38,7 +38,7 @@ ZLIBLIB=../zlib
ZLIBINC=../zlib ZLIBINC=../zlib
CFLAGS= -dy -belf -I$(ZLIBINC) -O3 CFLAGS= -dy -belf -I$(ZLIBINC) -O3
LDFLAGS=-L. -L$(ZLIBLIB) -lpng16 -lz -lm LDFLAGS=-L. -L$(ZLIBLIB) -lpng17 -lz -lm
INCPATH=$(prefix)/include INCPATH=$(prefix)/include
LIBPATH=$(exec_prefix)/lib LIBPATH=$(exec_prefix)/lib
@@ -86,7 +86,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \ -e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \ -e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \ -e s!@includedir@!$(INCPATH)! \
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc -e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
libpng-config: libpng-config:
( cat scripts/libpng-config-head.in; \ ( cat scripts/libpng-config-head.in; \
@@ -94,7 +94,7 @@ libpng-config:
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo ccopts=\"-belf\"; \ echo ccopts=\"-belf\"; \
echo L_opts=\"-L$(LIBPATH)\"; \ echo L_opts=\"-L$(LIBPATH)\"; \
echo libs=\"-lpng16 -lz -lm\"; \ echo libs=\"-lpng17 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config chmod +x libpng-config

View File

@@ -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) 2001-2002, 2006, 2010-2011 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# #
@@ -7,8 +7,8 @@
# and license in png.h # and license in png.h
# Library name: # Library name:
LIBNAME=libpng16 LIBNAME=libpng17
PNGMAJ = 16 PNGMAJ = 17
# Shared library names: # Shared library names:
LIBSO=$(LIBNAME).so LIBSO=$(LIBNAME).so
@@ -24,7 +24,7 @@ LN_SF=ln -sf
RANLIB=echo RANLIB=echo
RM_F=/bin/rm -f 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 must be a full pathname.
prefix=/usr/local prefix=/usr/local
@@ -91,7 +91,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \ -e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \ -e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \ -e s!@includedir@!$(INCPATH)! \
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc -e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
libpng-config: libpng-config:
( cat scripts/libpng-config-head.in; \ ( cat scripts/libpng-config-head.in; \
@@ -102,7 +102,7 @@ libpng-config:
echo ldopts=\"$(ABI)\"; \ echo ldopts=\"$(ABI)\"; \
echo L_opts=\"-L$(LIBPATH)\"; \ echo L_opts=\"-L$(LIBPATH)\"; \
echo libdir=\"$(LIBPATH)\"; \ echo libdir=\"$(LIBPATH)\"; \
echo libs=\"-lpng16 -lz -lm\"; \ echo libs=\"-lpng17 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config chmod +x libpng-config

View File

@@ -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) 2001-2002, 2006, 2007, 2010-2011 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc. # Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
# #
@@ -7,8 +7,8 @@
# and license in png.h # and license in png.h
# Library name: # Library name:
LIBNAME=libpng16 LIBNAME=libpng17
PNGMAJ = 16 PNGMAJ = 17
# Shared library names: # Shared library names:
LIBSO=$(LIBNAME).so LIBSO=$(LIBNAME).so
@@ -24,7 +24,7 @@ LN_SF=ln -sf
RANLIB=echo RANLIB=echo
RM_F=/bin/rm -f 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 must be a full pathname.
prefix=/usr/local prefix=/usr/local
@@ -46,7 +46,7 @@ WARNMORE=-fullwarn
# Note: -KPIC is the default anyhow # Note: -KPIC is the default anyhow
#CFLAGS= $(ABI) -I$(ZLIBINC) -O $(WARNMORE) -KPIC # -g -DPNG_DEBUG=5 #CFLAGS= $(ABI) -I$(ZLIBINC) -O $(WARNMORE) -KPIC # -g -DPNG_DEBUG=5
CFLAGS=$(ABI) -I$(ZLIBINC) -O $(WARNMORE) 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 LDFLAGS=$(ABI) -L. -L$(ZLIBLIB) -lpng -lz -lm
LDSHARED=cc $(ABI) -shared -soname $(LIBSOMAJ) \ LDSHARED=cc $(ABI) -shared -soname $(LIBSOMAJ) \
-set_version sgi$(PNGMAJ).0 -set_version sgi$(PNGMAJ).0
@@ -92,7 +92,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \ -e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \ -e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \ -e s!@includedir@!$(INCPATH)! \
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc -e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
libpng-config: libpng-config:
( cat scripts/libpng-config-head.in; \ ( cat scripts/libpng-config-head.in; \
@@ -102,7 +102,7 @@ libpng-config:
echo ldopts=\"$(ABI)\"; \ echo ldopts=\"$(ABI)\"; \
echo L_opts=\"-L$(LIBPATH)\"; \ echo L_opts=\"-L$(LIBPATH)\"; \
echo libdir=\"$(LIBPATH)\"; \ echo libdir=\"$(LIBPATH)\"; \
echo libs=\"-lpng16 -lz -lm\"; \ echo libs=\"-lpng17 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config chmod +x libpng-config

View File

@@ -10,8 +10,8 @@
# and license in png.h # and license in png.h
# Library name: # Library name:
PNGMAJ = 16 PNGMAJ = 17
LIBNAME = libpng16 LIBNAME = libpng17
# Shared library names: # Shared library names:
LIBSO=$(LIBNAME).so LIBSO=$(LIBNAME).so
@@ -48,7 +48,7 @@ ZLIBINC=/usr/include
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
#CFLAGS=-I$(ZLIBINC) -W -Wall -O3 $(WARNMORE) -g -DPNG_DEBUG=5 -DPNG_NO_MMX_CODE #CFLAGS=-I$(ZLIBINC) -W -Wall -O3 $(WARNMORE) -g -DPNG_DEBUG=5 -DPNG_NO_MMX_CODE
CFLAGS=-I$(ZLIBINC) -O3 -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 INCPATH=$(prefix)/include
LIBPATH=$(exec_prefix)/lib LIBPATH=$(exec_prefix)/lib
@@ -96,7 +96,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \ -e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \ -e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \ -e s!@includedir@!$(INCPATH)! \
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc -e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
libpng-config: libpng-config:
( cat scripts/libpng-config-head.in; \ ( cat scripts/libpng-config-head.in; \
@@ -104,7 +104,7 @@ libpng-config:
echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \ echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
echo L_opts=\"-L$(LIBPATH)\"; \ echo L_opts=\"-L$(LIBPATH)\"; \
echo R_opts=\"-R$(LIBPATH)\"; \ echo R_opts=\"-R$(LIBPATH)\"; \
echo libs=\"-lpng16 -lz -lm\"; \ echo libs=\"-lpng17 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config chmod +x libpng-config

View File

@@ -9,8 +9,8 @@
# and license in png.h # and license in png.h
# Library name: # Library name:
LIBNAME = libpng16 LIBNAME = libpng17
PNGMAJ = 16 PNGMAJ = 17
# Shared library names: # Shared library names:
LIBSO=$(LIBNAME).so LIBSO=$(LIBNAME).so
@@ -26,7 +26,7 @@ LN_SF=ln -f -s
RANLIB=echo RANLIB=echo
RM_F=/bin/rm -f RM_F=/bin/rm -f
# 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 prefix=/usr/local
exec_prefix=$(prefix) exec_prefix=$(prefix)
@@ -44,7 +44,7 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
CFLAGS=-I$(ZLIBINC) -W -Wall -O \ CFLAGS=-I$(ZLIBINC) -W -Wall -O \
# $(WARNMORE) -g -DPNG_DEBUG=5 # $(WARNMORE) -g -DPNG_DEBUG=5
LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng16 -lz -lm LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng17 -lz -lm
INCPATH=$(prefix)/include INCPATH=$(prefix)/include
LIBPATH=$(exec_prefix)/lib LIBPATH=$(exec_prefix)/lib
@@ -92,7 +92,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \ -e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \ -e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \ -e s!@includedir@!$(INCPATH)! \
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc -e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
libpng-config: libpng-config:
( cat scripts/libpng-config-head.in; \ ( cat scripts/libpng-config-head.in; \
@@ -101,7 +101,7 @@ libpng-config:
echo cppflags=\"\"; \ echo cppflags=\"\"; \
echo L_opts=\"-L$(LIBPATH)\"; \ echo L_opts=\"-L$(LIBPATH)\"; \
echo R_opts=\"-R$(LIBPATH)\"; \ echo R_opts=\"-R$(LIBPATH)\"; \
echo libs=\"-lpng16 -lz -lm\"; \ echo libs=\"-lpng17 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config chmod +x libpng-config

View File

@@ -9,8 +9,8 @@
# and license in png.h # and license in png.h
# Library name: # Library name:
LIBNAME = libpng16 LIBNAME = libpng17
PNGMAJ = 16 PNGMAJ = 17
# Shared library names: # Shared library names:
LIBSO=$(LIBNAME).so LIBSO=$(LIBNAME).so
@@ -26,7 +26,7 @@ LN_SF=ln -f -s
RANLIB=echo RANLIB=echo
RM_F=/bin/rm -f RM_F=/bin/rm -f
# 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 prefix=/usr/local
exec_prefix=$(prefix) exec_prefix=$(prefix)
@@ -44,7 +44,7 @@ WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wstrict-prototypes -Wmissing-prototypes #-Wconversion -Wstrict-prototypes -Wmissing-prototypes #-Wconversion
CFLAGS=-I$(ZLIBINC) -W -Wall -O \ CFLAGS=-I$(ZLIBINC) -W -Wall -O \
# $(WARNMORE) -g -DPNG_DEBUG=5 # $(WARNMORE) -g -DPNG_DEBUG=5
LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng16 -lz -lm LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng17 -lz -lm
INCPATH=$(prefix)/include INCPATH=$(prefix)/include
LIBPATH=$(exec_prefix)/lib LIBPATH=$(exec_prefix)/lib
@@ -92,7 +92,7 @@ libpng.pc:
-e s!@exec_prefix@!$(exec_prefix)! \ -e s!@exec_prefix@!$(exec_prefix)! \
-e s!@libdir@!$(LIBPATH)! \ -e s!@libdir@!$(LIBPATH)! \
-e s!@includedir@!$(INCPATH)! \ -e s!@includedir@!$(INCPATH)! \
-e s!-lpng16!-lpng16\ -lz\ -lm! > libpng.pc -e s!-lpng17!-lpng17\ -lz\ -lm! > libpng.pc
libpng-config: libpng-config:
( cat scripts/libpng-config-head.in; \ ( cat scripts/libpng-config-head.in; \
@@ -101,7 +101,7 @@ libpng-config:
echo cppflags=\""; \ echo cppflags=\""; \
echo L_opts=\"-L$(LIBPATH)\"; \ echo L_opts=\"-L$(LIBPATH)\"; \
echo R_opts=\"-R$(LIBPATH)\"; \ echo R_opts=\"-R$(LIBPATH)\"; \
echo libs=\"-lpng16 -lz -lm\"; \ echo libs=\"-lpng17 -lz -lm\"; \
cat scripts/libpng-config-body.in ) > libpng-config cat scripts/libpng-config-body.in ) > libpng-config
chmod +x libpng-config chmod +x libpng-config

View File

@@ -102,6 +102,7 @@ pre && version == "search" && version_file != FILENAME{
pre && version == "search" && $0 ~ /^ \* libpng version/{ pre && version == "search" && $0 ~ /^ \* libpng version/{
version = substr($0, 4) version = substr($0, 4)
gsub(/\./, " PNG_JOIN . PNG_JOIN", version)
print "version =", version >out print "version =", version >out
next next
} }

View File

@@ -8,7 +8,7 @@ com pnglibconf.h - library build configuration
com com
version version
com com
com Copyright (c) 1998-2011 Glenn Randers-Pehrson com Copyright (c) 1998-2012 Glenn Randers-Pehrson
com com
com This code is released under the libpng license. com This code is released under the libpng license.
com For conditions of distribution and use, see the disclaimer com For conditions of distribution and use, see the disclaimer
@@ -109,6 +109,13 @@ file pnglibconf.h scripts/pnglibconf.dfa PNGLCONF_H
logunsupported = 1 logunsupported = 1
# The following allows the output from configure to modify the contents of
# pnglibconf.h
@#ifdef HAVE_CONFIG_H
@# include "config.h"
@#endif
# PNG_USER_CONFIG has to be defined on the compiler command line # PNG_USER_CONFIG has to be defined on the compiler command line
# to cause pngusr.h to be read while constructing pnglibconf.h # to cause pngusr.h to be read while constructing pnglibconf.h
# #
@@ -178,6 +185,32 @@ setting API_RULE default 0
setting PREFIX setting PREFIX
# This says that a prefix has been added to zlib API function names; at present
# it is informational, the builder of zlib must ensure that zlib.h contains the
# appropriate renames
setting ZLIB_PREFIX
# This is used to select an alternative zlib header file - it must look pretty
# much like the standard zlib.h, but this makes it easier to ensure the correct
# header file is used. Set it to the "" or <> quoted file name (a full file
# name is acceptable). Prior to 1.7.0 this used "zlib.h", so it would use a
# zlib.h in the same directory as the libpng source, from 1.7.0 it defaults to
# just searching the -I directories. Prior to 1.6.0 the #include appeared in
# the exported header files - so it was quite important to use "zlib.h" to
# ensure that applications always got the zlib.h from the same directory as
# png.h.
setting ZLIB_HEADER default <zlib.h>
# Define this to something that will stop, at least, the current thread; control
# cannot proceed beyond the PNG_ABORT operation and compilation of pngerror.c is
# likely to fail if the operation implemented does not clearly terminate the
# thread or process. The default implementation is the ANSI-C abort function,
# but any manner of C code may be used.
setting ABORT default { (abort()); }
# Default to using the read macros # Default to using the read macros
setting DEFAULT_READ_MACROS default 1 setting DEFAULT_READ_MACROS default 1
@@ -276,40 +309,28 @@ option USER_MEM
option IO_STATE option IO_STATE
# This is only for PowerPC big-endian and 680x0 systems # Libpng limits: limit the size of images and data on read.
# some testing, not enabled by default.
# NO LONGER USED
#option READ_BIG_ENDIAN disabled
# Allow users to control limits on what the READ code will
# read:
# Added at libpng-1.2.43; adds limit fields to png_struct,
# allows some usages of these fields
option USER_LIMITS
# Added at libpng-1.2.6; adds setting APIs, allows additional
# usage of this field (UTSL)
option SET_USER_LIMITS requires USER_LIMITS
# Feature added at libpng-1.4.0, this flag added at 1.4.1
option SET_USER_LIMITS enables SET_CHUNK_CACHE_LIMIT
# Feature added at libpng-1.4.1, this flag added at 1.4.1
option SET_USER_LIMITS enables SET_CHUNK_MALLOC_LIMIT
# Libpng limits.
# #
# If these settings are *not* set libpng will not limit the size of # If this option is disabled all the limit checking code will be disabled:
option USER_LIMITS requires READ
# If the following settings are *not* set libpng will not limit the size of
# images or the size of data in ancilliary chunks. This does lead to # images or the size of data in ancilliary chunks. This does lead to
# security issues if PNG files come from untrusted sources. # security issues if PNG files come from untrusted sources. Settings have the
# following interpretations:
#
# USER_WIDTH_MAX: maximum width of an image that will be read
# USER_HEIGHT_MAX: maximum height
# USER_CHUNK_MALLOC_MAX: maximum in-memory (decompressed) size of a single chunk
# USER_CHUNK_CACHE_MAX: maximum number of chunks to be cached
#
# Only chunks that are variable in number are counted towards the
# USER_CHUNK_CACHE_MAX limit
setting USER_WIDTH_MAX setting USER_WIDTH_MAX
setting USER_HEIGHT_MAX setting USER_HEIGHT_MAX
setting USER_CHUNK_CACHE_MAX
setting USER_CHUNK_MALLOC_MAX setting USER_CHUNK_MALLOC_MAX
setting USER_CHUNK_CACHE_MAX
# To default all these settings to values that are large but probably # To default all these settings to values that are large but probably
# safe turn the SAFE_LIMITS option on; this will cause the value in # safe turn the SAFE_LIMITS option on; this will cause the value in
@@ -318,6 +339,10 @@ setting USER_CHUNK_MALLOC_MAX
option SAFE_LIMITS enables USER_LIMITS disabled option SAFE_LIMITS enables USER_LIMITS disabled
= SAFE_LIMITS SAFE_LIMITS = SAFE_LIMITS SAFE_LIMITS
# If this option is enabled APIs to set the above limits at run time are added;
# without these the hardwired (compile time) limits will be used.
option SET_USER_LIMITS requires USER_LIMITS
# All of the following options relate to code capabilities for # All of the following options relate to code capabilities for
# processing image data before creating a PNG or after reading one. # processing image data before creating a PNG or after reading one.
# You can remove these capabilities safely and still be PNG # You can remove these capabilities safely and still be PNG

View File

@@ -1,9 +1,6 @@
/* libpng STANDARD API DEFINITION */
/* pnglibconf.h - library build configuration */ /* pnglibconf.h - library build configuration */
/* Libpng 1.6.0beta33 - December 10, 2012 */ /* libpng version 1.7.0alpha03 - December 19, 2012 */
/* Copyright (c) 1998-2012 Glenn Randers-Pehrson */ /* Copyright (c) 1998-2012 Glenn Randers-Pehrson */
@@ -12,193 +9,189 @@
/* and license in png.h */ /* and license in png.h */
/* pnglibconf.h */ /* pnglibconf.h */
/* Machine generated file: DO NOT EDIT */
/* Derived from: scripts/pnglibconf.dfa */ /* Derived from: scripts/pnglibconf.dfa */
/* If you edit this file by hand you must obey the rules expressed in */
/* pnglibconf.dfa with respect to the dependencies between the following */
/* symbols. It is much better to generate a new file using */
/* scripts/libpngconf.mak */
#ifndef PNGLCONF_H #ifndef PNGLCONF_H
#define PNGLCONF_H #define PNGLCONF_H
/* settings */ /* settings */
#define PNG_API_RULE 0
#define PNG_CALLOC_SUPPORTED
#define PNG_COST_SHIFT 3
#define PNG_DEFAULT_READ_MACROS 1
#define PNG_GAMMA_THRESHOLD_FIXED 5000
#define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE
#define PNG_INFLATE_BUF_SIZE 1024
#define PNG_MAX_GAMMA_8 11 #define PNG_MAX_GAMMA_8 11
#define PNG_QUANTIZE_BLUE_BITS 5 #define PNG_CALLOC_SUPPORTED
#define PNG_QUANTIZE_GREEN_BITS 5
#define PNG_QUANTIZE_RED_BITS 5 #define PNG_QUANTIZE_RED_BITS 5
#define PNG_INFLATE_BUF_SIZE 1024
#define PNG_QUANTIZE_GREEN_BITS 5
#define PNG_API_RULE 0
#define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE
#define PNG_QUANTIZE_BLUE_BITS 5
#define PNG_ABORT { (abort()); }
#define PNG_sCAL_PRECISION 5 #define PNG_sCAL_PRECISION 5
#define PNG_sRGB_PROFILE_CHECKS 2 #define PNG_COST_SHIFT 3
#define PNG_WEIGHT_SHIFT 8 #define PNG_WEIGHT_SHIFT 8
#define PNG_ZLIB_HEADER <zlib.h>
#define PNG_DEFAULT_READ_MACROS 1
#define PNG_ZBUF_SIZE 8192 #define PNG_ZBUF_SIZE 8192
#define PNG_GAMMA_THRESHOLD_FIXED 5000
#define PNG_sRGB_PROFILE_CHECKS 2
/* end of settings */ /* end of settings */
/* options */ /* options */
#define PNG_16BIT_SUPPORTED #define PNG_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_ALIGN_MEMORY_SUPPORTED #define PNG_INFO_IMAGE_SUPPORTED
#define PNG_BENIGN_ERRORS_SUPPORTED #define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_BENIGN_READ_ERRORS_SUPPORTED #define PNG_POINTER_INDEXING_SUPPORTED
/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/ #define PNG_WARNINGS_SUPPORTED
#define PNG_bKGD_SUPPORTED #define PNG_FLOATING_ARITHMETIC_SUPPORTED
#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED #define PNG_WRITE_SUPPORTED
#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED #define PNG_WRITE_INTERLACING_SUPPORTED
#define PNG_cHRM_SUPPORTED #define PNG_WRITE_16BIT_SUPPORTED
#define PNG_COLORSPACE_SUPPORTED
#define PNG_CONSOLE_IO_SUPPORTED
#define PNG_CONVERT_tIME_SUPPORTED
#define PNG_EASY_ACCESS_SUPPORTED #define PNG_EASY_ACCESS_SUPPORTED
#define PNG_ALIGN_MEMORY_SUPPORTED
#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
#define PNG_FIXED_POINT_SUPPORTED
/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/ /*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
#define PNG_ERROR_TEXT_SUPPORTED #define PNG_ERROR_TEXT_SUPPORTED
#define PNG_FIXED_POINT_SUPPORTED
#define PNG_FLOATING_ARITHMETIC_SUPPORTED
#define PNG_FLOATING_POINT_SUPPORTED
#define PNG_FORMAT_AFIRST_SUPPORTED
#define PNG_FORMAT_BGR_SUPPORTED
#define PNG_gAMA_SUPPORTED
#define PNG_GAMMA_SUPPORTED
#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
#define PNG_hIST_SUPPORTED
#define PNG_iCCP_SUPPORTED
#define PNG_INCH_CONVERSIONS_SUPPORTED
#define PNG_INFO_IMAGE_SUPPORTED
#define PNG_IO_STATE_SUPPORTED
#define PNG_iTXt_SUPPORTED
#define PNG_MNG_FEATURES_SUPPORTED
#define PNG_oFFs_SUPPORTED
#define PNG_pCAL_SUPPORTED
#define PNG_pHYs_SUPPORTED
#define PNG_POINTER_INDEXING_SUPPORTED
#define PNG_PROGRESSIVE_READ_SUPPORTED
#define PNG_READ_16BIT_SUPPORTED
#define PNG_READ_ALPHA_MODE_SUPPORTED
#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
#define PNG_READ_BACKGROUND_SUPPORTED
#define PNG_READ_BGR_SUPPORTED
#define PNG_READ_bKGD_SUPPORTED
#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
#define PNG_READ_cHRM_SUPPORTED
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED
#define PNG_READ_COMPRESSED_TEXT_SUPPORTED
#define PNG_READ_EXPAND_16_SUPPORTED
#define PNG_READ_EXPAND_SUPPORTED
#define PNG_READ_FILLER_SUPPORTED
#define PNG_READ_gAMA_SUPPORTED
#define PNG_READ_GAMMA_SUPPORTED
#define PNG_READ_GRAY_TO_RGB_SUPPORTED
#define PNG_READ_hIST_SUPPORTED
#define PNG_READ_iCCP_SUPPORTED
#define PNG_READ_INTERLACING_SUPPORTED
#define PNG_READ_INT_FUNCTIONS_SUPPORTED
#define PNG_READ_INVERT_ALPHA_SUPPORTED
#define PNG_READ_INVERT_SUPPORTED
#define PNG_READ_iTXt_SUPPORTED
#define PNG_READ_oFFs_SUPPORTED
#define PNG_READ_OPT_PLTE_SUPPORTED
#define PNG_READ_PACK_SUPPORTED
#define PNG_READ_PACKSWAP_SUPPORTED
#define PNG_READ_pCAL_SUPPORTED
#define PNG_READ_pHYs_SUPPORTED
#define PNG_READ_QUANTIZE_SUPPORTED
#define PNG_READ_RGB_TO_GRAY_SUPPORTED
#define PNG_READ_sBIT_SUPPORTED
#define PNG_READ_SCALE_16_TO_8_SUPPORTED
#define PNG_READ_sCAL_SUPPORTED
#define PNG_READ_SHIFT_SUPPORTED
#define PNG_READ_sPLT_SUPPORTED
#define PNG_READ_sRGB_SUPPORTED
#define PNG_READ_STRIP_16_TO_8_SUPPORTED
#define PNG_READ_STRIP_ALPHA_SUPPORTED
#define PNG_READ_SUPPORTED #define PNG_READ_SUPPORTED
#define PNG_READ_SWAP_ALPHA_SUPPORTED #define PNG_BENIGN_ERRORS_SUPPORTED
#define PNG_READ_SWAP_SUPPORTED
#define PNG_READ_tEXt_SUPPORTED
#define PNG_READ_TEXT_SUPPORTED
#define PNG_READ_tIME_SUPPORTED
#define PNG_READ_TRANSFORMS_SUPPORTED
#define PNG_READ_tRNS_SUPPORTED
#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_READ_USER_CHUNKS_SUPPORTED
#define PNG_READ_USER_TRANSFORM_SUPPORTED
#define PNG_READ_zTXt_SUPPORTED
/*#undef PNG_SAFE_LIMITS_SUPPORTED*/
#define PNG_SAVE_INT_32_SUPPORTED
#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_sBIT_SUPPORTED
#define PNG_sCAL_SUPPORTED
#define PNG_SEQUENTIAL_READ_SUPPORTED
#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED
#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
#define PNG_SETJMP_SUPPORTED #define PNG_SETJMP_SUPPORTED
#define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_SET_USER_LIMITS_SUPPORTED
#define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED
#define PNG_SIMPLIFIED_READ_BGR_SUPPORTED
#define PNG_SIMPLIFIED_READ_SUPPORTED
#define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
#define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED
#define PNG_SIMPLIFIED_WRITE_SUPPORTED
#define PNG_sPLT_SUPPORTED
#define PNG_sRGB_SUPPORTED
#define PNG_STDIO_SUPPORTED
#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_tEXt_SUPPORTED
#define PNG_TEXT_SUPPORTED
#define PNG_TIME_RFC1123_SUPPORTED #define PNG_TIME_RFC1123_SUPPORTED
#define PNG_tIME_SUPPORTED #define PNG_BENIGN_READ_ERRORS_SUPPORTED
#define PNG_tRNS_SUPPORTED
#define PNG_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_USER_CHUNKS_SUPPORTED
#define PNG_USER_LIMITS_SUPPORTED
#define PNG_USER_MEM_SUPPORTED
#define PNG_USER_TRANSFORM_INFO_SUPPORTED
#define PNG_USER_TRANSFORM_PTR_SUPPORTED
#define PNG_WARNINGS_SUPPORTED
#define PNG_WRITE_16BIT_SUPPORTED
#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
#define PNG_WRITE_BGR_SUPPORTED
#define PNG_WRITE_bKGD_SUPPORTED
#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
#define PNG_WRITE_cHRM_SUPPORTED
#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
#define PNG_WRITE_FILLER_SUPPORTED
#define PNG_WRITE_FILTER_SUPPORTED
#define PNG_WRITE_FLUSH_SUPPORTED #define PNG_WRITE_FLUSH_SUPPORTED
#define PNG_WRITE_gAMA_SUPPORTED #define PNG_MNG_FEATURES_SUPPORTED
#define PNG_WRITE_hIST_SUPPORTED /*#undef PNG_SAFE_LIMITS_SUPPORTED*/
#define PNG_WRITE_iCCP_SUPPORTED #define PNG_FLOATING_POINT_SUPPORTED
#define PNG_WRITE_INTERLACING_SUPPORTED
#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED
#define PNG_WRITE_INVERT_ALPHA_SUPPORTED
#define PNG_WRITE_INVERT_SUPPORTED
#define PNG_WRITE_iTXt_SUPPORTED
#define PNG_WRITE_oFFs_SUPPORTED
#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED #define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
#define PNG_WRITE_PACK_SUPPORTED #define PNG_INCH_CONVERSIONS_SUPPORTED
#define PNG_WRITE_PACKSWAP_SUPPORTED #define PNG_STDIO_SUPPORTED
#define PNG_WRITE_pCAL_SUPPORTED #define PNG_USER_MEM_SUPPORTED
#define PNG_WRITE_pHYs_SUPPORTED #define PNG_IO_STATE_SUPPORTED
#define PNG_WRITE_sBIT_SUPPORTED #define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED
#define PNG_WRITE_sCAL_SUPPORTED #define PNG_WRITE_INT_FUNCTIONS_SUPPORTED
#define PNG_WRITE_SHIFT_SUPPORTED #define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED
#define PNG_WRITE_sPLT_SUPPORTED #define PNG_WRITE_FILTER_SUPPORTED
#define PNG_WRITE_sRGB_SUPPORTED
#define PNG_WRITE_SUPPORTED
#define PNG_WRITE_SWAP_ALPHA_SUPPORTED
#define PNG_WRITE_SWAP_SUPPORTED
#define PNG_WRITE_tEXt_SUPPORTED
#define PNG_WRITE_TEXT_SUPPORTED
#define PNG_WRITE_tIME_SUPPORTED
#define PNG_WRITE_TRANSFORMS_SUPPORTED
#define PNG_WRITE_tRNS_SUPPORTED
#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_WRITE_USER_TRANSFORM_SUPPORTED
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
#define PNG_WRITE_zTXt_SUPPORTED #define PNG_WRITE_zTXt_SUPPORTED
#define PNG_WRITE_iCCP_SUPPORTED
#define PNG_READ_TRANSFORMS_SUPPORTED
#define PNG_READ_bKGD_SUPPORTED
#define PNG_READ_sCAL_SUPPORTED
#define PNG_WRITE_hIST_SUPPORTED
#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
#define PNG_READ_OPT_PLTE_SUPPORTED
#define PNG_SIMPLIFIED_WRITE_SUPPORTED
#define PNG_READ_GRAY_TO_RGB_SUPPORTED
#define PNG_WRITE_pCAL_SUPPORTED
#define PNG_READ_INVERT_ALPHA_SUPPORTED
#define PNG_WRITE_TRANSFORMS_SUPPORTED
#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
#define PNG_READ_sBIT_SUPPORTED
#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
#define PNG_READ_PACK_SUPPORTED
#define PNG_WRITE_iTXt_SUPPORTED
#define PNG_WRITE_SWAP_SUPPORTED
#define PNG_READ_cHRM_SUPPORTED
#define PNG_READ_STRIP_16_TO_8_SUPPORTED
#define PNG_WRITE_tIME_SUPPORTED
#define PNG_READ_INTERLACING_SUPPORTED
#define PNG_READ_tRNS_SUPPORTED
#define PNG_WRITE_pHYs_SUPPORTED
#define PNG_WRITE_INVERT_SUPPORTED
#define PNG_WRITE_sRGB_SUPPORTED
#define PNG_READ_oFFs_SUPPORTED
#define PNG_WRITE_FILLER_SUPPORTED
#define PNG_WRITE_SHIFT_SUPPORTED
#define PNG_PROGRESSIVE_READ_SUPPORTED
#define PNG_READ_SHIFT_SUPPORTED
#define PNG_CONVERT_tIME_SUPPORTED
#define PNG_READ_USER_TRANSFORM_SUPPORTED
#define PNG_READ_INT_FUNCTIONS_SUPPORTED
#define PNG_READ_USER_CHUNKS_SUPPORTED
#define PNG_READ_hIST_SUPPORTED
#define PNG_READ_SWAP_ALPHA_SUPPORTED
#define PNG_READ_COMPOSITE_NODIV_SUPPORTED
#define PNG_SEQUENTIAL_READ_SUPPORTED
#define PNG_READ_QUANTIZE_SUPPORTED
#define PNG_READ_zTXt_SUPPORTED
#define PNG_USER_LIMITS_SUPPORTED
#define PNG_READ_iCCP_SUPPORTED
#define PNG_READ_PACKSWAP_SUPPORTED
#define PNG_READ_sRGB_SUPPORTED
#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
#define PNG_READ_gAMA_SUPPORTED
#define PNG_READ_pCAL_SUPPORTED
#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_WRITE_sPLT_SUPPORTED
#define PNG_READ_iTXt_SUPPORTED
/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/
#define PNG_READ_tIME_SUPPORTED
#define PNG_READ_pHYs_SUPPORTED
#define PNG_WRITE_SWAP_ALPHA_SUPPORTED
#define PNG_WRITE_BGR_SUPPORTED
#define PNG_USER_CHUNKS_SUPPORTED
#define PNG_CONSOLE_IO_SUPPORTED
#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_WRITE_PACK_SUPPORTED
#define PNG_WRITE_bKGD_SUPPORTED
#define PNG_WRITE_tRNS_SUPPORTED
#define PNG_READ_sPLT_SUPPORTED
#define PNG_WRITE_sCAL_SUPPORTED
#define PNG_WRITE_oFFs_SUPPORTED
#define PNG_SET_USER_LIMITS_SUPPORTED
#define PNG_WRITE_sBIT_SUPPORTED
#define PNG_READ_INVERT_SUPPORTED
#define PNG_WRITE_cHRM_SUPPORTED
#define PNG_WRITE_USER_TRANSFORM_SUPPORTED
#define PNG_READ_BGR_SUPPORTED
#define PNG_WRITE_PACKSWAP_SUPPORTED
#define PNG_WRITE_INVERT_ALPHA_SUPPORTED
#define PNG_sCAL_SUPPORTED
#define PNG_READ_GAMMA_SUPPORTED
#define PNG_USER_TRANSFORM_INFO_SUPPORTED
#define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED
#define PNG_sBIT_SUPPORTED
#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
#define PNG_WRITE_gAMA_SUPPORTED
#define PNG_cHRM_SUPPORTED
#define PNG_bKGD_SUPPORTED
#define PNG_tRNS_SUPPORTED
#define PNG_oFFs_SUPPORTED
#define PNG_USER_TRANSFORM_PTR_SUPPORTED
#define PNG_WRITE_TEXT_SUPPORTED
#define PNG_READ_COMPRESSED_TEXT_SUPPORTED
#define PNG_hIST_SUPPORTED
#define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
#define PNG_zTXt_SUPPORTED #define PNG_zTXt_SUPPORTED
#define PNG_iCCP_SUPPORTED
#define PNG_sRGB_SUPPORTED
#define PNG_gAMA_SUPPORTED
#define PNG_pCAL_SUPPORTED
#define PNG_WRITE_tEXt_SUPPORTED
#define PNG_iTXt_SUPPORTED
#define PNG_tIME_SUPPORTED
#define PNG_pHYs_SUPPORTED
#define PNG_READ_TEXT_SUPPORTED
#define PNG_SAVE_INT_32_SUPPORTED
#define PNG_sPLT_SUPPORTED
#define PNG_COLORSPACE_SUPPORTED
#define PNG_READ_tEXt_SUPPORTED
#define PNG_SIMPLIFIED_READ_SUPPORTED
#define PNG_READ_ALPHA_MODE_SUPPORTED
#define PNG_READ_RGB_TO_GRAY_SUPPORTED
#define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED
#define PNG_READ_16BIT_SUPPORTED
#define PNG_SIMPLIFIED_READ_BGR_SUPPORTED
#define PNG_READ_STRIP_ALPHA_SUPPORTED
#define PNG_READ_EXPAND_SUPPORTED
#define PNG_READ_SWAP_SUPPORTED
#define PNG_TEXT_SUPPORTED
#define PNG_READ_SCALE_16_TO_8_SUPPORTED
#define PNG_GAMMA_SUPPORTED
#define PNG_READ_FILLER_SUPPORTED
#define PNG_tEXt_SUPPORTED
#define PNG_16BIT_SUPPORTED
#define PNG_FORMAT_AFIRST_SUPPORTED
#define PNG_READ_EXPAND_16_SUPPORTED
#define PNG_FORMAT_BGR_SUPPORTED
#define PNG_READ_BACKGROUND_SUPPORTED
/* end of options */ /* end of options */
#endif /* PNGLCONF_H */ #endif /* PNGLCONF_H */

View File

@@ -5,7 +5,7 @@
LIBRARY LIBRARY
EXPORTS EXPORTS
;Version 1.6.0beta33 ;Version 1.7.0alpha03
png_access_version_number @1 png_access_version_number @1
png_set_sig_bytes @2 png_set_sig_bytes @2
png_sig_cmp @3 png_sig_cmp @3
@@ -15,7 +15,6 @@ EXPORTS
png_set_compression_buffer_size @7 png_set_compression_buffer_size @7
png_set_longjmp_fn @8 png_set_longjmp_fn @8
png_longjmp @9 png_longjmp @9
png_reset_zstream @10
png_create_read_struct_2 @11 png_create_read_struct_2 @11
png_create_write_struct_2 @12 png_create_write_struct_2 @12
png_write_sig @13 png_write_sig @13
@@ -24,11 +23,9 @@ EXPORTS
png_write_chunk_data @16 png_write_chunk_data @16
png_write_chunk_end @17 png_write_chunk_end @17
png_create_info_struct @18 png_create_info_struct @18
png_info_init_3 @19
png_write_info_before_PLTE @20 png_write_info_before_PLTE @20
png_write_info @21 png_write_info @21
png_read_info @22 png_read_info @22
png_convert_to_rfc1123 @23
png_convert_from_struct_tm @24 png_convert_from_struct_tm @24
png_convert_from_time_t @25 png_convert_from_time_t @25
png_set_expand @26 png_set_expand @26
@@ -104,9 +101,6 @@ EXPORTS
png_malloc_warn @96 png_malloc_warn @96
png_free @97 png_free @97
png_free_data @98 png_free_data @98
png_data_freer @99
png_malloc_default @100
png_free_default @101
png_error @102 png_error @102
png_chunk_error @103 png_chunk_error @103
png_err @104 png_err @104