[master] Imported from libpng-1.6.8.tar

This commit is contained in:
Glenn Randers-Pehrson 2013-12-19 09:04:52 -06:00
parent 0e60f06b7c
commit 339ef1ec97
56 changed files with 943 additions and 457 deletions

103
ANNOUNCE
View File

@ -1,5 +1,5 @@
Libpng 1.6.7 - November 14, 2013 Libpng 1.6.8 - December 19, 2013
This is a public release of libpng, intended for use in production codes. This is a public release of libpng, intended for use in production codes.
@ -8,81 +8,50 @@ 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
libpng-1.6.7.tar.xz (LZMA-compressed, recommended) libpng-1.6.8.tar.xz (LZMA-compressed, recommended)
libpng-1.6.7.tar.gz libpng-1.6.8.tar.gz
Source files with CRLF line endings (for Windows), without the Source files with CRLF line endings (for Windows), without the
"configure" script "configure" script
lpng167.7z (LZMA-compressed, recommended) lpng168.7z (LZMA-compressed, recommended)
lpng167.zip lpng168.zip
Other information: Other information:
libpng-1.6.7-README.txt libpng-1.6.8-README.txt
libpng-1.6.7-LICENSE.txt libpng-1.6.8-LICENSE.txt
Gnupg/*.asc (PGP armored detached signatures) Gnupg/*.asc (PGP armored detached signatures)
Changes since the last public release (1.6.6): Changes since the last public release (1.6.7):
Changed #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED in pngpread.c to
Revised unknown chunk code to correct several bugs in the NO_SAVE_/NO_WRITE #ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED to be consistent with
combination what is in pngpriv.h.
Allow HANDLE_AS_UNKNOWN to work when other options are configured off. Also Moved prototype for png_handle_unknown() in pngpriv.h outside of
fixed the pngminim makefiles to work when $(MAKEFLAGS) contains stuff the #ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED/#endif block.
which terminates the make options (as by default in recent versions of Added "-Wall" to CFLAGS in contrib/pngminim/*/makefile
Gentoo). Conditionally compile some unused functions reported by -Wall in
Avoid up-cast warnings in pngvalid.c. On ARM the alignment requirements of pngminim.
png_modifier are greater than that of png_store and as a consequence Fixed 'minimal' builds. Various obviously useful minimal configurations
compilation of pngvalid.c results in a warning about increased alignment don't build because of missing contrib/libtests test programs and
requirements because of the bare cast to (png_modifier*). The code is safe, overly complex dependencies in scripts/pnglibconf.dfa. This change
because the pointer is known to point to a stack allocated png_modifier, adds contrib/conftest/*.dfa files that can be used in automatic build
but this change avoids the warning. scripts to ensure that these configurations continue to build.
Fixed default behavior of ARM_NEON_API. If the ARM NEON API option was Enabled WRITE_INVERT and WRITE_PACK in contrib/pngminim/encoder.
compiled without the CHECK option it defaulted to on, not off. Fixed pngvalid 'fail' function declaration on the Intel C Compiler.
Check user callback behavior in pngunknown.c. Previous versions compiled This reverts to the previous 'static' implementation and works round
if SAVE_UNKNOWN was not available but did nothing since the callback the 'unused static function' warning by using PNG_UNUSED().
was never implemented. Removed or marked PNG_UNUSED some harmless "dead assignments" reported
Merged pngunknown.c with 1.7 version and back ported 1.7 improvements/fixes by clang scan-build.
Made changes for compatibility with automake 1.14: Changed tabs to 3 spaces in png_debug macros and changed '"%s"m'
1) Added the 'compile' program to the list of programs that must be cleaned to '"%s" m' to improve portability among compilers.
in autogen.sh Changed png_free_default() to free() in pngtest.c
2) Added 'subdir-objects' which causes .c files in sub-directories to be Tidied up pngfix inits and fixed pngtest no-write builds.
compiled such that the corresponding .o files are also in the Handle zero-length PLTE chunk or NULL palette with png_error()
sub-directory. This is because automake 1.14 warns that the instead of png_chunk_report(), which by default issues a warning
current behavior of compiling to the top level directory may be removed rather than an error, leading to later reading from a NULL pointer
in the future. (png_ptr->palette) in png_do_expand_palette(). This is CVE-2013-6954
3) Updated dependencies on pnglibconf.h to match the new .o locations and and VU#650142.
added all the files in contrib/libtests and contrib/tools that depend
on pnglibconf.h
4) Added 'BUILD_SOURCES = pnglibconf.h'; this is the automake recommended
way of handling the dependencies of sources that are machine generated;
unfortunately it only works if the user does 'make all' or 'make check',
so the dependencies (3) are still required.
Cleaned up (char*) casts of zlib messages. The latest version of the Intel C
compiler complains about casting a string literal as (char*), so copied the
treatment of z_const from the library code into pngfix.c
Simplified error message code in pngunknown. The simplification has the
useful side effect of avoiding a bogus warning generated by the latest
version of the Intel C compiler (it objects to
condition ? string-literal : string-literal).
Make autogen.sh work with automake 1.13 as well as 1.14. Do this by always
removing the 1.14 'compile' script but never checking for it.
Added ARMv8 support (James Yu <james.yu at linaro.org>). Added file
arm/filter_neon_intrinsics.c; enable with -mfpu=neon.
Revised pngvalid to generate size images with as many filters as it can
manage, limited by the number of rows.
Cleaned up ARM NEON compilation handling. The tests are now in pngpriv.h
and detect the broken GCC compilers.
Allow clang derived from older GCC versions to use ARM intrinsics. This
causes all clang builds that use -mfpu=neon to use the intrinsics code,
not the assembler code. This has only been tested on iOS 7. It may be
necessary to exclude some earlier clang versions but this seems unlikely.
Changed NEON implementation selection mechanism. This allows assembler
or intrinsics to be turned on at compile time during the build by defining
PNG_ARM_NEON_IMPLEMENTATION to the correct value (2 or 1). This macro
is undefined by default and the build type is selected in pngpriv.h.
Fixed #include in filter_neon_intrinsics.c and ctype macros. The ctype char
checking macros take an unsigned char argument, not a signed char.
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

36
CHANGES
View File

@ -4712,6 +4712,42 @@ Version 1.6.7rc02 [November 7, 2013]
checking macros take an unsigned char argument, not a signed char. checking macros take an unsigned char argument, not a signed char.
Version 1.6.7 [November 14, 2013] Version 1.6.7 [November 14, 2013]
No changes.
Version 1.6.8beta01 [November 24, 2013]
Moved prototype for png_handle_unknown() in pngpriv.h outside of
the #ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED/#endif block.
Added "-Wall" to CFLAGS in contrib/pngminim/*/makefile
Conditionally compile some unused functions reported by -Wall in
pngminim.
Fixed 'minimal' builds. Various obviously useful minimal configurations
don't build because of missing contrib/libtests test programs and
overly complex dependencies in scripts/pnglibconf.dfa. This change
adds contrib/conftest/*.dfa files that can be used in automatic build
scripts to ensure that these configurations continue to build.
Enabled WRITE_INVERT and WRITE_PACK in contrib/pngminim/encoder.
Fixed pngvalid 'fail' function declaration on the Intel C Compiler.
This reverts to the previous 'static' implementation and works round
the 'unused static function' warning by using PNG_UNUSED().
Version 1.6.8beta02 [November 30, 2013]
Removed or marked PNG_UNUSED some harmless "dead assignments" reported
by clang scan-build.
Changed tabs to 3 spaces in png_debug macros and changed '"%s"m'
to '"%s" m' to improve portability among compilers.
Changed png_free_default() to free() in pngtest.c
Version 1.6.8rc01 [December 12, 2013]
Tidied up pngfix inits and fixed pngtest no-write builds.
Version 1.6.8rc02 [December 14, 2013]
Handle zero-length PLTE chunk or NULL palette with png_error()
instead of png_chunk_report(), which by default issues a warning
rather than an error, leading to later reading from a NULL pointer
(png_ptr->palette) in png_do_expand_palette(). This is CVE-2013-6954
and VU#650142.
Version 1.6.8 [December 19, 2013]
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

View File

@ -16,7 +16,7 @@ enable_testing()
set(PNGLIB_MAJOR 1) set(PNGLIB_MAJOR 1)
set(PNGLIB_MINOR 6) set(PNGLIB_MINOR 6)
set(PNGLIB_RELEASE 7) set(PNGLIB_RELEASE 8)
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})
@ -252,7 +252,7 @@ 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.7 # VERSION 16.${PNGLIB_RELEASE}.1.6.8
VERSION 16.${PNGLIB_RELEASE}.0 VERSION 16.${PNGLIB_RELEASE}.0
SOVERSION 16 SOVERSION 16
CLEAN_DIRECT_OUTPUT 1) CLEAN_DIRECT_OUTPUT 1)

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.7, November 14, 2013, are libpng versions 1.2.6, August 15, 2004, through 1.6.8, December 19, 2013, are
Copyright (c) 2004, 2006-2013 Glenn Randers-Pehrson, and are Copyright (c) 2004, 2006-2013 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
November 14, 2013 December 19, 2013

2
README
View File

@ -1,4 +1,4 @@
README for libpng version 1.6.7 - November 14, 2013 (shared library 16.0) README for libpng version 1.6.8 - December 19, 2013 (shared library 16.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.

View File

@ -3,7 +3,7 @@
* *
* Copyright (c) 2013 Glenn Randers-Pehrson * Copyright (c) 2013 Glenn Randers-Pehrson
* Written by Mans Rullgard, 2011. * Written by Mans Rullgard, 2011.
* Last changed in libpng 1.6.7 [November 14, 2013] * Last changed in libpng 1.6.8 [December 19, 2013]
* *
* 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
@ -11,7 +11,8 @@
*/ */
/* This is required to get the symbol renames, which are #defines, and also /* This is required to get the symbol renames, which are #defines, and also
* includes the definition (or not) of PNG_ARM_NEON_OPT. * includes the definition (or not) of PNG_ARM_NEON_OPT and
* PNG_ARM_NEON_IMPLEMENTATION.
*/ */
#define PNG_VERSION_INFO_ONLY #define PNG_VERSION_INFO_ONLY
#include "../pngpriv.h" #include "../pngpriv.h"

View File

@ -5,7 +5,7 @@
* Written by James Yu <james.yu at linaro.org>, October 2013. * Written by James Yu <james.yu at linaro.org>, October 2013.
* Based on filter_neon.S, written by Mans Rullgard, 2011. * Based on filter_neon.S, written by Mans Rullgard, 2011.
* *
* Last changed in libpng 1.6.7 [November 14, 2013] * Last changed in libpng 1.6.8 [December 19, 2013]
* *
* 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
@ -15,7 +15,7 @@
#include "../pngpriv.h" #include "../pngpriv.h"
/* This code requires -mfpu=neon on the command line: */ /* This code requires -mfpu=neon on the command line: */
#if PNG_ARM_NEON_IMPLEMENTATION == 1 /* intrinsics code */ #if PNG_ARM_NEON_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */
#include <arm_neon.h> #include <arm_neon.h>

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.7],[png-mng-implement@lists.sourceforge.net]) AC_INIT([libpng],[1.6.8],[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')
@ -39,10 +39,10 @@ dnl automake, so the following is not necessary (and is not defined anyway):
dnl AM_PREREQ([1.11.2]) dnl AM_PREREQ([1.11.2])
dnl stop configure from automagically running automake dnl stop configure from automagically running automake
PNGLIB_VERSION=1.6.7 PNGLIB_VERSION=1.6.8
PNGLIB_MAJOR=1 PNGLIB_MAJOR=1
PNGLIB_MINOR=6 PNGLIB_MINOR=6
PNGLIB_RELEASE=7 PNGLIB_RELEASE=8
dnl End of version number stuff dnl End of version number stuff

49
contrib/conftest/README Normal file
View File

@ -0,0 +1,49 @@
This directory contains test configuration files, currently always '.dfa' files
intended to be used in the build by setting the make macro DFA_XTRA to the name
of the file.
These files are used in release validation of the 'configure' builds of libpng
by building 'make check', or 'make all-am' for cross-builds, with each .dfa
file.
The files in this directory may change between minor releases, however
contributions describing specific builds of libpng are welcomed. There is no
guarantee that libpng will continue to build with such configurations; support
for given configurations can be, and has been, dropped between successive minor
releases. However if a .dfa file describing a configuration is not in this
directory it is very unlikely that it will be tested before a minor release!
You can use these .dfa files as the basis of new configurations. Files in this
directory should not have any use restrictions or restrictive licenses.
This directory is not included in the .zip and .7z distributions, which do
not contain 'configure' scripts.
DOCUMENTATION
=============
Examples:
${srcdir}/pngusr.dfa
${srcdir}/contrib/pngminim/*/pngusr.dfa
Documentation of the options:
${srcdir}/scripts/pnglibconf.dfa
Documentation of the file format:
${srcdir}/scripts/options.awk
FILE NAMING
===========
File names in this directory may NOT contain any of the five characters:
- , + * ?
Neither may they contain any space character.
While other characters may be used it is strongly suggested that file names be
limited to lower case Latiin alphabetic characters (a-z), digits (0-9) and, if
necessary the underscore (_) character. File names should be about 8 characters
long (excluding the .dfa extension). Submitted .dfa files should have names
between 7 and 16 characters long, shorter names (6 characters or less) are
reserved for standard tests.

58
contrib/conftest/read.dfa Normal file
View File

@ -0,0 +1,58 @@
# read.dfa
# Build time configuration of libpng
#
# Author: John Bowler
# Copyright: (c) John Bowler, 2013
# Usage rights:
# To the extent possible under law, the author has waived all copyright and
# related or neighboring rights to this work. This work is published from:
# United States.
#
# Build libpng with basic read support. This enables the lowest level libpng
# read API - the one where the calling code has to use a loop to read each row.
# At present this is the API used by most programs.
#
# Support is enabled only for those chunks and transformations that are
# typically required - others can be added easily.
#
everything = off
# The sequential read code is enabled here; the progressive code can be used
# instead but there is no point enabling both.
option SEQUENTIAL_READ on
# Likewise it is pointless enabling both fixed and floating point APIs. Choose
# one or the other for both the API and the internal math.
#Fixed point:
#option FIXED_POINT on
#option FLOATING_ARITHMETIC off
#Floating point:
option FLOATING_POINT on
option FLOATING_ARITHMETIC on
# Basic error handling, IO and user memory support. The latter allows the
# application program to provide its own implementations of 'malloc' and 'free'.
option SETJMP on
option STDIO on
option USER_MEM on
# To read the full set of PNG images correctly interlace, transparency and
# 16-bit support is required. The application can implement interlace itself,
# but very few do and it's no longer possible to disable it when READ is
# enabled.
option READ_tRNS on
option READ_16BIT on
# Everything else is application dependent. This file assumes the app handles
# all the native PNG bit layouts, so it doesn't need any of layout change
# transforms, but needs libpng to perform gamma correction. It doesn't do any
# colorspace stuff and ignores the 'significant bit' information.
#
# If your app always expands the image to a limited set of bit layouts you
# probably want to consider using the simplified API instead of the low level
# one - see png.h and s_read.dfa.
option READ_GAMMA on

View File

@ -0,0 +1,35 @@
# s_read.dfa
# Build time configuration of libpng
#
# Author: John Bowler
# Copyright: (c) John Bowler, 2013
# Usage rights:
# To the extent possible under law, the author has waived all copyright and
# related or neighboring rights to this work. This work is published from:
# United States.
#
# Build libpng with simplified read support (only). This builds a minimal
# libpng able to read all PNG formats and convert them into a small number of
# well understood memory formats.
#
everything = off
option SIMPLIFIED_READ on
# It isn't necessary to chose fixed or floating point for the APIs because the
# simplified API doesn't need fixed or floating point numbers. It is necessary
# to chose an internal math implementation. The default (because of 'everything
# = off') is fixed point - turn the floating point implementation on if you have
# hardware floating point or prefer your software floating point implementation.
option FLOATING_ARITHMETIC on
# This is not strictly necessary, but without it the message strings in the API
# will not be filled in
option ERROR_TEXT on
# Switching these options on enables the 'AFIRST' and 'BGR' formats - you don't
# need this if you don't use them, they just allow the in-memory layout to be
# changed to match common hardware formats.
option SIMPLIFIED_READ_AFIRST on
option SIMPLIFIED_READ_BGR on

View File

@ -0,0 +1,33 @@
# s_write.dfa
# Build time configuration of libpng
#
# Author: John Bowler
# Copyright: (c) John Bowler, 2013
# Usage rights:
# To the extent possible under law, the author has waived all copyright and
# related or neighboring rights to this work. This work is published from:
# United States.
#
# Build libpng with (just) simplified write support
#
everything = off
option SIMPLIFIED_WRITE on
# It isn't necessary to chose fixed or floating point for the APIs because the
# simplified API doesn't need fixed or floating point numbers. It is necessary
# to chose an internal math implementation. The default (because of 'everything
# = off') is fixed point - turn the floating point implementation on if you have
# hardware floating point or prefer your software floating point implementation.
option FLOATING_ARITHMETIC on
# This is not strictly necessary, but without it the message strings in the API
# will not be filled in
option ERROR_TEXT on
# Switching these options on enables the 'AFIRST' and 'BGR' formats - you don't
# need this if you don't use them, they just allow the in-memory layout to be
# changed to match common hardware formats.
option SIMPLIFIED_WRITE_AFIRST on
option SIMPLIFIED_WRITE_BGR on

View File

@ -0,0 +1,36 @@
# simple.dfa
# Build time configuration of libpng
#
# Author: John Bowler
# Copyright: (c) John Bowler, 2013
# Usage rights:
# To the extent possible under law, the author has waived all copyright and
# related or neighboring rights to this work. This work is published from:
# United States.
#
# Build libpng with just the simplified APIs (read and write).
#
everything = off
option SIMPLIFIED_WRITE on
option SIMPLIFIED_READ on
# It isn't necessary to chose fixed or floating point for the APIs because the
# simplified API doesn't need fixed or floating point numbers. It is necessary
# to chose an internal math implementation. The default (because of 'everything
# = off') is fixed point - turn the floating point implementation on if you have
# hardware floating point or prefer your software floating point implementation.
option FLOATING_ARITHMETIC on
# This is not strictly necessary, but without it the message strings in the API
# will not be filled in
option ERROR_TEXT on
# Switching these options on enables the 'AFIRST' and 'BGR' formats - you don't
# need this if you don't use them, they just allow the in-memory layout to be
# changed to match common hardware formats.
option SIMPLIFIED_READ_AFIRST on
option SIMPLIFIED_READ_BGR on
option SIMPLIFIED_WRITE_AFIRST on
option SIMPLIFIED_WRITE_BGR on

View File

@ -0,0 +1,45 @@
# write.dfa
# Build time configuration of libpng
#
# Author: John Bowler
# Copyright: (c) John Bowler, 2013
# Usage rights:
# To the extent possible under law, the author has waived all copyright and
# related or neighboring rights to this work. This work is published from:
# United States.
#
# Build libpng with no read support and minimal write support.
#
everything = off
# Switch on the write code - this makes a minimalist encoder
option WRITE on
# Choose fixed or floating point APIs and arithmetic. The choices are
# independent but normally they will match. It is typically better to use the
# floating point if you have floating point hardware. If you don't know, or
# (perhaps) to make libpng smaller used fixed point throughout.
#Fixed point:
#option FIXED_POINT on
#option FLOATING_ARITHMETIC off
#Floating point:
option FLOATING_POINT on
option FLOATING_ARITHMETIC on
# Basic error handling, IO and user memory support. The latter allows the
# application program to provide its own implementations of 'malloc' and 'free'.
option SETJMP on
option STDIO on
option USER_MEM on
# Everything else is optional. Unlike the read code in libpng the write code
# does not need to deal with arbitrary formats, so only add support for things
# you really do write! For example you might only write sRGB images, sometimes
# with transparency and never write 16 bit images, so:
option WRITE_sRGB on
option WRITE_tRNS on
#option WRITE_16BIT off (this is the default with 'everything = off')

View File

@ -3,7 +3,7 @@
* *
* Copyright (c) 2013 John Cunningham Bowler * Copyright (c) 2013 John Cunningham Bowler
* *
* Last changed in libpng 1.6.1 [March 28, 2013] * Last changed in libpng 1.6.8 [December 19, 2013]
* *
* 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
@ -517,14 +517,23 @@ static void format_default(format_list *pf, int redundant)
for (f=0; f<FORMAT_COUNT; ++f) for (f=0; f<FORMAT_COUNT; ++f)
{ {
/* Eliminate redundant settings. */ /* Eliminate redundant and unsupported settings. */
/* BGR is meaningless if no color: */ # ifdef PNG_FORMAT_BGR_SUPPORTED
if ((f & PNG_FORMAT_FLAG_COLOR) == 0 && (f & PNG_FORMAT_FLAG_BGR) != 0) /* BGR is meaningless if no color: */
if ((f & PNG_FORMAT_FLAG_COLOR) == 0 &&
(f & PNG_FORMAT_FLAG_BGR) != 0)
# else
if ((f & 0x10U/*HACK: fixed value*/) != 0)
# endif
continue; continue;
/* AFIRST is meaningless if no alpha: */ /* AFIRST is meaningless if no alpha: */
if ((f & PNG_FORMAT_FLAG_ALPHA) == 0 && # ifdef PNG_FORMAT_AFIRST_SUPPORTED
(f & PNG_FORMAT_FLAG_AFIRST) != 0) if ((f & PNG_FORMAT_FLAG_ALPHA) == 0 &&
(f & PNG_FORMAT_FLAG_AFIRST) != 0)
# else
if ((f & 0x20U/*HACK: fixed value*/) != 0)
# endif
continue; continue;
format_set(pf, f); format_set(pf, f);
@ -786,6 +795,7 @@ gp_ga8(Pixel *p, png_const_voidp pb)
p->a = pp[1]; p->a = pp[1];
} }
#ifdef PNG_FORMAT_AFIRST_SUPPORTED
static void static void
gp_ag8(Pixel *p, png_const_voidp pb) gp_ag8(Pixel *p, png_const_voidp pb)
{ {
@ -794,6 +804,7 @@ gp_ag8(Pixel *p, png_const_voidp pb)
p->r = p->g = p->b = pp[1]; p->r = p->g = p->b = pp[1];
p->a = pp[0]; p->a = pp[0];
} }
#endif
static void static void
gp_rgb8(Pixel *p, png_const_voidp pb) gp_rgb8(Pixel *p, png_const_voidp pb)
@ -806,6 +817,7 @@ gp_rgb8(Pixel *p, png_const_voidp pb)
p->a = 255; p->a = 255;
} }
#ifdef PNG_FORMAT_BGR_SUPPORTED
static void static void
gp_bgr8(Pixel *p, png_const_voidp pb) gp_bgr8(Pixel *p, png_const_voidp pb)
{ {
@ -816,6 +828,7 @@ gp_bgr8(Pixel *p, png_const_voidp pb)
p->b = pp[0]; p->b = pp[0];
p->a = 255; p->a = 255;
} }
#endif
static void static void
gp_rgba8(Pixel *p, png_const_voidp pb) gp_rgba8(Pixel *p, png_const_voidp pb)
@ -828,6 +841,7 @@ gp_rgba8(Pixel *p, png_const_voidp pb)
p->a = pp[3]; p->a = pp[3];
} }
#ifdef PNG_FORMAT_BGR_SUPPORTED
static void static void
gp_bgra8(Pixel *p, png_const_voidp pb) gp_bgra8(Pixel *p, png_const_voidp pb)
{ {
@ -838,7 +852,9 @@ gp_bgra8(Pixel *p, png_const_voidp pb)
p->b = pp[0]; p->b = pp[0];
p->a = pp[3]; p->a = pp[3];
} }
#endif
#ifdef PNG_FORMAT_AFIRST_SUPPORTED
static void static void
gp_argb8(Pixel *p, png_const_voidp pb) gp_argb8(Pixel *p, png_const_voidp pb)
{ {
@ -849,7 +865,9 @@ gp_argb8(Pixel *p, png_const_voidp pb)
p->b = pp[3]; p->b = pp[3];
p->a = pp[0]; p->a = pp[0];
} }
#endif
#if defined(PNG_FORMAT_AFIRST_SUPPORTED) && defined(PNG_FORMAT_BGR_SUPPORTED)
static void static void
gp_abgr8(Pixel *p, png_const_voidp pb) gp_abgr8(Pixel *p, png_const_voidp pb)
{ {
@ -860,6 +878,7 @@ gp_abgr8(Pixel *p, png_const_voidp pb)
p->b = pp[1]; p->b = pp[1];
p->a = pp[0]; p->a = pp[0];
} }
#endif
static void static void
gp_g16(Pixel *p, png_const_voidp pb) gp_g16(Pixel *p, png_const_voidp pb)
@ -879,6 +898,7 @@ gp_ga16(Pixel *p, png_const_voidp pb)
p->a = pp[1]; p->a = pp[1];
} }
#ifdef PNG_FORMAT_AFIRST_SUPPORTED
static void static void
gp_ag16(Pixel *p, png_const_voidp pb) gp_ag16(Pixel *p, png_const_voidp pb)
{ {
@ -887,6 +907,7 @@ gp_ag16(Pixel *p, png_const_voidp pb)
p->r = p->g = p->b = pp[1]; p->r = p->g = p->b = pp[1];
p->a = pp[0]; p->a = pp[0];
} }
#endif
static void static void
gp_rgb16(Pixel *p, png_const_voidp pb) gp_rgb16(Pixel *p, png_const_voidp pb)
@ -899,6 +920,7 @@ gp_rgb16(Pixel *p, png_const_voidp pb)
p->a = 65535; p->a = 65535;
} }
#ifdef PNG_FORMAT_BGR_SUPPORTED
static void static void
gp_bgr16(Pixel *p, png_const_voidp pb) gp_bgr16(Pixel *p, png_const_voidp pb)
{ {
@ -909,6 +931,7 @@ gp_bgr16(Pixel *p, png_const_voidp pb)
p->b = pp[0]; p->b = pp[0];
p->a = 65535; p->a = 65535;
} }
#endif
static void static void
gp_rgba16(Pixel *p, png_const_voidp pb) gp_rgba16(Pixel *p, png_const_voidp pb)
@ -921,6 +944,7 @@ gp_rgba16(Pixel *p, png_const_voidp pb)
p->a = pp[3]; p->a = pp[3];
} }
#ifdef PNG_FORMAT_BGR_SUPPORTED
static void static void
gp_bgra16(Pixel *p, png_const_voidp pb) gp_bgra16(Pixel *p, png_const_voidp pb)
{ {
@ -931,7 +955,9 @@ gp_bgra16(Pixel *p, png_const_voidp pb)
p->b = pp[0]; p->b = pp[0];
p->a = pp[3]; p->a = pp[3];
} }
#endif
#ifdef PNG_FORMAT_AFIRST_SUPPORTED
static void static void
gp_argb16(Pixel *p, png_const_voidp pb) gp_argb16(Pixel *p, png_const_voidp pb)
{ {
@ -942,7 +968,9 @@ gp_argb16(Pixel *p, png_const_voidp pb)
p->b = pp[3]; p->b = pp[3];
p->a = pp[0]; p->a = pp[0];
} }
#endif
#if defined(PNG_FORMAT_AFIRST_SUPPORTED) && defined(PNG_FORMAT_BGR_SUPPORTED)
static void static void
gp_abgr16(Pixel *p, png_const_voidp pb) gp_abgr16(Pixel *p, png_const_voidp pb)
{ {
@ -953,6 +981,7 @@ gp_abgr16(Pixel *p, png_const_voidp pb)
p->b = pp[1]; p->b = pp[1];
p->a = pp[0]; p->a = pp[0];
} }
#endif
/* Given a format, return the correct one of the above functions. */ /* Given a format, return the correct one of the above functions. */
static void (* static void (*
@ -966,29 +995,35 @@ get_pixel(png_uint_32 format))(Pixel *p, png_const_voidp pb)
{ {
if (format & PNG_FORMAT_FLAG_COLOR) if (format & PNG_FORMAT_FLAG_COLOR)
{ {
if (format & PNG_FORMAT_FLAG_BGR) # ifdef PNG_FORMAT_BGR_SUPPORTED
{ if (format & PNG_FORMAT_FLAG_BGR)
if (format & PNG_FORMAT_FLAG_ALPHA)
{ {
if (format & PNG_FORMAT_FLAG_AFIRST) if (format & PNG_FORMAT_FLAG_ALPHA)
return gp_abgr16; {
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
if (format & PNG_FORMAT_FLAG_AFIRST)
return gp_abgr16;
else
# endif
return gp_bgra16;
}
else else
return gp_bgra16; return gp_bgr16;
} }
else else
return gp_bgr16; # endif
}
else
{ {
if (format & PNG_FORMAT_FLAG_ALPHA) if (format & PNG_FORMAT_FLAG_ALPHA)
{ {
if (format & PNG_FORMAT_FLAG_AFIRST) # ifdef PNG_FORMAT_AFIRST_SUPPORTED
return gp_argb16; if (format & PNG_FORMAT_FLAG_AFIRST)
return gp_argb16;
else else
# endif
return gp_rgba16; return gp_rgba16;
} }
@ -1001,10 +1036,12 @@ get_pixel(png_uint_32 format))(Pixel *p, png_const_voidp pb)
{ {
if (format & PNG_FORMAT_FLAG_ALPHA) if (format & PNG_FORMAT_FLAG_ALPHA)
{ {
if (format & PNG_FORMAT_FLAG_AFIRST) # ifdef PNG_FORMAT_AFIRST_SUPPORTED
return gp_ag16; if (format & PNG_FORMAT_FLAG_AFIRST)
return gp_ag16;
else else
# endif
return gp_ga16; return gp_ga16;
} }
@ -1017,29 +1054,35 @@ get_pixel(png_uint_32 format))(Pixel *p, png_const_voidp pb)
{ {
if (format & PNG_FORMAT_FLAG_COLOR) if (format & PNG_FORMAT_FLAG_COLOR)
{ {
if (format & PNG_FORMAT_FLAG_BGR) # ifdef PNG_FORMAT_BGR_SUPPORTED
{ if (format & PNG_FORMAT_FLAG_BGR)
if (format & PNG_FORMAT_FLAG_ALPHA)
{ {
if (format & PNG_FORMAT_FLAG_AFIRST) if (format & PNG_FORMAT_FLAG_ALPHA)
return gp_abgr8; {
# ifdef PNG_FORMAT_AFIRST_SUPPORTED
if (format & PNG_FORMAT_FLAG_AFIRST)
return gp_abgr8;
else
# endif
return gp_bgra8;
}
else else
return gp_bgra8; return gp_bgr8;
} }
else else
return gp_bgr8; # endif
}
else
{ {
if (format & PNG_FORMAT_FLAG_ALPHA) if (format & PNG_FORMAT_FLAG_ALPHA)
{ {
if (format & PNG_FORMAT_FLAG_AFIRST) # ifdef PNG_FORMAT_AFIRST_SUPPORTED
return gp_argb8; if (format & PNG_FORMAT_FLAG_AFIRST)
return gp_argb8;
else else
# endif
return gp_rgba8; return gp_rgba8;
} }
@ -1052,10 +1095,12 @@ get_pixel(png_uint_32 format))(Pixel *p, png_const_voidp pb)
{ {
if (format & PNG_FORMAT_FLAG_ALPHA) if (format & PNG_FORMAT_FLAG_ALPHA)
{ {
if (format & PNG_FORMAT_FLAG_AFIRST) # ifdef PNG_FORMAT_AFIRST_SUPPORTED
return gp_ag8; if (format & PNG_FORMAT_FLAG_AFIRST)
return gp_ag8;
else else
# endif
return gp_ga8; return gp_ga8;
} }
@ -2618,13 +2663,15 @@ component_loc(png_byte loc[4], png_uint_32 format)
loc[2] = 1; loc[2] = 1;
if (format & PNG_FORMAT_FLAG_BGR) # ifdef PNG_FORMAT_BGR_SUPPORTED
{ if (format & PNG_FORMAT_FLAG_BGR)
loc[1] = 2; {
loc[3] = 0; loc[1] = 2;
} loc[3] = 0;
}
else else
# endif
{ {
loc[1] = 0; loc[1] = 0;
loc[3] = 2; loc[3] = 2;
@ -2639,15 +2686,17 @@ component_loc(png_byte loc[4], png_uint_32 format)
if (format & PNG_FORMAT_FLAG_ALPHA) if (format & PNG_FORMAT_FLAG_ALPHA)
{ {
if (format & PNG_FORMAT_FLAG_AFIRST) # ifdef PNG_FORMAT_AFIRST_SUPPORTED
{ if (format & PNG_FORMAT_FLAG_AFIRST)
loc[0] = 0; {
++loc[1]; loc[0] = 0;
++loc[2]; ++loc[1];
++loc[3]; ++loc[2];
} ++loc[3];
}
else else
# endif
loc[0] = channels; loc[0] = channels;
++channels; ++channels;
@ -3017,17 +3066,25 @@ read_file(Image *image, png_uint_32 format, png_const_colorp background)
return logerror(image, "memory init: ", image->file_name, ""); return logerror(image, "memory init: ", image->file_name, "");
} }
else if (image->input_file != NULL) # ifdef PNG_STDIO_SUPPORTED
{ else if (image->input_file != NULL)
if (!png_image_begin_read_from_stdio(&image->image, image->input_file)) {
return logerror(image, "stdio init: ", image->file_name, ""); if (!png_image_begin_read_from_stdio(&image->image, image->input_file))
} return logerror(image, "stdio init: ", image->file_name, "");
}
else else
{ {
if (!png_image_begin_read_from_file(&image->image, image->file_name)) if (!png_image_begin_read_from_file(&image->image, image->file_name))
return logerror(image, "file init: ", image->file_name, ""); return logerror(image, "file init: ", image->file_name, "");
} }
# else
else
{
return logerror(image, "unsupported file/stdio init: ",
image->file_name, "");
}
# endif
/* This must be set after the begin_read call: */ /* This must be set after the begin_read call: */
if (image->opts & sRGB_16BIT) if (image->opts & sRGB_16BIT)
@ -3466,11 +3523,19 @@ main(int argc, char **argv)
memset(gpc_error_via_linear, 0, sizeof gpc_error_via_linear); memset(gpc_error_via_linear, 0, sizeof gpc_error_via_linear);
} }
else if (strcmp(arg, "--file") == 0) else if (strcmp(arg, "--file") == 0)
opts |= READ_FILE; # ifdef PNG_STDIO_SUPPORTED
opts |= READ_FILE;
# else
return 77; /* skipped: no support */
# endif
else if (strcmp(arg, "--memory") == 0) else if (strcmp(arg, "--memory") == 0)
opts &= ~READ_FILE; opts &= ~READ_FILE;
else if (strcmp(arg, "--stdio") == 0) else if (strcmp(arg, "--stdio") == 0)
opts |= USE_STDIO; # ifdef PNG_STDIO_SUPPORTED
opts |= USE_STDIO;
# else
return 77; /* skipped: no support */
# endif
else if (strcmp(arg, "--name") == 0) else if (strcmp(arg, "--name") == 0)
opts &= ~USE_STDIO; opts &= ~USE_STDIO;
else if (strcmp(arg, "--verbose") == 0) else if (strcmp(arg, "--verbose") == 0)

View File

@ -1,7 +1,7 @@
/* pngvalid.c - validate libpng by constructing then reading png files. /* pngvalid.c - validate libpng by constructing then reading png files.
* *
* Last changed in libpng 1.6.1 [March 28, 2013] * Last changed in libpng 1.6.8 [December 19, 2013]
* Copyright (c) 2013 Glenn Randers-Pehrson * Copyright (c) 2013 Glenn Randers-Pehrson
* Written by John Cunningham Bowler * Written by John Cunningham Bowler
* *
@ -43,7 +43,10 @@
# include "../../png.h" # include "../../png.h"
#endif #endif
#ifdef PNG_WRITE_SUPPORTED /* else pngvalid can do nothing */ /* pngvalid requires write support and one of the fixed or floating point APIs.
*/
#if defined(PNG_WRITE_SUPPORTED) &&\
(defined(PNG_FIXED_POINT_SUPPORTED) || defined(PNG_FLOATING_POINT_SUPPORTED))
#if PNG_LIBPNG_VER < 10500 #if PNG_LIBPNG_VER < 10500
/* This deliberately lacks the PNG_CONST. */ /* This deliberately lacks the PNG_CONST. */
@ -106,6 +109,11 @@ typedef png_byte *png_const_bytep;
# endif # endif
#endif #endif
/* Fixups for various minimal builds */
#ifndef PNG_ERROR_TEXT_SUPPORTED
# define png_error(a,b) png_err(a)
#endif
/***************************** EXCEPTION HANDLING *****************************/ /***************************** EXCEPTION HANDLING *****************************/
#ifdef PNG_FREESTANDING_TESTS #ifdef PNG_FREESTANDING_TESTS
# include <cexcept.h> # include <cexcept.h>
@ -1263,6 +1271,7 @@ store_current_palette(png_store *ps, int *npalette)
#endif /* PNG_READ_SUPPORTED */ #endif /* PNG_READ_SUPPORTED */
/***************************** MEMORY MANAGEMENT*** ***************************/ /***************************** MEMORY MANAGEMENT*** ***************************/
#ifdef PNG_USER_MEM_SUPPORTED
/* A store_memory is simply the header for an allocated block of memory. The /* A store_memory is simply the header for an allocated block of memory. The
* pointer returned to libpng is just after the end of the header block, the * pointer returned to libpng is just after the end of the header block, the
* allocated memory is followed by a second copy of the 'mark'. * allocated memory is followed by a second copy of the 'mark'.
@ -1463,6 +1472,7 @@ store_free(png_structp ppIn, png_voidp memory)
this->next = NULL; this->next = NULL;
store_memory_free(pp, pool, this); store_memory_free(pp, pool, this);
} }
#endif /* PNG_USER_MEM_SUPPORTED */
/* Setup functions. */ /* Setup functions. */
/* Cleanup when aborting a write or after storing the new file. */ /* Cleanup when aborting a write or after storing the new file. */
@ -1488,7 +1498,9 @@ store_write_reset(png_store *ps)
/* And make sure that all the memory has been freed - this will output /* And make sure that all the memory has been freed - this will output
* spurious errors in the case of memory corruption above, but this is safe. * spurious errors in the case of memory corruption above, but this is safe.
*/ */
store_pool_delete(ps, &ps->write_memory_pool); # ifdef PNG_USER_MEM_SUPPORTED
store_pool_delete(ps, &ps->write_memory_pool);
# endif
store_freenew(ps); store_freenew(ps);
} }
@ -1512,16 +1524,20 @@ set_store_for_write(png_store *ps, png_infopp ppi,
store_write_reset(ps); store_write_reset(ps);
safecat(ps->wname, sizeof ps->wname, 0, name); safecat(ps->wname, sizeof ps->wname, 0, name);
/* Don't do the slow memory checks if doing a speed test. */ /* Don't do the slow memory checks if doing a speed test, also if user
if (ps->speed) * memory is not supported we can't do it anyway.
*/
# ifdef PNG_USER_MEM_SUPPORTED
if (!ps->speed)
ps->pwrite = png_create_write_struct_2(PNG_LIBPNG_VER_STRING,
ps, store_error, store_warning, &ps->write_memory_pool,
store_malloc, store_free);
else
# endif
ps->pwrite = png_create_write_struct(PNG_LIBPNG_VER_STRING, ps->pwrite = png_create_write_struct(PNG_LIBPNG_VER_STRING,
ps, store_error, store_warning); ps, store_error, store_warning);
else
ps->pwrite = png_create_write_struct_2(PNG_LIBPNG_VER_STRING,
ps, store_error, store_warning, &ps->write_memory_pool,
store_malloc, store_free);
png_set_write_fn(ps->pwrite, ps, store_write, store_flush); png_set_write_fn(ps->pwrite, ps, store_write, store_flush);
# ifdef PNG_SET_OPTION_SUPPORTED # ifdef PNG_SET_OPTION_SUPPORTED
@ -1569,8 +1585,10 @@ store_read_reset(png_store *ps)
} }
# endif # endif
/* Always do this to be safe. */ # ifdef PNG_USER_MEM_SUPPORTED
store_pool_delete(ps, &ps->read_memory_pool); /* Always do this to be safe. */
store_pool_delete(ps, &ps->read_memory_pool);
# endif
ps->current = NULL; ps->current = NULL;
ps->next = NULL; ps->next = NULL;
@ -1630,14 +1648,16 @@ set_store_for_read(png_store *ps, png_infopp ppi, png_uint_32 id,
* However, given that store_error works correctly in these circumstances * However, given that store_error works correctly in these circumstances
* we don't ever expect NULL in this program. * we don't ever expect NULL in this program.
*/ */
if (ps->speed) # ifdef PNG_USER_MEM_SUPPORTED
ps->pread = png_create_read_struct(PNG_LIBPNG_VER_STRING, ps, if (!ps->speed)
store_error, store_warning); ps->pread = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, ps,
store_error, store_warning, &ps->read_memory_pool, store_malloc,
store_free);
else else
ps->pread = png_create_read_struct_2(PNG_LIBPNG_VER_STRING, ps, # endif
store_error, store_warning, &ps->read_memory_pool, store_malloc, ps->pread = png_create_read_struct(PNG_LIBPNG_VER_STRING, ps, store_error,
store_free); store_warning);
if (ps->pread == NULL) if (ps->pread == NULL)
{ {
@ -1934,7 +1954,7 @@ typedef struct png_modifier
/* This returns true if the test should be stopped now because it has already /* This returns true if the test should be stopped now because it has already
* failed and it is running silently. * failed and it is running silently.
*/ */
static int fail(png_modifier *pm) static int fail(png_modifier *pm)
{ {
return !pm->log && !pm->this.verbose && (pm->this.nerrors > 0 || return !pm->log && !pm->this.verbose && (pm->this.nerrors > 0 ||
@ -3109,8 +3129,10 @@ init_standard_palette(png_store *ps, png_structp pp, png_infop pi, int npalette,
for (; i<256; ++i) for (; i<256; ++i)
tRNS[i] = 24; tRNS[i] = 24;
if (j > 0) # ifdef PNG_WRITE_tRNS_SUPPORTED
png_set_tRNS(pp, pi, tRNS, j, 0/*color*/); if (j > 0)
png_set_tRNS(pp, pi, tRNS, j, 0/*color*/);
# endif
} }
} }
@ -3356,6 +3378,13 @@ transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX],
*/ */
#define DEPTH(bd) ((png_byte)(1U << (bd))) #define DEPTH(bd) ((png_byte)(1U << (bd)))
/* This is just a helper for compiling on minimal systems with no write
* interlacing support.
*/
#ifndef PNG_WRITE_INTERLACING_SUPPORTED
# define png_set_interlace_handling(a) (1)
#endif
/* Make a standardized image given a an image colour type, bit depth and /* Make a standardized image given a an image colour type, bit depth and
* interlace type. The standard images have a very restricted range of * interlace type. The standard images have a very restricted range of
* rows and heights and are used for testing transforms rather than image * rows and heights and are used for testing transforms rather than image
@ -3509,8 +3538,12 @@ make_transform_images(png_store *ps)
{ {
int interlace_type; int interlace_type;
for (interlace_type = PNG_INTERLACE_NONE; # ifdef PNG_WRITE_INTERLACING_SUPPORTED
interlace_type < PNG_INTERLACE_LAST; ++interlace_type) for (interlace_type = PNG_INTERLACE_NONE;
interlace_type < PNG_INTERLACE_LAST; ++interlace_type)
# else
interlace_type = PNG_INTERLACE_NONE;
# endif
{ {
char name[FILE_NAME_SIZE]; char name[FILE_NAME_SIZE];
@ -3666,7 +3699,9 @@ make_size_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
int npasses = npasses_from_interlace_type(pp, interlace_type); int npasses = npasses_from_interlace_type(pp, interlace_type);
png_uint_32 y; png_uint_32 y;
int pass; int pass;
int nfilter = PNG_FILTER_VALUE_LAST; # ifdef PNG_WRITE_FILTER_SUPPORTED
int nfilter = PNG_FILTER_VALUE_LAST;
# endif
png_byte image[16][SIZE_ROWMAX]; png_byte image[16][SIZE_ROWMAX];
/* To help consistent error detection make the parts of this buffer /* To help consistent error detection make the parts of this buffer
@ -3720,6 +3755,7 @@ make_size_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
continue; continue;
} }
# ifdef PNG_WRITE_FILTER_SUPPORTED
/* Only get to here if the row has some pixels in it, set the /* Only get to here if the row has some pixels in it, set the
* filters to 'all' for the very first row and thereafter to a * filters to 'all' for the very first row and thereafter to a
* single filter. It isn't well documented, but png_set_filter * single filter. It isn't well documented, but png_set_filter
@ -3735,6 +3771,7 @@ make_size_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
if (nfilter-- == 0) if (nfilter-- == 0)
nfilter = PNG_FILTER_VALUE_LAST-1; nfilter = PNG_FILTER_VALUE_LAST-1;
# endif
png_write_row(pp, row); png_write_row(pp, row);
} }
@ -3802,8 +3839,10 @@ make_size(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type, int bdlo,
width, height, 0); width, height, 0);
make_size_image(ps, colour_type, DEPTH(bdlo), PNG_INTERLACE_NONE, make_size_image(ps, colour_type, DEPTH(bdlo), PNG_INTERLACE_NONE,
width, height, 1); width, height, 1);
# ifdef PNG_WRITE_INTERLACING_SUPPORTED
make_size_image(ps, colour_type, DEPTH(bdlo), PNG_INTERLACE_ADAM7, make_size_image(ps, colour_type, DEPTH(bdlo), PNG_INTERLACE_ADAM7,
width, height, 0); width, height, 0);
# endif
make_size_image(ps, colour_type, DEPTH(bdlo), PNG_INTERLACE_ADAM7, make_size_image(ps, colour_type, DEPTH(bdlo), PNG_INTERLACE_ADAM7,
width, height, 1); width, height, 1);
} }
@ -3998,8 +4037,12 @@ make_errors(png_modifier* PNG_CONST pm, png_byte PNG_CONST colour_type,
{ {
int interlace_type; int interlace_type;
for (interlace_type = PNG_INTERLACE_NONE; # ifdef PNG_WRITE_INTERLACING_SUPPORTED
interlace_type < PNG_INTERLACE_LAST; ++interlace_type) for (interlace_type = PNG_INTERLACE_NONE;
interlace_type < PNG_INTERLACE_LAST; ++interlace_type)
# else
interlace_type = PNG_INTERLACE_NONE;
# endif
{ {
unsigned int test; unsigned int test;
char name[FILE_NAME_SIZE]; char name[FILE_NAME_SIZE];
@ -4020,7 +4063,7 @@ make_errors(png_modifier* PNG_CONST pm, png_byte PNG_CONST colour_type,
return 1; /* keep going */ return 1; /* keep going */
} }
#endif #endif /* PNG_WARNINGS_SUPPORTED */
static void static void
perform_error_test(png_modifier *pm) perform_error_test(png_modifier *pm)
@ -10222,12 +10265,16 @@ int main(int argc, char **argv)
} }
} }
/* This is required because some very minimal configurations do not use it:
*/
UNUSED(fail)
return 0; return 0;
} }
#else /* write not supported */ #else /* write or low level APIs not supported */
int main(void) int main(void)
{ {
fprintf(stderr, "pngvalid: no write support in libpng, all tests skipped\n"); fprintf(stderr,
"pngvalid: no low level write support in libpng, all tests skipped\n");
/* So the test is skipped: */ /* So the test is skipped: */
return 77; return 77;
} }

View File

@ -15,7 +15,7 @@ RM=rm -f
COPY=cp COPY=cp
CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
CFLAGS=-O1 CFLAGS=-O1 -Wall
C=.c C=.c
O=.o O=.o

View File

@ -15,7 +15,7 @@ RM=rm -f
COPY=cp COPY=cp
CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
CFLAGS=-O1 CFLAGS=-O1 -Wall
C=.c C=.c
O=.o O=.o

View File

@ -13,9 +13,10 @@ everything = off
# Switch on the write code - this makes a minimalist encoder # Switch on the write code - this makes a minimalist encoder
option WRITE on option WRITE on
# These 2 options are required if you need to read PGM (P1 or P4) PGM files.
# option WRITE_INVERT on # These 2 options are required if you need to read PBM (P1 or P4) files.
# option WRITE_PACK on option WRITE_INVERT on
option WRITE_PACK on
# You must choose fixed or floating point arithmetic: # You must choose fixed or floating point arithmetic:
# option FLOATING_POINT on # option FLOATING_POINT on

View File

@ -31,7 +31,7 @@ XLIB = -L/usr/X11R6/lib -lX11
LIBS = $(XLIB) -lm #platforms that need libm LIBS = $(XLIB) -lm #platforms that need libm
CPPFLAGS=-I. $(XINC) -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP CPPFLAGS=-I. $(XINC) -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
CFLAGS=-O1 CFLAGS=-O1 -Wall
C=.c C=.c
O=.o O=.o

View File

@ -2,7 +2,7 @@
* *
* Copyright (c) 2013 John Cunningham Bowler * Copyright (c) 2013 John Cunningham Bowler
* *
* Last changed in libpng 1.6.3 [July 18, 2013] * Last changed in libpng 1.6.8 [December 19, 2013]
* *
* 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
@ -50,7 +50,7 @@
# error "pngfix will not work with libpng prior to 1.6.3" # error "pngfix will not work with libpng prior to 1.6.3"
#endif #endif
#ifdef PNG_READ_SUPPORTED #if defined(PNG_READ_SUPPORTED) && defined(PNG_EASY_ACCESS_SUPPORTED)
/* zlib.h defines the structure z_stream, an instance of which is included /* zlib.h defines the structure z_stream, an instance of which is included
* in this structure and is required for decompressing the LZ compressed * in this structure and is required for decompressing the LZ compressed
* data in PNG files. * data in PNG files.
@ -142,6 +142,11 @@
/* Is it safe to copy? */ /* Is it safe to copy? */
#define SAFE_TO_COPY(chunk) (((chunk) & PNG_U32(0,0,0,32)) != 0) #define SAFE_TO_COPY(chunk) (((chunk) & PNG_U32(0,0,0,32)) != 0)
/* Fix ups for builds with limited read support */
#ifndef PNG_ERROR_TEXT_SUPPORTED
# define png_error(a,b) png_err(a)
#endif
/********************************* UTILITIES **********************************/ /********************************* UTILITIES **********************************/
/* UNREACHED is a value to cause an assert to fail. Because of the way the /* UNREACHED is a value to cause an assert to fail. Because of the way the
* assert macro is written the string "UNREACHED" is produced in the error * assert macro is written the string "UNREACHED" is produced in the error
@ -1570,7 +1575,7 @@ chunk_end(struct chunk **chunk_var)
} }
static void static void
chunk_init(struct chunk *chunk, struct file *file) chunk_init(struct chunk * const chunk, struct file * const file)
/* When a chunk is initialized the file length/type/pos are copied into the /* When a chunk is initialized the file length/type/pos are copied into the
* corresponding chunk fields and the new chunk is registered in the file * corresponding chunk fields and the new chunk is registered in the file
* structure. There can only be one chunk at a time. * structure. There can only be one chunk at a time.
@ -1779,7 +1784,7 @@ IDAT_end(struct IDAT **idat_var)
} }
static void static void
IDAT_init(struct IDAT *idat, struct file *file) IDAT_init(struct IDAT * const idat, struct file * const file)
/* When the chunk is png_IDAT instantiate an IDAT control structure in place /* When the chunk is png_IDAT instantiate an IDAT control structure in place
* of a chunk control structure. The IDAT will instantiate a chunk control * of a chunk control structure. The IDAT will instantiate a chunk control
* structure using the file alloc routine. * structure using the file alloc routine.
@ -3318,6 +3323,8 @@ read_callback(png_structp png_ptr, png_bytep buffer, size_t count)
else else
{ {
assert(chunk != NULL);
/* Set up for write, notice that repositioning the input stream /* Set up for write, notice that repositioning the input stream
* is only necessary if something is to be read from it. Also * is only necessary if something is to be read from it. Also
* notice that for the IDAT stream this must only happen once - * notice that for the IDAT stream this must only happen once -
@ -3331,6 +3338,8 @@ read_callback(png_structp png_ptr, png_bytep buffer, size_t count)
/* FALL THROUGH */ /* FALL THROUGH */
default: default:
assert(chunk != NULL);
/* NOTE: the arithmetic below overflows and gives a large positive /* NOTE: the arithmetic below overflows and gives a large positive
* png_uint_32 value until the whole chunk data has been written. * png_uint_32 value until the whole chunk data has been written.
*/ */
@ -3536,22 +3545,14 @@ allocate(struct file *file, int allocate_idat)
if (allocate_idat) if (allocate_idat)
{ {
struct IDAT *idat;
assert(file->idat == NULL); assert(file->idat == NULL);
idat = &control->idat; IDAT_init(&control->idat, file);
IDAT_init(idat, file);
file->idat = idat;
} }
else /* chunk */ else /* chunk */
{ {
struct chunk *chunk;
assert(file->chunk == NULL); assert(file->chunk == NULL);
chunk = &control->chunk; chunk_init(&control->chunk, file);
chunk_init(chunk, file);
file->chunk = chunk;
} }
} }
@ -3644,7 +3645,7 @@ read_png(struct control *control)
return rc; return rc;
} }
static void static int
one_file(struct global *global, const char *file_name, const char *out_name) one_file(struct global *global, const char *file_name, const char *out_name)
{ {
int rc; int rc;
@ -3663,6 +3664,8 @@ one_file(struct global *global, const char *file_name, const char *out_name)
rc = read_png(&control); rc = read_png(&control);
rc |= control_end(&control); rc |= control_end(&control);
return rc;
} }
static void static void
@ -4031,4 +4034,4 @@ main(void)
fprintf(stderr, "pngfix does not work without read support\n"); fprintf(stderr, "pngfix does not work without read support\n");
return 77; return 77;
} }
#endif /* PNG_READ_SUPPORTED */ #endif /* PNG_READ_SUPPORTED && PNG_EASY_ACCESS_SUPPORTED */

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.7 - November 14, 2013 libpng version 1.6.8 - December 19, 2013
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-2013 Glenn Randers-Pehrson Copyright (c) 1998-2013 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.7 - November 14, 2013 libpng versions 0.97, January 1998, through 1.6.8 - December 19, 2013
Updated and distributed by Glenn Randers-Pehrson Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2013 Glenn Randers-Pehrson Copyright (c) 1998-2013 Glenn Randers-Pehrson
@ -4622,11 +4622,11 @@ XI. Changes to Libpng from version 1.4.x to 1.5.x
From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
function) incorrectly returned a value of type png_uint_32. function) incorrectly returned a value of type png_uint_32.
Checking for invalid palette index on read or write was added at libpng Checking for invalid palette index on write was added at libpng
1.5.10. When an invalid index is found, libpng issues a benign error. 1.5.10. If a pixel contains an invalid (out-of-range) index libpng issues
This is enabled by default because this condition is an error according a benign error. This is enabled by default because this condition is an
to the PNG specification, Clause 11.3.2, but the error can be ignored in error according to the PNG specification, Clause 11.3.2, but the error can
each png_ptr with be ignored in each png_ptr with
png_set_check_for_invalid_index(png_ptr, allowed); png_set_check_for_invalid_index(png_ptr, allowed);
@ -5051,18 +5051,19 @@ The machine-generated configure files are no longer included in branches
libpng16 and later of the GIT repository. They continue to be included libpng16 and later of the GIT repository. They continue to be included
in the tarball releases, however. in the tarball releases, however.
Libpng-1.6.0 and later use the CMF bytes at the beginning of the IDAT stream Libpng-1.6.0 through 1.6.2 used the CMF bytes at the beginning of the IDAT
to set the size of the sliding window for reading instead of using the default stream to set the size of the sliding window for reading instead of using the
32-kbyte sliding window size. It was discovered that there are hundreds of PNG default 32-kbyte sliding window size. It was discovered that there are
files in the wild that have incorrect CMF bytes that cause libpng to now issue hundreds of PNG files in the wild that have incorrect CMF bytes that caused
a "too far back" error and reject the file. Libpng-1.6.3 provides a way to libpng to issue a "too far back" error and reject the file. Libpng-1.6.3 and
revert to the libpng-1.5.x behavior (ignoring the CMF bytes and using a later calculate their own safe CMF from the image dimensions, provide a way
to revert to the libpng-1.5.x behavior (ignoring the CMF bytes and using a
32-kbyte sliding window), by using 32-kbyte sliding window), by using
png_set_option(png_ptr, PNG_MAXIMUM_INFLATE_WINDOW, png_set_option(png_ptr, PNG_MAXIMUM_INFLATE_WINDOW,
PNG_OPTION_ON); PNG_OPTION_ON);
and provides a tool (contrib/tools/pngfix) for optimizing the CMF bytes and provide a tool (contrib/tools/pngfix) for optimizing the CMF bytes
correctly. correctly.
Libpng-1.6.0 and libpng-1.6.1 wrote uncompressed iTXt chunks with the wrong Libpng-1.6.0 and libpng-1.6.1 wrote uncompressed iTXt chunks with the wrong
@ -5232,13 +5233,13 @@ Other rules can be inferred by inspecting the libpng source.
XVI. Y2K Compliance in libpng XVI. Y2K Compliance in libpng
November 14, 2013 December 19, 2013
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.7 are Y2K compliant. It is my belief that earlier upward through 1.6.8 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

View File

@ -1,6 +1,6 @@
.TH LIBPNG 3 "November 14, 2013" .TH LIBPNG 3 "December 19, 2013"
.SH NAME .SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.7 libpng \- Portable Network Graphics (PNG) Reference Library 1.6.8
.SH SYNOPSIS .SH SYNOPSIS
\fB \fB
#include <png.h>\fP #include <png.h>\fP
@ -504,7 +504,7 @@ Following is a copy of the libpng-manual.txt file that accompanies libpng.
.SH LIBPNG.TXT .SH LIBPNG.TXT
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.7 - November 14, 2013 libpng version 1.6.8 - December 19, 2013
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-2013 Glenn Randers-Pehrson Copyright (c) 1998-2013 Glenn Randers-Pehrson
@ -515,7 +515,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.7 - November 14, 2013 libpng versions 0.97, January 1998, through 1.6.8 - December 19, 2013
Updated and distributed by Glenn Randers-Pehrson Updated and distributed by Glenn Randers-Pehrson
Copyright (c) 1998-2013 Glenn Randers-Pehrson Copyright (c) 1998-2013 Glenn Randers-Pehrson
@ -5127,11 +5127,11 @@ We removed the trailing '.' from the warning and error messages.
From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the
function) incorrectly returned a value of type png_uint_32. function) incorrectly returned a value of type png_uint_32.
Checking for invalid palette index on read or write was added at libpng Checking for invalid palette index on write was added at libpng
1.5.10. When an invalid index is found, libpng issues a benign error. 1.5.10. If a pixel contains an invalid (out-of-range) index libpng issues
This is enabled by default because this condition is an error according a benign error. This is enabled by default because this condition is an
to the PNG specification, Clause 11.3.2, but the error can be ignored in error according to the PNG specification, Clause 11.3.2, but the error can
each png_ptr with be ignored in each png_ptr with
png_set_check_for_invalid_index(png_ptr, allowed); png_set_check_for_invalid_index(png_ptr, allowed);
@ -5556,18 +5556,19 @@ The machine-generated configure files are no longer included in branches
libpng16 and later of the GIT repository. They continue to be included libpng16 and later of the GIT repository. They continue to be included
in the tarball releases, however. in the tarball releases, however.
Libpng-1.6.0 and later use the CMF bytes at the beginning of the IDAT stream Libpng-1.6.0 through 1.6.2 used the CMF bytes at the beginning of the IDAT
to set the size of the sliding window for reading instead of using the default stream to set the size of the sliding window for reading instead of using the
32-kbyte sliding window size. It was discovered that there are hundreds of PNG default 32-kbyte sliding window size. It was discovered that there are
files in the wild that have incorrect CMF bytes that cause libpng to now issue hundreds of PNG files in the wild that have incorrect CMF bytes that caused
a "too far back" error and reject the file. Libpng-1.6.3 provides a way to libpng to issue a "too far back" error and reject the file. Libpng-1.6.3 and
revert to the libpng-1.5.x behavior (ignoring the CMF bytes and using a later calculate their own safe CMF from the image dimensions, provide a way
to revert to the libpng-1.5.x behavior (ignoring the CMF bytes and using a
32-kbyte sliding window), by using 32-kbyte sliding window), by using
png_set_option(png_ptr, PNG_MAXIMUM_INFLATE_WINDOW, png_set_option(png_ptr, PNG_MAXIMUM_INFLATE_WINDOW,
PNG_OPTION_ON); PNG_OPTION_ON);
and provides a tool (contrib/tools/pngfix) for optimizing the CMF bytes and provide a tool (contrib/tools/pngfix) for optimizing the CMF bytes
correctly. correctly.
Libpng-1.6.0 and libpng-1.6.1 wrote uncompressed iTXt chunks with the wrong Libpng-1.6.0 and libpng-1.6.1 wrote uncompressed iTXt chunks with the wrong
@ -5737,13 +5738,13 @@ Other rules can be inferred by inspecting the libpng source.
.SH XVI. Y2K Compliance in libpng .SH XVI. Y2K Compliance in libpng
November 14, 2013 December 19, 2013
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.7 are Y2K compliant. It is my belief that earlier upward through 1.6.8 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
@ -5966,7 +5967,11 @@ the first widely used release:
1.6.5 16 10605 16.so.16.5[.0] 1.6.5 16 10605 16.so.16.5[.0]
1.6.6 16 10606 16.so.16.6[.0] 1.6.6 16 10606 16.so.16.6[.0]
1.6.7beta01-04 16 10607 16.so.16.7[.0] 1.6.7beta01-04 16 10607 16.so.16.7[.0]
1.6.7rc01-03 16 10607 16.so.16.7[.0] 1.6.7rc01-02 16 10607 16.so.16.7[.0]
1.6.7 16 10607 16.so.16.7[.0]
1.6.8beta01-02 16 10608 16.so.16.8[.0]
1.6.8rc01-02 16 10608 16.so.16.8[.0]
1.6.8 16 10608 16.so.16.8[.0]
Henceforth the source version will match the shared-library minor Henceforth the source version will match the shared-library minor
and patch numbers; the shared-library major version number will be and patch numbers; the shared-library major version number will be
@ -6023,7 +6028,7 @@ possible without all of you.
Thanks to Frank J. T. Wojcik for helping with the documentation. Thanks to Frank J. T. Wojcik for helping with the documentation.
Libpng version 1.6.7 - November 14, 2013: Libpng version 1.6.8 - December 19, 2013:
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc. Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net). Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net).
@ -6046,7 +6051,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.7, November 14, 2013, are libpng versions 1.2.6, August 15, 2004, through 1.6.8, December 19, 2013, are
Copyright (c) 2004,2006-2007 Glenn Randers-Pehrson, and are Copyright (c) 2004,2006-2007 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
@ -6145,7 +6150,7 @@ certification mark of the Open Source Initiative.
Glenn Randers-Pehrson Glenn Randers-Pehrson
glennrp at users.sourceforge.net glennrp at users.sourceforge.net
November 14, 2013 December 19, 2013
.\" end of man page .\" end of man page

View File

@ -1,6 +1,6 @@
.TH LIBPNGPF 3 "November 14, 2013" .TH LIBPNGPF 3 "December 19, 2013"
.SH NAME .SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.7 libpng \- Portable Network Graphics (PNG) Reference Library 1.6.8
(private functions) (private functions)
.SH SYNOPSIS .SH SYNOPSIS
\fB#include \fI"pngpriv.h" \fB#include \fI"pngpriv.h"

2
png.5
View File

@ -1,4 +1,4 @@
.TH PNG 5 "November 14, 2013" .TH PNG 5 "December 19, 2013"
.SH NAME .SH NAME
png \- Portable Network Graphics (PNG) format png \- Portable Network Graphics (PNG) format
.SH DESCRIPTION .SH DESCRIPTION

49
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.2 [April 25, 2013] * Last changed in libpng 1.6.8 [December 19, 2013]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson * Copyright (c) 1998-2013 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_7 Your_png_h_is_not_version_1_6_7; typedef png_libpng_version_1_6_8 Your_png_h_is_not_version_1_6_8;
/* 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
@ -201,6 +201,7 @@ png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver)
pos = png_safecat(m, (sizeof m), pos, user_png_ver); pos = png_safecat(m, (sizeof m), pos, user_png_ver);
pos = png_safecat(m, (sizeof m), pos, " but running with "); pos = png_safecat(m, (sizeof m), pos, " but running with ");
pos = png_safecat(m, (sizeof m), pos, png_libpng_ver); pos = png_safecat(m, (sizeof m), pos, png_libpng_ver);
PNG_UNUSED(pos)
png_warning(png_ptr, m); png_warning(png_ptr, m);
#endif #endif
@ -259,6 +260,10 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
*/ */
# ifdef PNG_USER_MEM_SUPPORTED # ifdef PNG_USER_MEM_SUPPORTED
png_set_mem_fn(&create_struct, mem_ptr, malloc_fn, free_fn); png_set_mem_fn(&create_struct, mem_ptr, malloc_fn, free_fn);
# else
PNG_UNUSED(mem_ptr)
PNG_UNUSED(malloc_fn)
PNG_UNUSED(free_fn)
# endif # endif
/* (*error_fn) can return control to the caller after the error_ptr is set, /* (*error_fn) can return control to the caller after the error_ptr is set,
@ -768,13 +773,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.7 - November 14, 2013" PNG_STRING_NEWLINE \ "libpng version 1.6.8 - December 19, 2013" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2013 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2013 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.7 - November 14, 2013\ return "libpng version 1.6.8 - December 19, 2013\
Copyright (c) 1998-2013 Glenn Randers-Pehrson\ Copyright (c) 1998-2013 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\ Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
@ -1722,6 +1727,7 @@ png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace,
# endif # endif
/* The 'reason' is an arbitrary message, allow +79 maximum 195 */ /* The 'reason' is an arbitrary message, allow +79 maximum 195 */
pos = png_safecat(message, (sizeof message), pos, reason); pos = png_safecat(message, (sizeof message), pos, reason);
PNG_UNUSED(pos)
/* This is recoverable, but make it unconditionally an app_error on write to /* This is recoverable, but make it unconditionally an app_error on write to
* avoid writing invalid ICC profiles into PNG files. (I.e. we handle them * avoid writing invalid ICC profiles into PNG files. (I.e. we handle them
@ -3091,11 +3097,15 @@ png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text)
if (r > 2147483647. || r < -2147483648.) if (r > 2147483647. || r < -2147483648.)
png_fixed_error(png_ptr, text); png_fixed_error(png_ptr, text);
# ifndef PNG_ERROR_TEXT_SUPPORTED
PNG_UNUSED(text)
# endif
return (png_fixed_point)r; return (png_fixed_point)r;
} }
#endif #endif
#if defined(PNG_READ_GAMMA_SUPPORTED) || \ #if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_COLORSPACE_SUPPORTED) ||\
defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED) defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED)
/* muldiv functions */ /* muldiv functions */
/* This API takes signed arguments and rounds the result to the nearest /* This API takes signed arguments and rounds the result to the nearest
@ -3268,27 +3278,29 @@ png_gamma_significant(png_fixed_point gamma_val)
#endif #endif
#ifdef PNG_READ_GAMMA_SUPPORTED #ifdef PNG_READ_GAMMA_SUPPORTED
# ifdef PNG_16BIT_SUPPORTED
/* A local convenience routine. */ /* A local convenience routine. */
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)
{ {
/* The required result is 1/a * 1/b; the following preserves accuracy. */ /* The required result is 1/a * 1/b; the following preserves accuracy. */
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED # ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
double r = a * 1E-5; double r = a * 1E-5;
r *= b; r *= b;
r = floor(r+.5); r = floor(r+.5);
if (r <= 2147483647. && r >= -2147483648.) if (r <= 2147483647. && r >= -2147483648.)
return (png_fixed_point)r; return (png_fixed_point)r;
#else # else
png_fixed_point res; png_fixed_point res;
if (png_muldiv(&res, a, b, 100000)) if (png_muldiv(&res, a, b, 100000))
return res; return res;
#endif # endif
return 0; /* overflow */ return 0; /* overflow */
} }
# endif /* 16BIT */
/* The inverse of the above. */ /* The inverse of the above. */
png_fixed_point png_fixed_point
@ -3593,6 +3605,7 @@ png_exp8bit(png_fixed_point lg2)
return (png_byte)((x + 0x7fffffU) >> 24); return (png_byte)((x + 0x7fffffU) >> 24);
} }
#ifdef PNG_16BIT_SUPPORTED
static png_uint_16 static png_uint_16
png_exp16bit(png_fixed_point lg2) png_exp16bit(png_fixed_point lg2)
{ {
@ -3603,6 +3616,7 @@ png_exp16bit(png_fixed_point lg2)
x -= x >> 16; x -= x >> 16;
return (png_uint_16)((x + 32767U) >> 16); return (png_uint_16)((x + 32767U) >> 16);
} }
#endif /* 16BIT */
#endif /* FLOATING_ARITHMETIC */ #endif /* FLOATING_ARITHMETIC */
png_byte png_byte
@ -3628,6 +3642,7 @@ png_gamma_8bit_correct(unsigned int value, png_fixed_point gamma_val)
return (png_byte)value; return (png_byte)value;
} }
#ifdef PNG_16BIT_SUPPORTED
png_uint_16 png_uint_16
png_gamma_16bit_correct(unsigned int value, png_fixed_point gamma_val) png_gamma_16bit_correct(unsigned int value, png_fixed_point gamma_val)
{ {
@ -3650,6 +3665,7 @@ png_gamma_16bit_correct(unsigned int value, png_fixed_point gamma_val)
return (png_uint_16)value; return (png_uint_16)value;
} }
#endif /* 16BIT */
/* This does the right thing based on the bit_depth field of the /* This does the right thing based on the bit_depth field of the
* png_struct, interpreting values as 8-bit or 16-bit. While the result * png_struct, interpreting values as 8-bit or 16-bit. While the result
@ -3663,10 +3679,16 @@ png_gamma_correct(png_structrp png_ptr, unsigned int value,
if (png_ptr->bit_depth == 8) if (png_ptr->bit_depth == 8)
return png_gamma_8bit_correct(value, gamma_val); return png_gamma_8bit_correct(value, gamma_val);
#ifdef PNG_16BIT_SUPPORTED
else else
return png_gamma_16bit_correct(value, gamma_val); return png_gamma_16bit_correct(value, gamma_val);
#else
/* should not reach this */
return 0;
#endif /* 16BIT */
} }
#ifdef PNG_16BIT_SUPPORTED
/* Internal function to build a single 16-bit table - the table consists of /* Internal function to build a single 16-bit table - the table consists of
* 'num' 256 entry subtables, where 'num' is determined by 'shift' - the amount * 'num' 256 entry subtables, where 'num' is determined by 'shift' - the amount
* to shift the input values right (or 16-number_of_signifiant_bits). * to shift the input values right (or 16-number_of_signifiant_bits).
@ -3805,6 +3827,7 @@ png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable,
last++; last++;
} }
} }
#endif /* 16BIT */
/* Build a single 8-bit table: same as the 16-bit case but much simpler (and /* Build a single 8-bit table: same as the 16-bit case but much simpler (and
* typically much faster). Note that libpng currently does no sBIT processing * typically much faster). Note that libpng currently does no sBIT processing
@ -3833,6 +3856,7 @@ 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;
#ifdef PNG_16BIT_SUPPORTED
if (png_ptr->gamma_16_table != NULL) if (png_ptr->gamma_16_table != NULL)
{ {
int i; int i;
@ -3844,6 +3868,7 @@ png_destroy_gamma_table(png_structrp png_ptr)
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;
} }
#endif /* 16BIT */
#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \ #if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \ defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
@ -3853,6 +3878,7 @@ 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;
#ifdef PNG_16BIT_SUPPORTED
if (png_ptr->gamma_16_from_1 != NULL) if (png_ptr->gamma_16_from_1 != NULL)
{ {
int i; int i;
@ -3875,6 +3901,7 @@ png_destroy_gamma_table(png_structrp png_ptr)
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 /* 16BIT */
#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ #endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
} }
@ -3920,6 +3947,7 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth)
} }
#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ #endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
} }
#ifdef PNG_16BIT_SUPPORTED
else else
{ {
png_byte shift, sig_bit; png_byte shift, sig_bit;
@ -3976,24 +4004,20 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth)
png_ptr->gamma_shift = shift; png_ptr->gamma_shift = shift;
#ifdef PNG_16BIT_SUPPORTED
/* NOTE: prior to 1.5.4 this test used to include PNG_BACKGROUND (now /* NOTE: prior to 1.5.4 this test used to include PNG_BACKGROUND (now
* PNG_COMPOSE). This effectively smashed the background calculation for * PNG_COMPOSE). This effectively smashed the background calculation for
* 16-bit output because the 8-bit table assumes the result will be reduced * 16-bit output because the 8-bit table assumes the result will be reduced
* to 8 bits. * to 8 bits.
*/ */
if (png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) 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_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 > 0 ? png_product2(png_ptr->colorspace.gamma,
png_ptr->screen_gamma) : PNG_FP_1); png_ptr->screen_gamma) : PNG_FP_1);
#ifdef PNG_16BIT_SUPPORTED
else else
png_build_16bit_table(png_ptr, &png_ptr->gamma_16_table, shift, 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 > 0 ? png_reciprocal2(png_ptr->colorspace.gamma,
png_ptr->screen_gamma) : PNG_FP_1); 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) || \
@ -4013,6 +4037,7 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth)
} }
#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */ #endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
} }
#endif /* 16BIT */
} }
#endif /* READ_GAMMA */ #endif /* READ_GAMMA */

24
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.7 - November 14, 2013 * libpng version 1.6.8 - December 19, 2013
* Copyright (c) 1998-2013 Glenn Randers-Pehrson * Copyright (c) 1998-2013 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.7 - November 14, 2013: Glenn * libpng versions 0.97, January 1998, through 1.6.8 - December 19, 2013: Glenn
* See also "Contributing Authors", below. * See also "Contributing Authors", below.
* *
* Note about libpng version numbers: * Note about libpng version numbers:
@ -185,6 +185,10 @@
* 1.6.6 16 10606 16.so.16.6[.0] * 1.6.6 16 10606 16.so.16.6[.0]
* 1.6.7beta01-04 16 10607 16.so.16.7[.0] * 1.6.7beta01-04 16 10607 16.so.16.7[.0]
* 1.6.7rc01-03 16 10607 16.so.16.7[.0] * 1.6.7rc01-03 16 10607 16.so.16.7[.0]
* 1.6.7 16 10607 16.so.16.7[.0]
* 1.6.8beta01-02 16 10608 16.so.16.8[.0]
* 1.6.8rc01-02 16 10608 16.so.16.8[.0]
* 1.6.8 16 10608 16.so.16.8[.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
@ -216,7 +220,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.7, November 14, 2013, are * libpng versions 1.2.6, August 15, 2004, through 1.6.8, December 19, 2013, are
* Copyright (c) 2004, 2006-2013 Glenn Randers-Pehrson, and are * Copyright (c) 2004, 2006-2013 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:
@ -328,13 +332,13 @@
* Y2K compliance in libpng: * Y2K compliance in libpng:
* ========================= * =========================
* *
* November 14, 2013 * December 19, 2013
* *
* 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.7 are Y2K compliant. It is my belief that * upward through 1.6.8 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
@ -394,9 +398,9 @@
*/ */
/* 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.7" #define PNG_LIBPNG_VER_STRING "1.6.8"
#define PNG_HEADER_VERSION_STRING \ #define PNG_HEADER_VERSION_STRING \
" libpng version 1.6.7 - November 14, 2013\n" " libpng version 1.6.8 - December 19, 2013\n"
#define PNG_LIBPNG_VER_SONUM 16 #define PNG_LIBPNG_VER_SONUM 16
#define PNG_LIBPNG_VER_DLLNUM 16 #define PNG_LIBPNG_VER_DLLNUM 16
@ -404,7 +408,7 @@
/* 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 6
#define PNG_LIBPNG_VER_RELEASE 7 #define PNG_LIBPNG_VER_RELEASE 8
/* 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:
@ -435,7 +439,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 10607 /* 1.6.7 */ #define PNG_LIBPNG_VER 10608 /* 1.6.8 */
/* 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.
@ -540,7 +544,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_7; typedef char* png_libpng_version_1_6_8;
/* 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.
* *

View File

@ -1,7 +1,7 @@
/* pngconf.h - machine configurable file for libpng /* pngconf.h - machine configurable file for libpng
* *
* libpng version 1.6.7 - November 14, 2013 * libpng version 1.6.8 - December 19, 2013
* *
* Copyright (c) 1998-2013 Glenn Randers-Pehrson * Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)

View File

@ -1,11 +1,11 @@
/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c /* pngdebug.h - Debugging macros for libpng, also used in pngtest.c
* *
* Copyright (c) 1998-2011 Glenn Randers-Pehrson * Copyright (c) 1998-2013 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.)
* *
* Last changed in libpng 1.5.0 [January 6, 2011] * Last changed in libpng 1.6.8 [December 19, 2013]
* *
* 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
@ -25,7 +25,7 @@
* (actually ((void)0)). * (actually ((void)0)).
* *
* level: level of detail of message, starting at 0. A level 'n' * level: level of detail of message, starting at 0. A level 'n'
* message is preceded by 'n' tab characters (not implemented * message is preceded by 'n' 3-space indentations (not implemented
* on Microsoft compilers unless PNG_DEBUG_FILE is also * on Microsoft compilers unless PNG_DEBUG_FILE is also
* defined, to allow debug DLL compilation with no standard IO). * defined, to allow debug DLL compilation with no standard IO).
* message: a printf(3) style text string. A trailing '\n' is added * message: a printf(3) style text string. A trailing '\n' is added
@ -77,32 +77,29 @@
# endif /* PNG_DEBUG_FILE */ # endif /* PNG_DEBUG_FILE */
# if (PNG_DEBUG > 1) # if (PNG_DEBUG > 1)
/* Note: ["%s"m PNG_STRING_NEWLINE] probably does not work on
* non-ISO compilers
*/
# ifdef __STDC__ # ifdef __STDC__
# ifndef png_debug # ifndef png_debug
# define png_debug(l,m) \ # define png_debug(l,m) \
do { \ do { \
int num_tabs=l; \ int num_tabs=l; \
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":"")))); \ (num_tabs==2 ? " " : (num_tabs>2 ? " " : "")))); \
} while (0) } while (0)
# endif # endif
# ifndef png_debug1 # ifndef png_debug1
# define png_debug1(l,m,p1) \ # define png_debug1(l,m,p1) \
do { \ do { \
int num_tabs=l; \ int num_tabs=l; \
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1); \ (num_tabs==2 ? " " : (num_tabs>2 ? " " : ""))),p1); \
} while (0) } while (0)
# endif # endif
# ifndef png_debug2 # ifndef png_debug2
# define png_debug2(l,m,p1,p2) \ # define png_debug2(l,m,p1,p2) \
do { \ do { \
int num_tabs=l; \ int num_tabs=l; \
fprintf(PNG_DEBUG_FILE,"%s"m PNG_STRING_NEWLINE,(num_tabs==1 ? "\t" : \ fprintf(PNG_DEBUG_FILE,"%s" m PNG_STRING_NEWLINE,(num_tabs==1 ? " " : \
(num_tabs==2 ? "\t\t":(num_tabs>2 ? "\t\t\t":""))),p1,p2); \ (num_tabs==2 ? " " : (num_tabs>2 ? " " : ""))),p1,p2);\
} while (0) } while (0)
# endif # endif
# else /* __STDC __ */ # else /* __STDC __ */

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.1 [March 28, 2013] * Last changed in libpng 1.6.8 [December 19, 2013]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson * Copyright (c) 1998-2013 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.)
@ -382,6 +382,10 @@ png_benign_error(png_const_structrp png_ptr, png_const_charp error_message)
# endif # endif
png_error(png_ptr, error_message); png_error(png_ptr, error_message);
} }
# ifndef PNG_ERROR_TEXT_SUPPORTED
PNG_UNUSED(error_message)
# endif
} }
void /* PRIVATE */ void /* PRIVATE */
@ -391,6 +395,10 @@ png_app_warning(png_const_structrp png_ptr, png_const_charp error_message)
png_warning(png_ptr, error_message); png_warning(png_ptr, error_message);
else else
png_error(png_ptr, error_message); png_error(png_ptr, error_message);
# ifndef PNG_ERROR_TEXT_SUPPORTED
PNG_UNUSED(error_message)
# endif
} }
void /* PRIVATE */ void /* PRIVATE */
@ -400,6 +408,10 @@ png_app_error(png_const_structrp png_ptr, png_const_charp error_message)
png_warning(png_ptr, error_message); png_warning(png_ptr, error_message);
else else
png_error(png_ptr, error_message); png_error(png_ptr, error_message);
# ifndef PNG_ERROR_TEXT_SUPPORTED
PNG_UNUSED(error_message)
# endif
} }
#endif /* BENIGN_ERRORS */ #endif /* BENIGN_ERRORS */
@ -416,7 +428,8 @@ static PNG_CONST char png_digit[16] = {
}; };
#define PNG_MAX_ERROR_TEXT 196 /* Currently limited be profile_error in png.c */ #define PNG_MAX_ERROR_TEXT 196 /* Currently limited be profile_error in png.c */
#if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED) #if defined(PNG_WARNINGS_SUPPORTED) || \
(defined(PNG_READ_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED))
static void /* PRIVATE */ static void /* PRIVATE */
png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp
error_message) error_message)
@ -506,6 +519,10 @@ png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp
else else
png_chunk_error(png_ptr, error_message); png_chunk_error(png_ptr, error_message);
# ifndef PNG_ERROR_TEXT_SUPPORTED
PNG_UNUSED(error_message)
# endif
} }
#endif #endif
#endif /* PNG_READ_SUPPORTED */ #endif /* PNG_READ_SUPPORTED */
@ -513,6 +530,10 @@ png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp
void /* PRIVATE */ void /* PRIVATE */
png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error) png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error)
{ {
# ifndef PNG_WARNINGS_SUPPORTED
PNG_UNUSED(message)
# endif
/* This is always supported, but for just read or just write it /* This is always supported, but for just read or just write it
* unconditionally does the right thing. * unconditionally does the right thing.
*/ */

View File

@ -1,7 +1,7 @@
/* pngmem.c - stub functions for memory allocation /* pngmem.c - stub functions for memory allocation
* *
* Last changed in libpng 1.6.0 [February 14, 2013] * Last changed in libpng 1.6.8 [December 19, 2013]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson * Copyright (c) 1998-2013 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.)
@ -73,9 +73,10 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
* to implement a user memory handler. This checks to be sure it isn't * to implement a user memory handler. This checks to be sure it isn't
* called with big numbers. * called with big numbers.
*/ */
#ifdef PNG_USER_MEM_SUPPORTED #ifndef PNG_USER_MEM_SUPPORTED
PNG_UNUSED(png_ptr) PNG_UNUSED(png_ptr)
#endif #endif
if (size > 0 && size <= PNG_SIZE_MAX if (size > 0 && size <= PNG_SIZE_MAX
# ifdef PNG_MAX_MALLOC_64K # ifdef PNG_MAX_MALLOC_64K
&& size <= 65536U && size <= 65536U
@ -95,6 +96,8 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
return NULL; return NULL;
} }
#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\
defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED)
/* This is really here only to work round a spurious warning in GCC 4.6 and 4.7 /* This is really here only to work round a spurious warning in GCC 4.6 and 4.7
* that arises because of the checks in png_realloc_array that are repeated in * that arises because of the checks in png_realloc_array that are repeated in
* png_malloc_array. * png_malloc_array.
@ -156,6 +159,7 @@ png_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array,
return NULL; /* error */ return NULL; /* error */
} }
#endif /* TEXT || sPLT || STORE_UNKNOWN_CHUNKS */
/* Various functions that have different error handling are derived from this. /* Various functions that have different error handling are derived from this.
* png_malloc always exists, but if PNG_USER_MEM_SUPPORTED is defined a separate * png_malloc always exists, but if PNG_USER_MEM_SUPPORTED is defined a separate

View File

@ -1,7 +1,7 @@
/* pngpread.c - read a png file in push mode /* pngpread.c - read a png file in push mode
* *
* Last changed in libpng 1.6.0 [February 14, 2013] * Last changed in libpng 1.6.8 [December 19, 2013]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson * Copyright (c) 1998-2013 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.)
@ -285,8 +285,8 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
if (chunk_name == png_PLTE) if (chunk_name == png_PLTE)
png_ptr->mode |= PNG_HAVE_PLTE; png_ptr->mode |= PNG_HAVE_PLTE;
} }
#endif #endif
else if (chunk_name == png_PLTE) else if (chunk_name == png_PLTE)
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size) if (png_ptr->push_length + 4 > png_ptr->buffer_size)
@ -528,8 +528,8 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
png_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length); png_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
} }
#endif #endif
else else
{ {
if (png_ptr->push_length + 4 > png_ptr->buffer_size) if (png_ptr->push_length + 4 > png_ptr->buffer_size)

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.7 [November 14, 2013] * Last changed in libpng 1.6.8 [December 19, 2013]
* *
* 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
@ -112,9 +112,15 @@
* typically the target FPU. If the FPU has been set to NEON (-mfpu=neon * typically the target FPU. If the FPU has been set to NEON (-mfpu=neon
* with GCC) then the compiler will define __ARM_NEON__ and we can rely * with GCC) then the compiler will define __ARM_NEON__ and we can rely
* unconditionally on NEON instructions not crashing, otherwise we must * unconditionally on NEON instructions not crashing, otherwise we must
* disable use of NEON instructions: * disable use of NEON instructions.
*
* NOTE: at present these optimizations depend on 'ALIGNED_MEMORY', so they
* can only be turned on automatically if that is supported too. If
* PNG_ARM_NEON_OPT is set in CPPFLAGS (to >0) then arm/arm_init.c will fail
* to compile with an appropriate #error if ALIGNED_MEMORY has been turned
* off.
*/ */
# ifdef __ARM_NEON__ # if defined(__ARM_NEON__) && defined(PNG_ALIGNED_MEMORY_SUPPORTED)
# define PNG_ARM_NEON_OPT 2 # define PNG_ARM_NEON_OPT 2
# else # else
# define PNG_ARM_NEON_OPT 0 # define PNG_ARM_NEON_OPT 0
@ -1218,7 +1224,7 @@ PNG_INTERNAL_FUNCTION(void,png_read_finish_IDAT,(png_structrp png_ptr),
PNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr), PNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr),
PNG_EMPTY); PNG_EMPTY);
/* Finish a row while reading, dealing with interlacing passes, etc. */ /* Finish a row while reading, dealing with interlacing passes, etc. */
#endif #endif /* PNG_SEQUENTIAL_READ_SUPPORTED */
/* Initialize the row buffers, etc. */ /* Initialize the row buffers, etc. */
PNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY); PNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY);
@ -1464,7 +1470,6 @@ PNG_INTERNAL_FUNCTION(void,png_handle_zTXt,(png_structrp png_ptr,
PNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_structrp png_ptr, PNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_structrp png_ptr,
png_uint_32 chunk_name),PNG_EMPTY); png_uint_32 chunk_name),PNG_EMPTY);
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
PNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr, PNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr,
png_inforp info_ptr, png_uint_32 length, int keep),PNG_EMPTY); png_inforp info_ptr, png_uint_32 length, int keep),PNG_EMPTY);
/* This is the function that gets called for unknown chunks. The 'keep' /* This is the function that gets called for unknown chunks. The 'keep'
@ -1474,14 +1479,13 @@ PNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr,
*/ */
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) ||\ #if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) ||\
defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED) defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
PNG_INTERNAL_FUNCTION(int,png_chunk_unknown_handling, PNG_INTERNAL_FUNCTION(int,png_chunk_unknown_handling,
(png_const_structrp png_ptr, png_uint_32 chunk_name),PNG_EMPTY); (png_const_structrp png_ptr, png_uint_32 chunk_name),PNG_EMPTY);
/* Exactly as the API png_handle_as_unknown() except that the argument is a /* Exactly as the API png_handle_as_unknown() except that the argument is a
* 32-bit chunk name, not a string. * 32-bit chunk name, not a string.
*/ */
#endif /* READ_UNKNOWN_CHUNKS || HANDLE_AS_UNKNOWN */ #endif /* READ_UNKNOWN_CHUNKS || HANDLE_AS_UNKNOWN */
#endif /* PNG_SET_UNKNOWN_CHUNKS_SUPPORTED */
/* Handle the transformations for reading and writing */ /* Handle the transformations for reading and writing */
#ifdef PNG_READ_TRANSFORMS_SUPPORTED #ifdef PNG_READ_TRANSFORMS_SUPPORTED
@ -1900,7 +1904,7 @@ PNG_INTERNAL_FUNCTION(int,png_check_fp_string,(png_const_charp string,
png_size_t size),PNG_EMPTY); png_size_t size),PNG_EMPTY);
#endif /* pCAL || sCAL */ #endif /* pCAL || sCAL */
#if defined(PNG_READ_GAMMA_SUPPORTED) ||\ #if defined(PNG_GAMMA_SUPPORTED) ||\
defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED) defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED)
/* Added at libpng version 1.5.0 */ /* Added at libpng version 1.5.0 */
/* This is a utility to provide a*times/div (rounded) and indicate /* This is a utility to provide a*times/div (rounded) and indicate

206
pngread.c
View File

@ -1,7 +1,7 @@
/* pngread.c - read a PNG file /* pngread.c - read a PNG file
* *
* Last changed in libpng 1.6.1 [March 28, 2013] * Last changed in libpng 1.6.8 [December 19, 2013]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson * Copyright (c) 1998-2013 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.)
@ -1125,12 +1125,11 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
/* Arguments to png_image_finish_read: */ /* Arguments to png_image_finish_read: */
/* Encoding of PNG data (used by the color-map code) */ /* Encoding of PNG data (used by the color-map code) */
/* TODO: change these, dang, ANSI-C reserves the 'E' namespace. */ # define P_NOTSET 0 /* File encoding not yet known */
# define E_NOTSET 0 /* File encoding not yet known */ # define P_sRGB 1 /* 8-bit encoded to sRGB gamma */
# define E_sRGB 1 /* 8-bit encoded to sRGB gamma */ # define P_LINEAR 2 /* 16-bit linear: not encoded, NOT pre-multiplied! */
# define E_LINEAR 2 /* 16-bit linear: not encoded, NOT pre-multiplied! */ # define P_FILE 3 /* 8-bit encoded to file gamma, not sRGB or linear */
# define E_FILE 3 /* 8-bit encoded to file gamma, not sRGB or linear */ # define P_LINEAR8 4 /* 8-bit linear: only from a file value */
# define E_LINEAR8 4 /* 8-bit linear: only from a file value */
/* Color-map processing: after libpng has run on the PNG image further /* Color-map processing: after libpng has run on the PNG image further
* processing may be needed to conver the data to color-map indicies. * processing may be needed to conver the data to color-map indicies.
@ -1161,7 +1160,7 @@ typedef struct
png_voidp first_row; png_voidp first_row;
ptrdiff_t row_bytes; /* step between rows */ ptrdiff_t row_bytes; /* step between rows */
int file_encoding; /* E_ values above */ int file_encoding; /* E_ values above */
png_fixed_point gamma_to_linear; /* For E_FILE, reciprocal of gamma */ png_fixed_point gamma_to_linear; /* For P_FILE, reciprocal of gamma */
int colormap_processing; /* PNG_CMAP_ values above */ int colormap_processing; /* PNG_CMAP_ values above */
} png_image_read_control; } png_image_read_control;
@ -1293,7 +1292,7 @@ png_image_read_header(png_voidp argument)
#ifdef PNG_COLORSPACE_SUPPORTED #ifdef PNG_COLORSPACE_SUPPORTED
/* Does the colorspace match sRGB? If there is no color endpoint /* Does the colorspace match sRGB? If there is no color endpoint
* (colorant) information assume yes, otherwise require the * (colorant) information assume yes, otherwise require the
* 'ENDPOINTS_MATCHE_sRGB' colorspace flag to have been set. If the * 'ENDPOINTS_MATCHP_sRGB' colorspace flag to have been set. If the
* colorspace has been determined to be invalid ignore it. * colorspace has been determined to be invalid ignore it.
*/ */
if ((format & PNG_FORMAT_FLAG_COLOR) != 0 && ((png_ptr->colorspace.flags if ((format & PNG_FORMAT_FLAG_COLOR) != 0 && ((png_ptr->colorspace.flags
@ -1482,17 +1481,24 @@ png_image_skip_unused_chunks(png_structrp png_ptr)
* *
* Or image data handling: * Or image data handling:
* *
* tRNS, bKGD, gAMA, cHRM, sRGB, iCCP and sBIT. * tRNS, bKGD, gAMA, cHRM, sRGB, [iCCP] and sBIT.
* *
* This provides a small performance improvement and eliminates any * This provides a small performance improvement and eliminates any
* potential vulnerability to security problems in the unused chunks. * potential vulnerability to security problems in the unused chunks.
*
* At present the iCCP chunk data isn't used, so iCCP chunk can be ignored
* too. This allows the simplified API to be compiled without iCCP support,
* however if the support is there the chunk is still checked to detect
* errors (which are unfortunately quite common.)
*/ */
{ {
static PNG_CONST png_byte chunks_to_process[] = { static PNG_CONST png_byte chunks_to_process[] = {
98, 75, 71, 68, '\0', /* bKGD */ 98, 75, 71, 68, '\0', /* bKGD */
99, 72, 82, 77, '\0', /* cHRM */ 99, 72, 82, 77, '\0', /* cHRM */
103, 65, 77, 65, '\0', /* gAMA */ 103, 65, 77, 65, '\0', /* gAMA */
# ifdef PNG_READ_iCCP_SUPPORTED
105, 67, 67, 80, '\0', /* iCCP */ 105, 67, 67, 80, '\0', /* iCCP */
# endif
115, 66, 73, 84, '\0', /* sBIT */ 115, 66, 73, 84, '\0', /* sBIT */
115, 82, 71, 66, '\0', /* sRGB */ 115, 82, 71, 66, '\0', /* sRGB */
}; };
@ -1529,25 +1535,25 @@ set_file_encoding(png_image_read_control *display)
{ {
if (png_gamma_not_sRGB(g)) if (png_gamma_not_sRGB(g))
{ {
display->file_encoding = E_FILE; display->file_encoding = P_FILE;
display->gamma_to_linear = png_reciprocal(g); display->gamma_to_linear = png_reciprocal(g);
} }
else else
display->file_encoding = E_sRGB; display->file_encoding = P_sRGB;
} }
else else
display->file_encoding = E_LINEAR8; display->file_encoding = P_LINEAR8;
} }
static unsigned int static unsigned int
decode_gamma(png_image_read_control *display, png_uint_32 value, int encoding) decode_gamma(png_image_read_control *display, png_uint_32 value, int encoding)
{ {
if (encoding == E_FILE) /* double check */ if (encoding == P_FILE) /* double check */
encoding = display->file_encoding; encoding = display->file_encoding;
if (encoding == E_NOTSET) /* must be the file encoding */ if (encoding == P_NOTSET) /* must be the file encoding */
{ {
set_file_encoding(display); set_file_encoding(display);
encoding = display->file_encoding; encoding = display->file_encoding;
@ -1555,18 +1561,18 @@ decode_gamma(png_image_read_control *display, png_uint_32 value, int encoding)
switch (encoding) switch (encoding)
{ {
case E_FILE: case P_FILE:
value = png_gamma_16bit_correct(value*257, display->gamma_to_linear); value = png_gamma_16bit_correct(value*257, display->gamma_to_linear);
break; break;
case E_sRGB: case P_sRGB:
value = png_sRGB_table[value]; value = png_sRGB_table[value];
break; break;
case E_LINEAR: case P_LINEAR:
break; break;
case E_LINEAR8: case P_LINEAR8:
value *= 257; value *= 257;
break; break;
@ -1585,9 +1591,9 @@ png_colormap_compose(png_image_read_control *display,
png_uint_32 background, int encoding) png_uint_32 background, int encoding)
{ {
/* The file value is composed on the background, the background has the given /* The file value is composed on the background, the background has the given
* encoding and so does the result, the file is encoded with E_FILE and the * encoding and so does the result, the file is encoded with P_FILE and the
* file and alpha are 8-bit values. The (output) encoding will always be * file and alpha are 8-bit values. The (output) encoding will always be
* E_LINEAR or E_sRGB. * P_LINEAR or P_sRGB.
*/ */
png_uint_32 f = decode_gamma(display, foreground, foreground_encoding); png_uint_32 f = decode_gamma(display, foreground, foreground_encoding);
png_uint_32 b = decode_gamma(display, background, encoding); png_uint_32 b = decode_gamma(display, background, encoding);
@ -1597,7 +1603,7 @@ png_colormap_compose(png_image_read_control *display,
*/ */
f = f * alpha + b * (255-alpha); f = f * alpha + b * (255-alpha);
if (encoding == E_LINEAR) if (encoding == P_LINEAR)
{ {
/* Scale to 65535; divide by 255, approximately (in fact this is extremely /* Scale to 65535; divide by 255, approximately (in fact this is extremely
* accurate, it divides by 255.00000005937181414556, with no overflow.) * accurate, it divides by 255.00000005937181414556, with no overflow.)
@ -1607,13 +1613,13 @@ png_colormap_compose(png_image_read_control *display,
f = (f+32768) >> 16; f = (f+32768) >> 16;
} }
else /* E_sRGB */ else /* P_sRGB */
f = PNG_sRGB_FROM_LINEAR(f); f = PNG_sRGB_FROM_LINEAR(f);
return f; return f;
} }
/* NOTE: E_LINEAR values to this routine must be 16-bit, but E_FILE values must /* NOTE: P_LINEAR values to this routine must be 16-bit, but P_FILE values must
* be 8-bit. * be 8-bit.
*/ */
static void static void
@ -1623,7 +1629,7 @@ png_create_colormap_entry(png_image_read_control *display,
{ {
png_imagep image = display->image; png_imagep image = display->image;
const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) ? const int output_encoding = (image->format & PNG_FORMAT_FLAG_LINEAR) ?
E_LINEAR : E_sRGB; P_LINEAR : P_sRGB;
const int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 && const int convert_to_Y = (image->format & PNG_FORMAT_FLAG_COLOR) == 0 &&
(red != green || green != blue); (red != green || green != blue);
@ -1633,18 +1639,18 @@ png_create_colormap_entry(png_image_read_control *display,
/* Update the cache with whether the file gamma is significantly different /* Update the cache with whether the file gamma is significantly different
* from sRGB. * from sRGB.
*/ */
if (encoding == E_FILE) if (encoding == P_FILE)
{ {
if (display->file_encoding == E_NOTSET) if (display->file_encoding == P_NOTSET)
set_file_encoding(display); set_file_encoding(display);
/* Note that the cached value may be E_FILE too, but if it is then the /* Note that the cached value may be P_FILE too, but if it is then the
* gamma_to_linear member has been set. * gamma_to_linear member has been set.
*/ */
encoding = display->file_encoding; encoding = display->file_encoding;
} }
if (encoding == E_FILE) if (encoding == P_FILE)
{ {
png_fixed_point g = display->gamma_to_linear; png_fixed_point g = display->gamma_to_linear;
@ -1652,10 +1658,10 @@ png_create_colormap_entry(png_image_read_control *display,
green = png_gamma_16bit_correct(green*257, g); green = png_gamma_16bit_correct(green*257, g);
blue = png_gamma_16bit_correct(blue*257, g); blue = png_gamma_16bit_correct(blue*257, g);
if (convert_to_Y || output_encoding == E_LINEAR) if (convert_to_Y || output_encoding == P_LINEAR)
{ {
alpha *= 257; alpha *= 257;
encoding = E_LINEAR; encoding = P_LINEAR;
} }
else else
@ -1663,11 +1669,11 @@ png_create_colormap_entry(png_image_read_control *display,
red = PNG_sRGB_FROM_LINEAR(red * 255); red = PNG_sRGB_FROM_LINEAR(red * 255);
green = PNG_sRGB_FROM_LINEAR(green * 255); green = PNG_sRGB_FROM_LINEAR(green * 255);
blue = PNG_sRGB_FROM_LINEAR(blue * 255); blue = PNG_sRGB_FROM_LINEAR(blue * 255);
encoding = E_sRGB; encoding = P_sRGB;
} }
} }
else if (encoding == E_LINEAR8) else if (encoding == P_LINEAR8)
{ {
/* This encoding occurs quite frequently in test cases because PngSuite /* This encoding occurs quite frequently in test cases because PngSuite
* includes a gAMA 1.0 chunk with most images. * includes a gAMA 1.0 chunk with most images.
@ -1676,10 +1682,10 @@ png_create_colormap_entry(png_image_read_control *display,
green *= 257; green *= 257;
blue *= 257; blue *= 257;
alpha *= 257; alpha *= 257;
encoding = E_LINEAR; encoding = P_LINEAR;
} }
else if (encoding == E_sRGB && (convert_to_Y || output_encoding == E_LINEAR)) else if (encoding == P_sRGB && (convert_to_Y || output_encoding == P_LINEAR))
{ {
/* The values are 8-bit sRGB values, but must be converted to 16-bit /* The values are 8-bit sRGB values, but must be converted to 16-bit
* linear. * linear.
@ -1688,11 +1694,11 @@ png_create_colormap_entry(png_image_read_control *display,
green = png_sRGB_table[green]; green = png_sRGB_table[green];
blue = png_sRGB_table[blue]; blue = png_sRGB_table[blue];
alpha *= 257; alpha *= 257;
encoding = E_LINEAR; encoding = P_LINEAR;
} }
/* This is set if the color isn't gray but the output is. */ /* This is set if the color isn't gray but the output is. */
if (encoding == E_LINEAR) if (encoding == P_LINEAR)
{ {
if (convert_to_Y) if (convert_to_Y)
{ {
@ -1700,7 +1706,7 @@ png_create_colormap_entry(png_image_read_control *display,
png_uint_32 y = (png_uint_32)6968 * red + (png_uint_32)23434 * green + png_uint_32 y = (png_uint_32)6968 * red + (png_uint_32)23434 * green +
(png_uint_32)2366 * blue; (png_uint_32)2366 * blue;
if (output_encoding == E_LINEAR) if (output_encoding == P_LINEAR)
y = (y + 16384) >> 15; y = (y + 16384) >> 15;
else else
@ -1709,19 +1715,19 @@ png_create_colormap_entry(png_image_read_control *display,
y = (y + 128) >> 8; y = (y + 128) >> 8;
y *= 255; y *= 255;
y = PNG_sRGB_FROM_LINEAR((y + 64) >> 7); y = PNG_sRGB_FROM_LINEAR((y + 64) >> 7);
encoding = E_sRGB; encoding = P_sRGB;
} }
blue = red = green = y; blue = red = green = y;
} }
else if (output_encoding == E_sRGB) else if (output_encoding == P_sRGB)
{ {
red = PNG_sRGB_FROM_LINEAR(red * 255); red = PNG_sRGB_FROM_LINEAR(red * 255);
green = PNG_sRGB_FROM_LINEAR(green * 255); green = PNG_sRGB_FROM_LINEAR(green * 255);
blue = PNG_sRGB_FROM_LINEAR(blue * 255); blue = PNG_sRGB_FROM_LINEAR(blue * 255);
alpha = PNG_DIV257(alpha); alpha = PNG_DIV257(alpha);
encoding = E_sRGB; encoding = P_sRGB;
} }
} }
@ -1730,7 +1736,7 @@ png_create_colormap_entry(png_image_read_control *display,
/* Store the value. */ /* Store the value. */
{ {
# ifdef PNG_FORMAT_BGR_SUPPORTED # ifdef PNG_FORMAT_AFIRST_SUPPORTED
const int afirst = (image->format & PNG_FORMAT_FLAG_AFIRST) != 0 && const int afirst = (image->format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
(image->format & PNG_FORMAT_FLAG_ALPHA) != 0; (image->format & PNG_FORMAT_FLAG_ALPHA) != 0;
# else # else
@ -1742,7 +1748,7 @@ png_create_colormap_entry(png_image_read_control *display,
# define bgr 0 # define bgr 0
# endif # endif
if (output_encoding == E_LINEAR) if (output_encoding == P_LINEAR)
{ {
png_uint_16p entry = png_voidcast(png_uint_16p, display->colormap); png_uint_16p entry = png_voidcast(png_uint_16p, display->colormap);
@ -1797,7 +1803,7 @@ png_create_colormap_entry(png_image_read_control *display,
} }
} }
else /* output encoding is E_sRGB */ else /* output encoding is P_sRGB */
{ {
png_bytep entry = png_voidcast(png_bytep, display->colormap); png_bytep entry = png_voidcast(png_bytep, display->colormap);
@ -1839,7 +1845,7 @@ make_gray_file_colormap(png_image_read_control *display)
unsigned int i; unsigned int i;
for (i=0; i<256; ++i) for (i=0; i<256; ++i)
png_create_colormap_entry(display, i, i, i, i, 255, E_FILE); png_create_colormap_entry(display, i, i, i, i, 255, P_FILE);
return i; return i;
} }
@ -1850,7 +1856,7 @@ make_gray_colormap(png_image_read_control *display)
unsigned int i; unsigned int i;
for (i=0; i<256; ++i) for (i=0; i<256; ++i)
png_create_colormap_entry(display, i, i, i, i, 255, E_sRGB); png_create_colormap_entry(display, i, i, i, i, 255, P_sRGB);
return i; return i;
} }
@ -1889,13 +1895,13 @@ make_ga_colormap(png_image_read_control *display)
while (i < 231) while (i < 231)
{ {
unsigned int gray = (i * 256 + 115) / 231; unsigned int gray = (i * 256 + 115) / 231;
png_create_colormap_entry(display, i++, gray, gray, gray, 255, E_sRGB); png_create_colormap_entry(display, i++, gray, gray, gray, 255, P_sRGB);
} }
/* 255 is used here for the component values for consistency with the code /* 255 is used here for the component values for consistency with the code
* that undoes premultiplication in pngwrite.c. * that undoes premultiplication in pngwrite.c.
*/ */
png_create_colormap_entry(display, i++, 255, 255, 255, 0, E_sRGB); png_create_colormap_entry(display, i++, 255, 255, 255, 0, P_sRGB);
for (a=1; a<5; ++a) for (a=1; a<5; ++a)
{ {
@ -1903,7 +1909,7 @@ make_ga_colormap(png_image_read_control *display)
for (g=0; g<6; ++g) for (g=0; g<6; ++g)
png_create_colormap_entry(display, i++, g*51, g*51, g*51, a*51, png_create_colormap_entry(display, i++, g*51, g*51, g*51, a*51,
E_sRGB); P_sRGB);
} }
return i; return i;
@ -1927,7 +1933,7 @@ make_rgb_colormap(png_image_read_control *display)
for (b=0; b<6; ++b) for (b=0; b<6; ++b)
png_create_colormap_entry(display, i++, r*51, g*51, b*51, 255, png_create_colormap_entry(display, i++, r*51, g*51, b*51, 255,
E_sRGB); P_sRGB);
} }
} }
@ -1950,11 +1956,11 @@ png_image_read_colormap(png_voidp argument)
const png_structrp png_ptr = image->opaque->png_ptr; const png_structrp png_ptr = image->opaque->png_ptr;
const png_uint_32 output_format = image->format; const png_uint_32 output_format = image->format;
const int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) ? const int output_encoding = (output_format & PNG_FORMAT_FLAG_LINEAR) ?
E_LINEAR : E_sRGB; P_LINEAR : P_sRGB;
unsigned int cmap_entries; unsigned int cmap_entries;
unsigned int output_processing; /* Output processing option */ unsigned int output_processing; /* Output processing option */
unsigned int data_encoding = E_NOTSET; /* Encoding libpng must produce */ unsigned int data_encoding = P_NOTSET; /* Encoding libpng must produce */
/* Background information; the background color and the index of this color /* Background information; the background color and the index of this color
* in the color-map if it exists (else 256). * in the color-map if it exists (else 256).
@ -1974,7 +1980,7 @@ png_image_read_colormap(png_voidp argument)
png_ptr->num_trans > 0) /* alpha in input */ && png_ptr->num_trans > 0) /* alpha in input */ &&
((output_format & PNG_FORMAT_FLAG_ALPHA) == 0) /* no alpha in output */) ((output_format & PNG_FORMAT_FLAG_ALPHA) == 0) /* no alpha in output */)
{ {
if (output_encoding == E_LINEAR) /* compose on black */ if (output_encoding == P_LINEAR) /* compose on black */
back_b = back_g = back_r = 0; back_b = back_g = back_r = 0;
else if (display->background == NULL /* no way to remove it */) else if (display->background == NULL /* no way to remove it */)
@ -1998,7 +2004,7 @@ png_image_read_colormap(png_voidp argument)
} }
} }
else if (output_encoding == E_LINEAR) else if (output_encoding == P_LINEAR)
back_b = back_r = back_g = 65535; back_b = back_r = back_g = 65535;
else else
@ -2056,7 +2062,7 @@ png_image_read_colormap(png_voidp argument)
trans = png_ptr->trans_color.gray; trans = png_ptr->trans_color.gray;
if ((output_format & PNG_FORMAT_FLAG_ALPHA) == 0) if ((output_format & PNG_FORMAT_FLAG_ALPHA) == 0)
back_alpha = output_encoding == E_LINEAR ? 65535 : 255; back_alpha = output_encoding == P_LINEAR ? 65535 : 255;
} }
/* png_create_colormap_entry just takes an RGBA and writes the /* png_create_colormap_entry just takes an RGBA and writes the
@ -2074,7 +2080,7 @@ png_image_read_colormap(png_voidp argument)
*/ */
if (i != trans) if (i != trans)
png_create_colormap_entry(display, i, val, val, val, 255, png_create_colormap_entry(display, i, val, val, val, 255,
E_FILE/*8-bit with file gamma*/); P_FILE/*8-bit with file gamma*/);
/* Else this entry is transparent. The colors don't matter if /* Else this entry is transparent. The colors don't matter if
* there is an alpha channel (back_alpha == 0), but it does no * there is an alpha channel (back_alpha == 0), but it does no
@ -2090,7 +2096,7 @@ png_image_read_colormap(png_voidp argument)
} }
/* We need libpng to preserve the original encoding. */ /* We need libpng to preserve the original encoding. */
data_encoding = E_FILE; data_encoding = P_FILE;
/* The rows from libpng, while technically gray values, are now also /* The rows from libpng, while technically gray values, are now also
* color-map indicies; however, they may need to be expanded to 1 * color-map indicies; however, they may need to be expanded to 1
@ -2119,7 +2125,7 @@ png_image_read_colormap(png_voidp argument)
* ensuring that the corresponding gray level matches the background * ensuring that the corresponding gray level matches the background
* color exactly. * color exactly.
*/ */
data_encoding = E_sRGB; data_encoding = P_sRGB;
if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries) if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries)
png_error(png_ptr, "gray[16] color-map: too few entries"); png_error(png_ptr, "gray[16] color-map: too few entries");
@ -2143,7 +2149,7 @@ png_image_read_colormap(png_voidp argument)
png_color_16 c; png_color_16 c;
png_uint_32 gray = back_g; png_uint_32 gray = back_g;
if (output_encoding == E_LINEAR) if (output_encoding == P_LINEAR)
{ {
gray = PNG_sRGB_FROM_LINEAR(gray * 255); gray = PNG_sRGB_FROM_LINEAR(gray * 255);
@ -2151,7 +2157,7 @@ png_image_read_colormap(png_voidp argument)
* matches. * matches.
*/ */
png_create_colormap_entry(display, gray, back_g, back_g, png_create_colormap_entry(display, gray, back_g, back_g,
back_g, 65535, E_LINEAR); back_g, 65535, P_LINEAR);
} }
/* The background passed to libpng, however, must be the /* The background passed to libpng, however, must be the
@ -2172,7 +2178,7 @@ png_image_read_colormap(png_voidp argument)
break; break;
} }
back_alpha = output_encoding == E_LINEAR ? 65535 : 255; back_alpha = output_encoding == P_LINEAR ? 65535 : 255;
} }
/* output_processing means that the libpng-processed row will be /* output_processing means that the libpng-processed row will be
@ -2209,7 +2215,7 @@ png_image_read_colormap(png_voidp argument)
* worry about tRNS matching - tRNS is ignored if there is an alpha * worry about tRNS matching - tRNS is ignored if there is an alpha
* channel. * channel.
*/ */
data_encoding = E_sRGB; data_encoding = P_sRGB;
if (output_format & PNG_FORMAT_FLAG_ALPHA) if (output_format & PNG_FORMAT_FLAG_ALPHA)
{ {
@ -2252,13 +2258,13 @@ png_image_read_colormap(png_voidp argument)
cmap_entries = make_gray_colormap(display); cmap_entries = make_gray_colormap(display);
if (output_encoding == E_LINEAR) if (output_encoding == P_LINEAR)
{ {
gray = PNG_sRGB_FROM_LINEAR(gray * 255); gray = PNG_sRGB_FROM_LINEAR(gray * 255);
/* And make sure the corresponding palette entry matches. */ /* And make sure the corresponding palette entry matches. */
png_create_colormap_entry(display, gray, back_g, back_g, png_create_colormap_entry(display, gray, back_g, back_g,
back_g, 65535, E_LINEAR); back_g, 65535, P_LINEAR);
} }
/* The background passed to libpng, however, must be the sRGB /* The background passed to libpng, however, must be the sRGB
@ -2289,7 +2295,7 @@ png_image_read_colormap(png_voidp argument)
{ {
png_uint_32 gray = (i * 256 + 115) / 231; png_uint_32 gray = (i * 256 + 115) / 231;
png_create_colormap_entry(display, i++, gray, gray, gray, png_create_colormap_entry(display, i++, gray, gray, gray,
255, E_sRGB); 255, P_sRGB);
} }
/* NOTE: this preserves the full precision of the application /* NOTE: this preserves the full precision of the application
@ -2297,7 +2303,7 @@ png_image_read_colormap(png_voidp argument)
*/ */
background_index = i; background_index = i;
png_create_colormap_entry(display, i++, back_r, back_g, back_b, png_create_colormap_entry(display, i++, back_r, back_g, back_b,
output_encoding == E_LINEAR ? 65535U : 255U, output_encoding); output_encoding == P_LINEAR ? 65535U : 255U, output_encoding);
/* For non-opaque input composite on the sRGB background - this /* For non-opaque input composite on the sRGB background - this
* requires inverting the encoding for each component. The input * requires inverting the encoding for each component. The input
@ -2307,7 +2313,7 @@ png_image_read_colormap(png_voidp argument)
* represents. Consequently 'G' is always sRGB encoded, while * represents. Consequently 'G' is always sRGB encoded, while
* 'A' is linear. We need the linear background colors. * 'A' is linear. We need the linear background colors.
*/ */
if (output_encoding == E_sRGB) /* else already linear */ if (output_encoding == P_sRGB) /* else already linear */
{ {
/* This may produce a value not exactly matching the /* This may produce a value not exactly matching the
* background, but that's ok because these numbers are only * background, but that's ok because these numbers are only
@ -2337,7 +2343,7 @@ png_image_read_colormap(png_voidp argument)
png_create_colormap_entry(display, i++, png_create_colormap_entry(display, i++,
PNG_sRGB_FROM_LINEAR(gray + back_rx), PNG_sRGB_FROM_LINEAR(gray + back_rx),
PNG_sRGB_FROM_LINEAR(gray + back_gx), PNG_sRGB_FROM_LINEAR(gray + back_gx),
PNG_sRGB_FROM_LINEAR(gray + back_bx), 255, E_sRGB); PNG_sRGB_FROM_LINEAR(gray + back_bx), 255, P_sRGB);
} }
} }
@ -2364,7 +2370,7 @@ png_image_read_colormap(png_voidp argument)
*/ */
png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE, -1, png_set_rgb_to_gray_fixed(png_ptr, PNG_ERROR_ACTION_NONE, -1,
-1); -1);
data_encoding = E_sRGB; data_encoding = P_sRGB;
/* The output will now be one or two 8-bit gray or gray+alpha /* The output will now be one or two 8-bit gray or gray+alpha
* channels. The more complex case arises when the input has alpha. * channels. The more complex case arises when the input has alpha.
@ -2409,7 +2415,7 @@ png_image_read_colormap(png_voidp argument)
png_gamma_not_sRGB(png_ptr->colorspace.gamma)) png_gamma_not_sRGB(png_ptr->colorspace.gamma))
{ {
cmap_entries = make_gray_file_colormap(display); cmap_entries = make_gray_file_colormap(display);
data_encoding = E_FILE; data_encoding = P_FILE;
} }
else else
@ -2428,18 +2434,18 @@ png_image_read_colormap(png_voidp argument)
* it. Achieve this simply by ensuring that the entry * it. Achieve this simply by ensuring that the entry
* selected for the background really is the background color. * selected for the background really is the background color.
*/ */
if (data_encoding == E_FILE) /* from the fixup above */ if (data_encoding == P_FILE) /* from the fixup above */
{ {
/* The app supplied a gray which is in output_encoding, we /* The app supplied a gray which is in output_encoding, we
* need to convert it to a value of the input (E_FILE) * need to convert it to a value of the input (P_FILE)
* encoding then set this palette entry to the required * encoding then set this palette entry to the required
* output encoding. * output encoding.
*/ */
if (output_encoding == E_sRGB) if (output_encoding == P_sRGB)
gray = png_sRGB_table[gray]; /* now E_LINEAR */ gray = png_sRGB_table[gray]; /* now P_LINEAR */
gray = PNG_DIV257(png_gamma_16bit_correct(gray, gray = PNG_DIV257(png_gamma_16bit_correct(gray,
png_ptr->colorspace.gamma)); /* now E_FILE */ png_ptr->colorspace.gamma)); /* now P_FILE */
/* And make sure the corresponding palette entry contains /* And make sure the corresponding palette entry contains
* exactly the required sRGB value. * exactly the required sRGB value.
@ -2448,14 +2454,14 @@ png_image_read_colormap(png_voidp argument)
back_g, 0/*unused*/, output_encoding); back_g, 0/*unused*/, output_encoding);
} }
else if (output_encoding == E_LINEAR) else if (output_encoding == P_LINEAR)
{ {
gray = PNG_sRGB_FROM_LINEAR(gray * 255); gray = PNG_sRGB_FROM_LINEAR(gray * 255);
/* And make sure the corresponding palette entry matches. /* And make sure the corresponding palette entry matches.
*/ */
png_create_colormap_entry(display, gray, back_g, back_g, png_create_colormap_entry(display, gray, back_g, back_g,
back_g, 0/*unused*/, E_LINEAR); back_g, 0/*unused*/, P_LINEAR);
} }
/* The background passed to libpng, however, must be the /* The background passed to libpng, however, must be the
@ -2485,7 +2491,7 @@ png_image_read_colormap(png_voidp argument)
* to do it once and using PNG_DIV51 on the 6x6x6 reduced RGB cube. * to do it once and using PNG_DIV51 on the 6x6x6 reduced RGB cube.
* Consequently we always want libpng to produce sRGB data. * Consequently we always want libpng to produce sRGB data.
*/ */
data_encoding = E_sRGB; data_encoding = P_sRGB;
/* Is there any transparency or alpha? */ /* Is there any transparency or alpha? */
if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA || if (png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
@ -2505,7 +2511,7 @@ png_image_read_colormap(png_voidp argument)
/* Add a transparent entry. */ /* Add a transparent entry. */
png_create_colormap_entry(display, cmap_entries, 255, 255, png_create_colormap_entry(display, cmap_entries, 255, 255,
255, 0, E_sRGB); 255, 0, P_sRGB);
/* This is stored as the background index for the processing /* This is stored as the background index for the processing
* algorithm. * algorithm.
@ -2526,7 +2532,7 @@ png_image_read_colormap(png_voidp argument)
*/ */
for (b=0; b<256; b = (b << 1) | 0x7f) for (b=0; b<256; b = (b << 1) | 0x7f)
png_create_colormap_entry(display, cmap_entries++, png_create_colormap_entry(display, cmap_entries++,
r, g, b, 128, E_sRGB); r, g, b, 128, P_sRGB);
} }
} }
@ -2555,7 +2561,7 @@ png_image_read_colormap(png_voidp argument)
png_create_colormap_entry(display, cmap_entries, back_r, png_create_colormap_entry(display, cmap_entries, back_r,
back_g, back_b, 0/*unused*/, output_encoding); back_g, back_b, 0/*unused*/, output_encoding);
if (output_encoding == E_LINEAR) if (output_encoding == P_LINEAR)
{ {
r = PNG_sRGB_FROM_LINEAR(back_r * 255); r = PNG_sRGB_FROM_LINEAR(back_r * 255);
g = PNG_sRGB_FROM_LINEAR(back_g * 255); g = PNG_sRGB_FROM_LINEAR(back_g * 255);
@ -2595,11 +2601,11 @@ png_image_read_colormap(png_voidp argument)
*/ */
for (b=0; b<256; b = (b << 1) | 0x7f) for (b=0; b<256; b = (b << 1) | 0x7f)
png_create_colormap_entry(display, cmap_entries++, png_create_colormap_entry(display, cmap_entries++,
png_colormap_compose(display, r, E_sRGB, 128, png_colormap_compose(display, r, P_sRGB, 128,
back_r, output_encoding), back_r, output_encoding),
png_colormap_compose(display, g, E_sRGB, 128, png_colormap_compose(display, g, P_sRGB, 128,
back_g, output_encoding), back_g, output_encoding),
png_colormap_compose(display, b, E_sRGB, 128, png_colormap_compose(display, b, P_sRGB, 128,
back_b, output_encoding), back_b, output_encoding),
0/*unused*/, output_encoding); 0/*unused*/, output_encoding);
} }
@ -2658,7 +2664,7 @@ png_image_read_colormap(png_voidp argument)
num_trans = 0; num_trans = 0;
output_processing = PNG_CMAP_NONE; output_processing = PNG_CMAP_NONE;
data_encoding = E_FILE; /* Don't change from color-map indicies */ data_encoding = P_FILE; /* Don't change from color-map indicies */
cmap_entries = png_ptr->num_palette; cmap_entries = png_ptr->num_palette;
if (cmap_entries > 256) if (cmap_entries > 256)
cmap_entries = 256; cmap_entries = 256;
@ -2680,13 +2686,13 @@ png_image_read_colormap(png_voidp argument)
* on the sRGB color in 'back'. * on the sRGB color in 'back'.
*/ */
png_create_colormap_entry(display, i, png_create_colormap_entry(display, i,
png_colormap_compose(display, colormap[i].red, E_FILE, png_colormap_compose(display, colormap[i].red, P_FILE,
trans[i], back_r, output_encoding), trans[i], back_r, output_encoding),
png_colormap_compose(display, colormap[i].green, E_FILE, png_colormap_compose(display, colormap[i].green, P_FILE,
trans[i], back_g, output_encoding), trans[i], back_g, output_encoding),
png_colormap_compose(display, colormap[i].blue, E_FILE, png_colormap_compose(display, colormap[i].blue, P_FILE,
trans[i], back_b, output_encoding), trans[i], back_b, output_encoding),
output_encoding == E_LINEAR ? trans[i] * 257U : output_encoding == P_LINEAR ? trans[i] * 257U :
trans[i], trans[i],
output_encoding); output_encoding);
} }
@ -2695,7 +2701,7 @@ png_image_read_colormap(png_voidp argument)
else else
png_create_colormap_entry(display, i, colormap[i].red, png_create_colormap_entry(display, i, colormap[i].red,
colormap[i].green, colormap[i].blue, colormap[i].green, colormap[i].blue,
i < num_trans ? trans[i] : 255U, E_FILE/*8-bit*/); i < num_trans ? trans[i] : 255U, P_FILE/*8-bit*/);
} }
/* The PNG data may have indicies packed in fewer than 8 bits, it /* The PNG data may have indicies packed in fewer than 8 bits, it
@ -2723,12 +2729,12 @@ png_image_read_colormap(png_voidp argument)
png_error(png_ptr, "bad data option (internal error)"); png_error(png_ptr, "bad data option (internal error)");
break; break;
case E_sRGB: case P_sRGB:
/* Change to 8-bit sRGB */ /* Change to 8-bit sRGB */
png_set_alpha_mode_fixed(png_ptr, PNG_ALPHA_PNG, PNG_GAMMA_sRGB); png_set_alpha_mode_fixed(png_ptr, PNG_ALPHA_PNG, PNG_GAMMA_sRGB);
/* FALL THROUGH */ /* FALL THROUGH */
case E_FILE: case P_FILE:
if (png_ptr->bit_depth > 8) if (png_ptr->bit_depth > 8)
png_set_scale_16(png_ptr); png_set_scale_16(png_ptr);
break; break;
@ -2805,7 +2811,6 @@ png_image_read_and_map(png_voidp argument)
break; break;
default: default:
passes = 0;
png_error(png_ptr, "unknown interlace type"); png_error(png_ptr, "unknown interlace type");
} }
@ -3124,7 +3129,6 @@ png_image_read_composite(png_voidp argument)
break; break;
default: default:
passes = 0;
png_error(png_ptr, "unknown interlace type"); png_error(png_ptr, "unknown interlace type");
} }
@ -3273,11 +3277,15 @@ png_image_read_background(png_voidp argument)
break; break;
default: default:
passes = 0;
png_error(png_ptr, "unknown interlace type"); png_error(png_ptr, "unknown interlace type");
} }
switch (png_get_bit_depth(png_ptr, info_ptr)) /* Use direct access to info_ptr here because otherwise the simplified API
* would require PNG_EASY_ACCESS_SUPPORTED (just for this.) Note this is
* checking the value after libpng expansions, not the original value in the
* PNG.
*/
switch (info_ptr->bit_depth)
{ {
default: default:
png_error(png_ptr, "unexpected bit depth"); png_error(png_ptr, "unexpected bit depth");
@ -3425,8 +3433,10 @@ png_image_read_background(png_voidp argument)
unsigned int outchannels = 1+preserve_alpha; unsigned int outchannels = 1+preserve_alpha;
int swap_alpha = 0; int swap_alpha = 0;
if (preserve_alpha && (image->format & PNG_FORMAT_FLAG_AFIRST)) # ifdef PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED
swap_alpha = 1; if (preserve_alpha && (image->format & PNG_FORMAT_FLAG_AFIRST))
swap_alpha = 1;
# endif
for (pass = 0; pass < passes; ++pass) for (pass = 0; pass < passes; ++pass)
{ {

View File

@ -1,7 +1,7 @@
/* pngrtran.c - transforms the data in a row for PNG readers /* pngrtran.c - transforms the data in a row for PNG readers
* *
* Last changed in libpng 1.6.4 [August 21, 2013] * Last changed in libpng 1.6.8 [December 19, 2013]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson * Copyright (c) 1998-2013 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.)
@ -1942,6 +1942,9 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
info_ptr->bit_depth = 8; info_ptr->bit_depth = 8;
info_ptr->num_trans = 0; info_ptr->num_trans = 0;
if (png_ptr->palette == NULL)
png_error (png_ptr, "Palette is NULL in indexed image");
} }
else else
{ {

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.7 [November 14, 2013] * Last changed in libpng 1.6.8 [December 19, 2013]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson * Copyright (c) 1998-2013 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.)
@ -278,6 +278,10 @@ png_crc_error(png_structrp png_ptr)
return (0); return (0);
} }
#if defined(PNG_READ_iCCP_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) ||\
defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_READ_sCAL_SUPPORTED) ||\
defined(PNG_READ_sPLT_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) ||\
defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_SEQUENTIAL_READ_SUPPORTED)
/* Manage the read buffer; this simply reallocates the buffer if it is not small /* Manage the read buffer; this simply reallocates the buffer if it is not small
* enough (or if it is not allocated). The routine returns a pointer to the * enough (or if it is not allocated). The routine returns a pointer to the
* buffer; if an error occurs and 'warn' is set the routine returns NULL, else * buffer; if an error occurs and 'warn' is set the routine returns NULL, else
@ -325,6 +329,7 @@ png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn)
return buffer; return buffer;
} }
#endif /* PNG_READ_iCCP|iTXt|pCAL|sCAL|sPLT|tEXt|zTXt|SEQUENTIAL_READ */
/* png_inflate_claim: claim the zstream for some nefarious purpose that involves /* png_inflate_claim: claim the zstream for some nefarious purpose that involves
* decompression. Returns Z_OK on success, else a zlib error code. It checks * decompression. Returns Z_OK on success, else a zlib error code. It checks
@ -3871,7 +3876,6 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
if (pb < pa) pa = pb, a = b; if (pb < pa) pa = pb, a = b;
if (pc < pa) a = c; if (pc < pa) a = c;
c = b;
a += *row; a += *row;
*row++ = (png_byte)a; *row++ = (png_byte)a;
} }

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.3 [July 18, 2013] * Last changed in libpng 1.6.8 [December 19, 2013]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson * Copyright (c) 1998-2013 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.)
@ -527,7 +527,7 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
# endif # endif
)) ))
{ {
png_chunk_report(png_ptr, "Invalid palette", PNG_CHUNK_ERROR); png_error(png_ptr, "Invalid palette");
return; return;
} }

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.2 [April 25, 2013] * Last changed in libpng 1.6.8 [December 19, 2013]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson * Copyright (c) 1998-2013 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.)
@ -573,7 +573,8 @@ png_debug_free(png_structp png_ptr, png_voidp ptr)
/* We must free the list element too, but first kill /* We must free the list element too, but first kill
the memory that is to be freed. */ the memory that is to be freed. */
memset(ptr, 0x55, pinfo->size); memset(ptr, 0x55, pinfo->size);
png_free_default(png_ptr, pinfo); if (pinfo)
free(pinfo);
pinfo = NULL; pinfo = NULL;
break; break;
} }
@ -592,7 +593,8 @@ png_debug_free(png_structp png_ptr, png_voidp ptr)
if (verbose) if (verbose)
printf("Freeing %p\n", ptr); printf("Freeing %p\n", ptr);
png_free_default(png_ptr, ptr); if (ptr)
free(ptr);
ptr = NULL; ptr = NULL;
} }
#endif /* PNG_USER_MEM_SUPPORTED && PNG_DEBUG */ #endif /* PNG_USER_MEM_SUPPORTED && PNG_DEBUG */
@ -1578,14 +1580,12 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#ifdef PNG_WRITE_SUPPORTED /* else nothing was written */ #ifdef PNG_WRITE_SUPPORTED /* else nothing was written */
{ {
int wrote_question = 0;
for (;;) for (;;)
{ {
static int wrote_question = 0;
png_size_t num_in, num_out; png_size_t num_in, num_out;
char inbuf[256], outbuf[256]; char inbuf[256], outbuf[256];
num_in = fread(inbuf, 1, sizeof inbuf, fpin); num_in = fread(inbuf, 1, sizeof inbuf, fpin);
num_out = fread(outbuf, 1, sizeof outbuf, fpout); num_out = fread(outbuf, 1, sizeof outbuf, fpout);
@ -1970,4 +1970,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_7 Your_png_h_is_not_version_1_6_7; typedef png_libpng_version_1_6_8 Your_png_h_is_not_version_1_6_8;

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 [February 14, 2013] * Last changed in libpng 1.6.8 [December 19, 2013]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson * Copyright (c) 1998-2013 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.)
@ -149,6 +149,8 @@ png_set_write_fn(png_structrp png_ptr, png_voidp io_ptr,
# else # else
png_ptr->output_flush_fn = output_flush_fn; png_ptr->output_flush_fn = output_flush_fn;
# endif # endif
#else
PNG_UNUSED(output_flush_fn)
#endif /* PNG_WRITE_FLUSH_SUPPORTED */ #endif /* PNG_WRITE_FLUSH_SUPPORTED */
/* It is an error to read while writing a png file */ /* It is an error to read while writing a png file */

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.2 [April 25, 2013] * Last changed in libpng 1.6.8 [December 19, 2013]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson * Copyright (c) 1998-2013 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.)
@ -1638,14 +1638,16 @@ png_write_image_16bit(png_voidp argument)
if (image->format & PNG_FORMAT_FLAG_ALPHA) if (image->format & PNG_FORMAT_FLAG_ALPHA)
{ {
if (image->format & PNG_FORMAT_FLAG_AFIRST) # ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
{ if (image->format & PNG_FORMAT_FLAG_AFIRST)
aindex = -1; {
++input_row; /* To point to the first component */ aindex = -1;
++output_row; ++input_row; /* To point to the first component */
} ++output_row;
}
else else
# endif
aindex = channels; aindex = channels;
} }
@ -1794,14 +1796,16 @@ png_write_image_8bit(png_voidp argument)
png_bytep row_end; png_bytep row_end;
int aindex; int aindex;
if (image->format & PNG_FORMAT_FLAG_AFIRST) # ifdef PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
{ if (image->format & PNG_FORMAT_FLAG_AFIRST)
aindex = -1; {
++input_row; /* To point to the first component */ aindex = -1;
++output_row; ++input_row; /* To point to the first component */
} ++output_row;
}
else else
# endif
aindex = channels; aindex = channels;
/* Use row_end in place of a loop counter: */ /* Use row_end in place of a loop counter: */
@ -1881,7 +1885,8 @@ png_image_set_PLTE(png_image_write_control *display)
const png_uint_32 format = image->format; const png_uint_32 format = image->format;
const int channels = PNG_IMAGE_SAMPLE_CHANNELS(format); const int channels = PNG_IMAGE_SAMPLE_CHANNELS(format);
# ifdef PNG_FORMAT_BGR_SUPPORTED # if defined(PNG_FORMAT_BGR_SUPPORTED) &&\
defined(PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED)
const int afirst = (format & PNG_FORMAT_FLAG_AFIRST) != 0 && const int afirst = (format & PNG_FORMAT_FLAG_AFIRST) != 0 &&
(format & PNG_FORMAT_FLAG_ALPHA) != 0; (format & PNG_FORMAT_FLAG_ALPHA) != 0;
# else # else

View File

@ -1,7 +1,7 @@
VisualStudio instructions VisualStudio instructions
libpng version 1.6.7 - November 14, 2013 libpng version 1.6.8 - December 19, 2013
Copyright (c) 1998-2010 Glenn Randers-Pehrson Copyright (c) 1998-2010 Glenn Randers-Pehrson

View File

@ -2,7 +2,7 @@
<!-- <!--
* zlib.props - location of zlib source * zlib.props - location of zlib source
* *
* libpng version 1.6.7 - November 14, 2013 * libpng version 1.6.8 - December 19, 2013
* *
* 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.7 - November 14, 2013 Makefiles for libpng version 1.6.8 - December 19, 2013
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.7) (gcc, creates libpng16.so.16.1.6.8)
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.7) (gcc, creates libpng16.so.16.1.6.8)
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.7) creates libpng16.so.16.1.6.8)
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.7) creates libpng16.so.16.1.6.8)
makefile.so9 => Solaris 9 makefile (gcc, makefile.so9 => Solaris 9 makefile (gcc,
creates libpng16.so.16.1.6.7) creates libpng16.so.16.1.6.8)
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

@ -21,7 +21,7 @@ PNG_DFN "OS2 DESCRIPTION "PNG image compression library""
PNG_DFN "OS2 CODE PRELOAD MOVEABLE DISCARDABLE" PNG_DFN "OS2 CODE PRELOAD MOVEABLE DISCARDABLE"
PNG_DFN "" PNG_DFN ""
PNG_DFN "EXPORTS" PNG_DFN "EXPORTS"
PNG_DFN ";Version 1.6.7" PNG_DFN ";Version 1.6.8"
#define PNG_EXPORTA(ordinal, type, name, args, attributes)\ #define PNG_EXPORTA(ordinal, type, name, args, attributes)\
PNG_DFN "@" SYMBOL_PREFIX "@@" name "@" PNG_DFN "@" SYMBOL_PREFIX "@@" name "@"

View File

@ -11,7 +11,7 @@
# Modeled after libxml-config. # Modeled after libxml-config.
version=1.6.7 version=1.6.8
prefix="" prefix=""
libdir="" libdir=""
libs="" libs=""

View File

@ -5,6 +5,6 @@ includedir=@includedir@/libpng16
Name: libpng Name: libpng
Description: Loads and saves PNG files Description: Loads and saves PNG files
Version: 1.6.7 Version: 1.6.8
Libs: -L${libdir} -lpng16 Libs: -L${libdir} -lpng16
Cflags: -I${includedir} Cflags: -I${includedir}

View File

@ -23,7 +23,7 @@
VERMAJ = 1 VERMAJ = 1
VERMIN = 6 VERMIN = 6
VERMIC = 7 VERMIC = 8
VER = $(VERMAJ).$(VERMIN).$(VERMIC) VER = $(VERMAJ).$(VERMIN).$(VERMIC)
NAME = libpng NAME = libpng
PACKAGE = $(NAME)-$(VER) PACKAGE = $(NAME)-$(VER)

View File

@ -10,7 +10,7 @@
# Library name: # Library name:
LIBNAME = libpng16 LIBNAME = libpng16
PNGMAJ = 16 PNGMAJ = 16
RELEASE = 7 RELEASE = 8
# Shared library names: # Shared library names:
LIBSO=$(LIBNAME).so LIBSO=$(LIBNAME).so

View File

@ -18,7 +18,7 @@ exec_prefix=$(prefix)
# Library name: # Library name:
LIBNAME = libpng16 LIBNAME = libpng16
PNGMAJ = 16 PNGMAJ = 16
RELEASE = 7 RELEASE = 8
# Shared library names: # Shared library names:
LIBSO=$(LIBNAME).dll LIBSO=$(LIBNAME).dll

View File

@ -17,7 +17,7 @@ INCSDIR=${LOCALBASE}/include/libpng16
LIB= png16 LIB= png16
SHLIB_MAJOR= 0 SHLIB_MAJOR= 0
SHLIB_MINOR= 1.6.7 SHLIB_MINOR= 1.6.8
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

@ -17,7 +17,7 @@ INCSDIR=${LOCALBASE}/include
LIB= png LIB= png
SHLIB_MAJOR= 16 SHLIB_MAJOR= 16
SHLIB_MINOR= 1.6.7 SHLIB_MINOR= 1.6.8
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

@ -11,7 +11,7 @@ LIBDIR= ${PREFIX}/lib
MANDIR= ${PREFIX}/man/cat MANDIR= ${PREFIX}/man/cat
SHLIB_MAJOR= 16 SHLIB_MAJOR= 16
SHLIB_MINOR= 1.6.7 SHLIB_MINOR= 1.6.8
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

@ -282,7 +282,7 @@ $1 == "option" && NF >= 2{
for (i=istart; i<=NF; ++i) { for (i=istart; i<=NF; ++i) {
val=$(i) val=$(i)
sub(/,$/,"",val) sub(/,$/,"",val)
if (val == "on" || val == "off" || val == "disabled") { if (val == "on" || val == "off" || val == "disabled" || val =="enabled") {
key = "" key = ""
if (onoff != val) { if (onoff != val) {
# on or off can zap disabled or enabled: # on or off can zap disabled or enabled:
@ -687,9 +687,11 @@ END{
} }
# if # if
have_ifs = 0
nreqs = split(iffs[i], r) nreqs = split(iffs[i], r)
print "#undef PNG_no_if" >out print "#undef PNG_no_if" >out
if (nreqs > 0) { if (nreqs > 0) {
have_ifs = 1
print "/* if" iffs[i], "*/" >out print "/* if" iffs[i], "*/" >out
print "#define PNG_no_if 1" >out print "#define PNG_no_if 1" >out
for (j=1; j<=nreqs; ++j) { for (j=1; j<=nreqs; ++j) {
@ -727,7 +729,10 @@ END{
print "# ifndef PNG_" i "_SUPPORTED /*!command line*/" >out print "# ifndef PNG_" i "_SUPPORTED /*!command line*/" >out
print "# ifdef PNG_not_enabled /*!enabled*/" >out print "# ifdef PNG_not_enabled /*!enabled*/" >out
if (option[i] == "off" || option[i] == "disabled" && everything != "on" || option[i] == "enabled" && everything == "off") { # 'have_ifs' here means that everything = "off" still allows an 'if' on
# an otherwise enabled option to turn it on; otherwise the 'if'
# handling is effectively disabled by 'everything = off'
if (option[i] == "off" || option[i] == "disabled" && everything != "on" || option[i] == "enabled" && everything == "off" && !have_ifs) {
print "# undef PNG_on /*default off*/" >out print "# undef PNG_on /*default off*/" >out
} else { } else {
print "# ifdef PNG_NO_" i >out print "# ifdef PNG_NO_" i >out

View File

@ -294,12 +294,16 @@ option BENIGN_READ_ERRORS requires BENIGN_ERRORS
option MNG_FEATURES option MNG_FEATURES
# Arithmetic options, the first is the big switch that chooses between internal # Arithmetic options, the first is the big switch that chooses between internal
# floating and fixed point arithmetic implementations - it does not affect any # floating and fixed point arithmetic implementations - it does not affect an
# APIs. The second two (the _POINT settings) switch off individual APIs. # APIs. The second two (the _POINT settings) switch off individual APIs.
#
# Prior to libpng 1.6.8 one of the API (_POINT) variants had to be selected. At
# 1.6.8 this restriction has been removed; the simplified API can be used
# without enabling any of the low level fixed/floating APIs.
option FLOATING_ARITHMETIC option FLOATING_ARITHMETIC
option FLOATING_POINT enables ok_math option FLOATING_POINT
option FIXED_POINT enables ok_math option FIXED_POINT
# The following is always on (defined empty) # The following is always on (defined empty)
@ -435,7 +439,7 @@ option READ_TRANSFORMS requires READ
# If you handle gamma issues outside libpng then you do not need the libpng # If you handle gamma issues outside libpng then you do not need the libpng
# gamma processing; and it is an enormous waste of space. You just need to # gamma processing; and it is an enormous waste of space. You just need to
# remove the use of libpng APIs that depend on it. # remove the use of libpng APIs that depend on it.
option READ_GAMMA requires READ_TRANSFORMS, READ_gAMA option READ_GAMMA requires READ_TRANSFORMS, READ_gAMA, READ_sRGB
option READ_ALPHA_MODE requires READ_TRANSFORMS, READ_GAMMA option READ_ALPHA_MODE requires READ_TRANSFORMS, READ_GAMMA
option READ_BACKGROUND requires READ_TRANSFORMS, READ_STRIP_ALPHA, READ_GAMMA option READ_BACKGROUND requires READ_TRANSFORMS, READ_STRIP_ALPHA, READ_GAMMA
@ -448,7 +452,7 @@ option READ_INVERT_ALPHA requires READ_TRANSFORMS
option READ_INVERT requires READ_TRANSFORMS option READ_INVERT requires READ_TRANSFORMS
option READ_PACK requires READ_TRANSFORMS option READ_PACK requires READ_TRANSFORMS
option READ_PACKSWAP requires READ_TRANSFORMS option READ_PACKSWAP requires READ_TRANSFORMS
option READ_RGB_TO_GRAY requires READ_TRANSFORMS, READ_GAMMA option READ_RGB_TO_GRAY requires READ_TRANSFORMS, READ_GAMMA enables COLORSPACE
option READ_SCALE_16_TO_8 requires READ_TRANSFORMS option READ_SCALE_16_TO_8 requires READ_TRANSFORMS
option READ_SHIFT requires READ_TRANSFORMS option READ_SHIFT requires READ_TRANSFORMS
option READ_STRIP_16_TO_8 requires READ_TRANSFORMS option READ_STRIP_16_TO_8 requires READ_TRANSFORMS
@ -805,13 +809,13 @@ option SAVE_INT_32 disabled
option WRITE_OPTIMIZE_CMF requires WRITE option WRITE_OPTIMIZE_CMF requires WRITE
option READ_COMPRESSED_TEXT disabled option READ_COMPRESSED_TEXT disabled
option READ_iCCP enables READ_COMPRESSED_TEXT
option READ_iTXt enables READ_COMPRESSED_TEXT option READ_iTXt enables READ_COMPRESSED_TEXT
option READ_zTXt enables READ_COMPRESSED_TEXT option READ_zTXt enables READ_COMPRESSED_TEXT
option READ_COMPRESSED_TEXT enables READ_TEXT option READ_COMPRESSED_TEXT enables READ_TEXT
option WRITE_oFFs enables SAVE_INT_32 option WRITE_oFFs enables SAVE_INT_32
option WRITE_pCAL enables SAVE_INT_32 option WRITE_pCAL enables SAVE_INT_32
option WRITE_cHRM enables SAVE_INT_32
option WRITE_COMPRESSED_TEXT disabled option WRITE_COMPRESSED_TEXT disabled
option WRITE_iCCP enables WRITE_COMPRESSED_TEXT option WRITE_iCCP enables WRITE_COMPRESSED_TEXT
@ -839,30 +843,44 @@ option READ_GET_PALETTE_MAX requires READ_CHECK_FOR_INVALID_INDEX disabled
option WRITE_GET_PALETTE_MAX requires WRITE_CHECK_FOR_INVALID_INDEX disabled option WRITE_GET_PALETTE_MAX requires WRITE_CHECK_FOR_INVALID_INDEX disabled
# Simplified API options (added at libpng-1.6.0) # Simplified API options (added at libpng-1.6.0)
# In libpng 1.6.8 the handling of these options was changed to used 'requires'
# throughout, so that disabling some of the low level support always disables
# the base simplified read/write API. This much simplifies the handling and
# makes 'everything = off' work in a more intuitive way. It eliminates a
# previously reported feature that APIs previously enabled by the simplified
# API couldn't be turned off without explicitly turning off the simplified
# APIs.
#
# Read: # Read:
option SIMPLIFIED_READ, option SIMPLIFIED_READ,
requires SEQUENTIAL_READ, READ_TRANSFORMS, SETJMP, BENIGN_ERRORS READ_GAMMA, requires SEQUENTIAL_READ, READ_TRANSFORMS, SETJMP, BENIGN_ERRORS,
enables READ_EXPAND, READ_16BIT READ_EXPAND_16, READ_SCALE_16_TO_8, READ_EXPAND, READ_16BIT, READ_EXPAND_16, READ_SCALE_16_TO_8,
READ_RGB_TO_GRAY, READ_ALPHA_MODE READ_BACKGROUND READ_STRIP_ALPHA, READ_RGB_TO_GRAY, READ_ALPHA_MODE, READ_BACKGROUND, READ_STRIP_ALPHA,
READ_FILLER, READ_SWAP READ_FILLER, READ_SWAP, READ_PACK, READ_GRAY_TO_RGB, READ_GAMMA,
READ_tRNS, READ_bKGD, READ_gAMA, READ_cHRM, READ_sRGB, READ_sBIT
option SIMPLIFIED_READ_AFIRST requires SIMPLIFIED_READ disabled # AFIRST and BGR read options:
option READ_SWAP_ALPHA enables SIMPLIFIED_READ_AFIRST # Prior to libpng 1.6.8 these were disabled but switched on if the low level
# libpng routines that do the swaps were enabled. This worked but was
# confusing. In libpng 1.6.8 the options were changed to simple 'requires'
# and are enabled by default. This should work the same way in practice.
option SIMPLIFIED_READ_AFIRST enables FORMAT_AFIRST,
requires SIMPLIFIED_READ READ_SWAP_ALPHA
option SIMPLIFIED_READ_BGR requires SIMPLIFIED_READ disabled option SIMPLIFIED_READ_BGR enables FORMAT_BGR,
option READ_BGR enables SIMPLIFIED_READ_BGR requires SIMPLIFIED_READ READ_BGR
# Write: # Write:
option SIMPLIFIED_WRITE, option SIMPLIFIED_WRITE,
requires WRITE STDIO, SETJMP, requires WRITE STDIO, SETJMP, WRITE_SWAP, WRITE_PACK,
enables WRITE_SWAP WRITE_gAMA, WRITE_sRGB WRITE_cHRM WRITE_tRNS, WRITE_gAMA, WRITE_sRGB, WRITE_cHRM
option SIMPLIFIED_WRITE_AFIRST requires SIMPLIFIED_WRITE disabled option SIMPLIFIED_WRITE_AFIRST enables FORMAT_AFIRST,
option WRITE_SWAP_ALPHA enables SIMPLIFIED_WRITE_AFIRST requires SIMPLIFIED_WRITE WRITE_SWAP_ALPHA
option SIMPLIFIED_WRITE_BGR requires SIMPLIFIED_WRITE disabled option SIMPLIFIED_WRITE_BGR enables FORMAT_BGR,
option WRITE_BGR enables SIMPLIFIED_WRITE_BGR requires SIMPLIFIED_WRITE WRITE_BGR
# Formats: # Formats:
option FORMAT_AFIRST if SIMPLIFIED_READ_AFIRST, SIMPLIFIED_WRITE_AFIRST option FORMAT_AFIRST disabled
option FORMAT_BGR if SIMPLIFIED_READ_BGR, SIMPLIFIED_WRITE_BGR option FORMAT_BGR disabled

View File

@ -1,8 +1,8 @@
/* libpng 1.6.7 STANDARD API DEFINITION */ /* libpng 1.6.8 STANDARD API DEFINITION */
/* pnglibconf.h - library build configuration */ /* pnglibconf.h - library build configuration */
/* Libpng version 1.6.7 - November 14, 2013 */ /* Libpng version 1.6.8 - December 19, 2013 */
/* Copyright (c) 1998-2013 Glenn Randers-Pehrson */ /* Copyright (c) 1998-2013 Glenn Randers-Pehrson */

View File

@ -1,4 +1,4 @@
;Version 1.6.7 ;Version 1.6.8
;-------------------------------------------------------------- ;--------------------------------------------------------------
; LIBPNG symbol list as a Win32 DEF file ; LIBPNG symbol list as a Win32 DEF file
; Contains all the symbols that can be exported from libpng ; Contains all the symbols that can be exported from libpng