mirror of https://github.com/stella-emu/stella.git
Updated include PNG library to latest version.
git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@3192 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
parent
38dce5194e
commit
3312ea5b70
|
@ -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.17 [March 26, 2015]
|
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2015 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_17 Your_png_h_is_not_version_1_6_17;
|
typedef png_libpng_version_1_6_18 Your_png_h_is_not_version_1_6_18;
|
||||||
|
|
||||||
/* 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
|
||||||
|
@ -101,7 +101,7 @@ png_zfree(voidpf png_ptr, voidpf ptr)
|
||||||
void /* PRIVATE */
|
void /* PRIVATE */
|
||||||
png_reset_crc(png_structrp png_ptr)
|
png_reset_crc(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
/* The cast is safe because the crc is a 32 bit value. */
|
/* The cast is safe because the crc is a 32-bit value. */
|
||||||
png_ptr->crc = (png_uint_32)crc32(0, Z_NULL, 0);
|
png_ptr->crc = (png_uint_32)crc32(0, Z_NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ png_calculate_crc(png_structrp png_ptr, png_const_bytep ptr, png_size_t length)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 'uLong' is defined in zlib.h as unsigned long; this means that on some
|
/* 'uLong' is defined in zlib.h as unsigned long; this means that on some
|
||||||
* systems it is a 64 bit value. crc32, however, returns 32 bits so the
|
* systems it is a 64-bit value. crc32, however, returns 32 bits so the
|
||||||
* following cast is safe. 'uInt' may be no more than 16 bits, so it is
|
* following cast is safe. 'uInt' may be no more than 16 bits, so it is
|
||||||
* necessary to perform a loop here.
|
* necessary to perform a loop here.
|
||||||
*/
|
*/
|
||||||
|
@ -275,7 +275,9 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||||
|
|
||||||
# ifdef PNG_SETJMP_SUPPORTED
|
# ifdef PNG_SETJMP_SUPPORTED
|
||||||
if (!setjmp(create_jmp_buf))
|
if (!setjmp(create_jmp_buf))
|
||||||
|
# endif
|
||||||
{
|
{
|
||||||
|
# ifdef PNG_SETJMP_SUPPORTED
|
||||||
/* Temporarily fake out the longjmp information until we have
|
/* Temporarily fake out the longjmp information until we have
|
||||||
* successfully completed this function. This only works if we have
|
* successfully completed this function. This only works if we have
|
||||||
* setjmp() support compiled in, but it is safe - this stuff should
|
* setjmp() support compiled in, but it is safe - this stuff should
|
||||||
|
@ -284,8 +286,6 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||||
create_struct.jmp_buf_ptr = &create_jmp_buf;
|
create_struct.jmp_buf_ptr = &create_jmp_buf;
|
||||||
create_struct.jmp_buf_size = 0; /*stack allocation*/
|
create_struct.jmp_buf_size = 0; /*stack allocation*/
|
||||||
create_struct.longjmp_fn = longjmp;
|
create_struct.longjmp_fn = longjmp;
|
||||||
# else
|
|
||||||
{
|
|
||||||
# endif
|
# endif
|
||||||
/* Call the general version checker (shared with read and write code):
|
/* Call the general version checker (shared with read and write code):
|
||||||
*/
|
*/
|
||||||
|
@ -766,13 +766,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.17 - March 26, 2015" PNG_STRING_NEWLINE \
|
"libpng version 1.6.18 - July 23, 2015" PNG_STRING_NEWLINE \
|
||||||
"Copyright (c) 1998-2015 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
|
"Copyright (c) 1998-2015 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.17 - March 26, 2015\
|
return "libpng version 1.6.18 - July 23, 2015\
|
||||||
Copyright (c) 1998-2015 Glenn Randers-Pehrson\
|
Copyright (c) 1998-2015 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.";
|
||||||
|
@ -1235,7 +1235,8 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy)
|
||||||
|
|
||||||
/* Check xy and, implicitly, z. Note that wide gamut color spaces typically
|
/* Check xy and, implicitly, z. Note that wide gamut color spaces typically
|
||||||
* have end points with 0 tristimulus values (these are impossible end
|
* have end points with 0 tristimulus values (these are impossible end
|
||||||
* points, but they are used to cover the possible colors.)
|
* points, but they are used to cover the possible colors). We check
|
||||||
|
* xy->whitey against 5, not 0, to avoid a possible integer overflow.
|
||||||
*/
|
*/
|
||||||
if (xy->redx < 0 || xy->redx > PNG_FP_1) return 1;
|
if (xy->redx < 0 || xy->redx > PNG_FP_1) return 1;
|
||||||
if (xy->redy < 0 || xy->redy > PNG_FP_1-xy->redx) return 1;
|
if (xy->redy < 0 || xy->redy > PNG_FP_1-xy->redx) return 1;
|
||||||
|
@ -1244,7 +1245,7 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy)
|
||||||
if (xy->bluex < 0 || xy->bluex > PNG_FP_1) return 1;
|
if (xy->bluex < 0 || xy->bluex > PNG_FP_1) return 1;
|
||||||
if (xy->bluey < 0 || xy->bluey > PNG_FP_1-xy->bluex) return 1;
|
if (xy->bluey < 0 || xy->bluey > PNG_FP_1-xy->bluex) return 1;
|
||||||
if (xy->whitex < 0 || xy->whitex > PNG_FP_1) return 1;
|
if (xy->whitex < 0 || xy->whitex > PNG_FP_1) return 1;
|
||||||
if (xy->whitey < 0 || xy->whitey > PNG_FP_1-xy->whitex) return 1;
|
if (xy->whitey < 5 || xy->whitey > PNG_FP_1-xy->whitex) return 1;
|
||||||
|
|
||||||
/* The reverse calculation is more difficult because the original tristimulus
|
/* The reverse calculation is more difficult because the original tristimulus
|
||||||
* value had 9 independent values (red,green,blue)x(X,Y,Z) however only 8
|
* value had 9 independent values (red,green,blue)x(X,Y,Z) however only 8
|
||||||
|
@ -2276,7 +2277,7 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
|
||||||
|
|
||||||
/* Length *and* intent must match */
|
/* Length *and* intent must match */
|
||||||
if (length == png_sRGB_checks[i].length &&
|
if (length == png_sRGB_checks[i].length &&
|
||||||
intent == png_sRGB_checks[i].intent)
|
intent == (png_uint_32) png_sRGB_checks[i].intent)
|
||||||
{
|
{
|
||||||
/* Now calculate the adler32 if not done already. */
|
/* Now calculate the adler32 if not done already. */
|
||||||
if (adler == 0)
|
if (adler == 0)
|
||||||
|
@ -2891,7 +2892,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
||||||
*/
|
*/
|
||||||
|
|
||||||
{
|
{
|
||||||
int czero, clead, cdigits;
|
unsigned int czero, clead, cdigits;
|
||||||
char exponent[10];
|
char exponent[10];
|
||||||
|
|
||||||
/* Allow up to two leading zeros - this will not lengthen
|
/* Allow up to two leading zeros - this will not lengthen
|
||||||
|
@ -2921,7 +2922,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
||||||
* of the loop don't break the number into parts so
|
* of the loop don't break the number into parts so
|
||||||
* that the final digit is rounded.
|
* that the final digit is rounded.
|
||||||
*/
|
*/
|
||||||
if (cdigits+czero-clead+1 < (int)precision)
|
if (cdigits+czero+1 < precision+clead)
|
||||||
fp = modf(fp, &d);
|
fp = modf(fp, &d);
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -3027,7 +3028,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
||||||
*ascii++ = (char)(48 + (int)d), ++cdigits;
|
*ascii++ = (char)(48 + (int)d), ++cdigits;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (cdigits+czero-clead < (int)precision && fp > DBL_MIN);
|
while (cdigits+czero < precision+clead && fp > DBL_MIN);
|
||||||
|
|
||||||
/* The total output count (max) is now 4+precision */
|
/* The total output count (max) is now 4+precision */
|
||||||
|
|
||||||
|
@ -3095,7 +3096,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
||||||
/* Need another size check here for the exponent digits, so
|
/* Need another size check here for the exponent digits, so
|
||||||
* this need not be considered above.
|
* this need not be considered above.
|
||||||
*/
|
*/
|
||||||
if ((int)size > cdigits)
|
if (size > cdigits)
|
||||||
{
|
{
|
||||||
while (cdigits > 0) *ascii++ = exponent[--cdigits];
|
while (cdigits > 0) *ascii++ = exponent[--cdigits];
|
||||||
|
|
||||||
|
@ -4236,7 +4237,7 @@ png_set_option(png_structrp png_ptr, int option, int onoff)
|
||||||
* contrib/tools/makesRGB.c. The actual sRGB transfer curve defined in the
|
* contrib/tools/makesRGB.c. The actual sRGB transfer curve defined in the
|
||||||
* specification (see the article at http://en.wikipedia.org/wiki/SRGB)
|
* specification (see the article at http://en.wikipedia.org/wiki/SRGB)
|
||||||
* is used, not the gamma=1/2.2 approximation use elsewhere in libpng.
|
* is used, not the gamma=1/2.2 approximation use elsewhere in libpng.
|
||||||
* The sRGB to linear table is exact (to the nearest 16 bit linear fraction).
|
* The sRGB to linear table is exact (to the nearest 16-bit linear fraction).
|
||||||
* The inverse (linear to sRGB) table has accuracies as follows:
|
* The inverse (linear to sRGB) table has accuracies as follows:
|
||||||
*
|
*
|
||||||
* For all possible (255*65535+1) input values:
|
* For all possible (255*65535+1) input values:
|
||||||
|
|
105
src/libpng/png.h
105
src/libpng/png.h
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
/* png.h - header file for PNG reference library
|
/* png.h - header file for PNG reference library
|
||||||
*
|
*
|
||||||
* libpng version 1.6.17, March 26, 2015
|
* libpng version 1.6.18, July 23, 2015
|
||||||
*
|
*
|
||||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
|
@ -11,8 +11,8 @@
|
||||||
*
|
*
|
||||||
* 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.89, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||||
* libpng versions 0.97, January 1998, through 1.6.17, March 26, 2015: Glenn
|
* libpng versions 0.97, January 1998, through 1.6.18, July 23, 2015: Glenn
|
||||||
* See also "Contributing Authors", below.
|
* See also "Contributing Authors", below.
|
||||||
*
|
*
|
||||||
* Note about libpng version numbers:
|
* Note about libpng version numbers:
|
||||||
|
@ -216,6 +216,9 @@
|
||||||
* 1.6.17beta01-06 16 10617 16.so.16.17[.0]
|
* 1.6.17beta01-06 16 10617 16.so.16.17[.0]
|
||||||
* 1.6.17rc01-06 16 10617 16.so.16.17[.0]
|
* 1.6.17rc01-06 16 10617 16.so.16.17[.0]
|
||||||
* 1.6.17 16 10617 16.so.16.17[.0]
|
* 1.6.17 16 10617 16.so.16.17[.0]
|
||||||
|
* 1.6.18beta01-09 16 10618 16.so.16.18[.0]
|
||||||
|
* 1.6.18rc01-03 16 10618 16.so.16.18[.0]
|
||||||
|
* 1.6.18 16 10618 16.so.16.18[.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
|
||||||
|
@ -247,21 +250,16 @@
|
||||||
*
|
*
|
||||||
* 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.17, March 26, 2015, are
|
* libpng versions 1.0.7, July 1, 2000, through 1.6.18, July 23, 2015, are
|
||||||
* Copyright (c) 2004, 2006-2015 Glenn Randers-Pehrson, and are
|
* Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, and are
|
||||||
* distributed according to the same disclaimer and license as libpng-1.2.5
|
|
||||||
* with the following individual added to the list of Contributing Authors:
|
|
||||||
*
|
|
||||||
* Cosmin Truta
|
|
||||||
*
|
|
||||||
* libpng versions 1.0.7, July 1, 2000, through 1.2.5, October 3, 2002, are
|
|
||||||
* Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
|
|
||||||
* distributed according to the same disclaimer and license as libpng-1.0.6
|
* distributed according to the same disclaimer and license as libpng-1.0.6
|
||||||
* with the following individuals added to the list of Contributing Authors:
|
* with the following individuals added to the list of Contributing Authors:
|
||||||
*
|
*
|
||||||
* Simon-Pierre Cadieux
|
* Simon-Pierre Cadieux
|
||||||
* Eric S. Raymond
|
* Mans Rullgard
|
||||||
|
* Cosmin Truta
|
||||||
* Gilles Vollant
|
* Gilles Vollant
|
||||||
|
* James Yu
|
||||||
*
|
*
|
||||||
* and with the following additions to the disclaimer:
|
* and with the following additions to the disclaimer:
|
||||||
*
|
*
|
||||||
|
@ -273,17 +271,18 @@
|
||||||
* the user.
|
* the user.
|
||||||
*
|
*
|
||||||
* libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
* libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
||||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson, and are
|
* Copyright (c) 1998-2000 Glenn Randers-Pehrson, and are distributed according
|
||||||
* distributed according to the same disclaimer and license as libpng-0.96,
|
* to the same disclaimer and license as libpng-0.96, with the following
|
||||||
* with the following individuals added to the list of Contributing Authors:
|
* individuals added to the list of Contributing Authors:
|
||||||
*
|
*
|
||||||
* Tom Lane
|
* Tom Lane
|
||||||
* Glenn Randers-Pehrson
|
* Glenn Randers-Pehrson
|
||||||
|
* Eric S. Raymond
|
||||||
* Willem van Schaik
|
* Willem van Schaik
|
||||||
*
|
*
|
||||||
* libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
* libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
||||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
* Copyright (c) 1996-1997 Andreas Dilger, and are
|
||||||
* Distributed according to the same disclaimer and license as libpng-0.88,
|
* distributed according to the same disclaimer and license as libpng-0.88,
|
||||||
* with the following individuals added to the list of Contributing Authors:
|
* with the following individuals added to the list of Contributing Authors:
|
||||||
*
|
*
|
||||||
* John Bowler
|
* John Bowler
|
||||||
|
@ -294,7 +293,7 @@
|
||||||
* Tom Tanner
|
* Tom Tanner
|
||||||
*
|
*
|
||||||
* libpng versions 0.5, May 1995, through 0.88, January 1996, are
|
* libpng versions 0.5, May 1995, through 0.88, January 1996, are
|
||||||
* Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
|
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||||
*
|
*
|
||||||
* For the purposes of this copyright and license, "Contributing Authors"
|
* For the purposes of this copyright and license, "Contributing Authors"
|
||||||
* is defined as the following set of individuals:
|
* is defined as the following set of individuals:
|
||||||
|
@ -322,8 +321,8 @@
|
||||||
* 2. Altered versions must be plainly marked as such and must not
|
* 2. Altered versions must be plainly marked as such and must not
|
||||||
* be misrepresented as being the original source.
|
* be misrepresented as being the original source.
|
||||||
*
|
*
|
||||||
* 3. This Copyright notice may not be removed or altered from
|
* 3. This Copyright notice may not be removed or altered from any
|
||||||
* any source or altered source distribution.
|
* source or altered source distribution.
|
||||||
*
|
*
|
||||||
* The Contributing Authors and Group 42, Inc. specifically permit, without
|
* The Contributing Authors and Group 42, Inc. specifically permit, without
|
||||||
* fee, and encourage the use of this source code as a component to
|
* fee, and encourage the use of this source code as a component to
|
||||||
|
@ -343,8 +342,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Libpng is OSI Certified Open Source Software. OSI Certified is a
|
* Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
|
||||||
* certification mark of the Open Source Initiative.
|
* a certification mark of the Open Source Initiative. OSI has not addressed
|
||||||
|
* the additional disclaimers inserted at version 1.0.7.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -359,13 +359,13 @@
|
||||||
* Y2K compliance in libpng:
|
* Y2K compliance in libpng:
|
||||||
* =========================
|
* =========================
|
||||||
*
|
*
|
||||||
* March 26, 2015
|
* July 23, 2015
|
||||||
*
|
*
|
||||||
* 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.17 are Y2K compliant. It is my belief that
|
* upward through 1.6.18 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
|
||||||
|
@ -427,9 +427,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.17"
|
#define PNG_LIBPNG_VER_STRING "1.6.18"
|
||||||
#define PNG_HEADER_VERSION_STRING \
|
#define PNG_HEADER_VERSION_STRING \
|
||||||
" libpng version 1.6.17 - March 26, 2015\n"
|
" libpng version 1.6.18 - July 23, 2015\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
|
||||||
|
@ -437,7 +437,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 17
|
#define PNG_LIBPNG_VER_RELEASE 18
|
||||||
|
|
||||||
/* 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:
|
||||||
|
@ -468,7 +468,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 10617 /* 1.6.17 */
|
#define PNG_LIBPNG_VER 10618 /* 1.6.18 */
|
||||||
|
|
||||||
/* 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.
|
||||||
|
@ -573,7 +573,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_17;
|
typedef char* png_libpng_version_1_6_18;
|
||||||
|
|
||||||
/* 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.
|
||||||
*
|
*
|
||||||
|
@ -1623,35 +1623,7 @@ PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,
|
||||||
#define PNG_FILTER_VALUE_LAST 5
|
#define PNG_FILTER_VALUE_LAST 5
|
||||||
|
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#ifdef PNG_WRITE_SUPPORTED
|
||||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* EXPERIMENTAL */
|
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */
|
||||||
/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_
|
|
||||||
* defines, either the default (minimum-sum-of-absolute-differences), or
|
|
||||||
* the experimental method (weighted-minimum-sum-of-absolute-differences).
|
|
||||||
*
|
|
||||||
* Weights are factors >= 1.0, indicating how important it is to keep the
|
|
||||||
* filter type consistent between rows. Larger numbers mean the current
|
|
||||||
* filter is that many times as likely to be the same as the "num_weights"
|
|
||||||
* previous filters. This is cumulative for each previous row with a weight.
|
|
||||||
* There needs to be "num_weights" values in "filter_weights", or it can be
|
|
||||||
* NULL if the weights aren't being specified. Weights have no influence on
|
|
||||||
* the selection of the first row filter. Well chosen weights can (in theory)
|
|
||||||
* improve the compression for a given image.
|
|
||||||
*
|
|
||||||
* Costs are factors >= 1.0 indicating the relative decoding costs of a
|
|
||||||
* filter type. Higher costs indicate more decoding expense, and are
|
|
||||||
* therefore less likely to be selected over a filter with lower computational
|
|
||||||
* costs. There needs to be a value in "filter_costs" for each valid filter
|
|
||||||
* type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't
|
|
||||||
* setting the costs. Costs try to improve the speed of decompression without
|
|
||||||
* unduly increasing the compressed image size.
|
|
||||||
*
|
|
||||||
* A negative weight or cost indicates the default value is to be used, and
|
|
||||||
* values in the range [0.0, 1.0) indicate the value is to remain unchanged.
|
|
||||||
* The default values for both weights and costs are currently 1.0, but may
|
|
||||||
* change if good general weighting/cost heuristics can be found. If both
|
|
||||||
* the weights and costs are set to 1.0, this degenerates the WEIGHTED method
|
|
||||||
* to the UNWEIGHTED method, but with added encoding time/computation.
|
|
||||||
*/
|
|
||||||
PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr,
|
PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr,
|
||||||
int heuristic_method, int num_weights, png_const_doublep filter_weights,
|
int heuristic_method, int num_weights, png_const_doublep filter_weights,
|
||||||
png_const_doublep filter_costs))
|
png_const_doublep filter_costs))
|
||||||
|
@ -1661,9 +1633,7 @@ PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
|
||||||
png_const_fixed_point_p filter_costs))
|
png_const_fixed_point_p filter_costs))
|
||||||
#endif /* WRITE_WEIGHTED_FILTER */
|
#endif /* WRITE_WEIGHTED_FILTER */
|
||||||
|
|
||||||
/* Heuristic used for row filter selection. These defines should NOT be
|
/* The following are no longer used and will be removed from libpng-1.7: */
|
||||||
* changed.
|
|
||||||
*/
|
|
||||||
#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */
|
#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */
|
||||||
#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */
|
#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */
|
||||||
#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */
|
#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */
|
||||||
|
@ -2783,8 +2753,9 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
|
||||||
*
|
*
|
||||||
* To read a PNG file using the simplified API:
|
* To read a PNG file using the simplified API:
|
||||||
*
|
*
|
||||||
* 1) Declare a 'png_image' structure (see below) on the stack and set the
|
* 1) Declare a 'png_image' structure (see below) on the stack, set the
|
||||||
* version field to PNG_IMAGE_VERSION.
|
* version field to PNG_IMAGE_VERSION and the 'opaque' pointer to NULL
|
||||||
|
* (this is REQUIRED, your program may crash if you don't do it.)
|
||||||
* 2) Call the appropriate png_image_begin_read... function.
|
* 2) Call the appropriate png_image_begin_read... function.
|
||||||
* 3) Set the png_image 'format' member to the required sample format.
|
* 3) Set the png_image 'format' member to the required sample format.
|
||||||
* 4) Allocate a buffer for the image and, if required, the color-map.
|
* 4) Allocate a buffer for the image and, if required, the color-map.
|
||||||
|
@ -3209,9 +3180,11 @@ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
|
||||||
*
|
*
|
||||||
* With all APIs row_stride is handled as in the read APIs - it is the spacing
|
* With all APIs row_stride is handled as in the read APIs - it is the spacing
|
||||||
* from one row to the next in component sized units (1 or 2 bytes) and if
|
* from one row to the next in component sized units (1 or 2 bytes) and if
|
||||||
* negative indicates a bottom-up row layout in the buffer.
|
* negative indicates a bottom-up row layout in the buffer. If row_stride is zero,
|
||||||
|
* libpng will calculate it for you from the image width and number of channels.
|
||||||
*
|
*
|
||||||
* Note that the write API does not support interlacing or sub-8-bit pixels.
|
* Note that the write API does not support interlacing, sub-8-bit pixels, indexed
|
||||||
|
* PNG (color_type 3) or most ancillary chunks.
|
||||||
*/
|
*/
|
||||||
#endif /* STDIO */
|
#endif /* STDIO */
|
||||||
#endif /* SIMPLIFIED_WRITE */
|
#endif /* SIMPLIFIED_WRITE */
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
/* pngconf.h - machine configurable file for libpng
|
/* pngconf.h - machine configurable file for libpng
|
||||||
*
|
*
|
||||||
* libpng version 1.6.17, March 26, 2015
|
* libpng version 1.6.18, July 23, 2015
|
||||||
*
|
*
|
||||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||||
|
@ -295,11 +295,11 @@
|
||||||
* table entries, so we discard it here. See the .dfn files in the
|
* table entries, so we discard it here. See the .dfn files in the
|
||||||
* scripts directory.
|
* scripts directory.
|
||||||
*/
|
*/
|
||||||
#ifndef PNG_EXPORTA
|
|
||||||
|
|
||||||
|
#ifndef PNG_EXPORTA
|
||||||
# define PNG_EXPORTA(ordinal, type, name, args, attributes) \
|
# define PNG_EXPORTA(ordinal, type, name, args, attributes) \
|
||||||
PNG_FUNCTION(PNG_EXPORT_TYPE(type), (PNGAPI name), PNGARG(args), \
|
PNG_FUNCTION(PNG_EXPORT_TYPE(type), (PNGAPI name), PNGARG(args), \
|
||||||
extern attributes)
|
PNG_LINKAGE_API attributes)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
|
/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/* pnglibconf.h - library build configuration */
|
/* pnglibconf.h - library build configuration */
|
||||||
|
|
||||||
/* libpng version 1.6.17, March 26, 2015 */
|
/* libpng version 1.6.18, July 23, 2015 */
|
||||||
|
|
||||||
/* Copyright (c) 1998-2014 Glenn Randers-Pehrson */
|
/* Copyright (c) 1998-2014 Glenn Randers-Pehrson */
|
||||||
|
|
||||||
|
@ -188,6 +188,10 @@
|
||||||
#define PNG_GAMMA_THRESHOLD_FIXED 5000
|
#define PNG_GAMMA_THRESHOLD_FIXED 5000
|
||||||
#define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE
|
#define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE
|
||||||
#define PNG_INFLATE_BUF_SIZE 1024
|
#define PNG_INFLATE_BUF_SIZE 1024
|
||||||
|
#define PNG_LINKAGE_API extern
|
||||||
|
#define PNG_LINKAGE_CALLBACK extern
|
||||||
|
#define PNG_LINKAGE_DATA extern
|
||||||
|
#define PNG_LINKAGE_FUNCTION extern
|
||||||
#define PNG_MAX_GAMMA_8 11
|
#define PNG_MAX_GAMMA_8 11
|
||||||
#define PNG_QUANTIZE_BLUE_BITS 5
|
#define PNG_QUANTIZE_BLUE_BITS 5
|
||||||
#define PNG_QUANTIZE_GREEN_BITS 5
|
#define PNG_QUANTIZE_GREEN_BITS 5
|
||||||
|
|
|
@ -77,6 +77,9 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
|
||||||
PNG_UNUSED(png_ptr)
|
PNG_UNUSED(png_ptr)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Some compilers complain that this is always true. However, it
|
||||||
|
* can be false when integer overflow happens.
|
||||||
|
*/
|
||||||
if (size > 0 && size <= PNG_SIZE_MAX
|
if (size > 0 && size <= PNG_SIZE_MAX
|
||||||
# ifdef PNG_MAX_MALLOC_64K
|
# ifdef PNG_MAX_MALLOC_64K
|
||||||
&& size <= 65536U
|
&& size <= 65536U
|
||||||
|
|
|
@ -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.17 [March 26, 2015]
|
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2015 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.)
|
||||||
|
@ -19,7 +19,6 @@
|
||||||
#define PNG_READ_SIG_MODE 0
|
#define PNG_READ_SIG_MODE 0
|
||||||
#define PNG_READ_CHUNK_MODE 1
|
#define PNG_READ_CHUNK_MODE 1
|
||||||
#define PNG_READ_IDAT_MODE 2
|
#define PNG_READ_IDAT_MODE 2
|
||||||
#define PNG_SKIP_MODE 3
|
|
||||||
#define PNG_READ_tEXt_MODE 4
|
#define PNG_READ_tEXt_MODE 4
|
||||||
#define PNG_READ_zTXt_MODE 5
|
#define PNG_READ_zTXt_MODE 5
|
||||||
#define PNG_READ_DONE_MODE 6
|
#define PNG_READ_DONE_MODE 6
|
||||||
|
@ -78,32 +77,14 @@ png_process_data_pause(png_structrp png_ptr, int save)
|
||||||
png_uint_32 PNGAPI
|
png_uint_32 PNGAPI
|
||||||
png_process_data_skip(png_structrp png_ptr)
|
png_process_data_skip(png_structrp png_ptr)
|
||||||
{
|
{
|
||||||
png_uint_32 remaining = 0;
|
/* TODO: Deprecate and remove this API.
|
||||||
|
* Somewhere the implementation of this seems to have been lost,
|
||||||
if (png_ptr != NULL && png_ptr->process_mode == PNG_SKIP_MODE &&
|
* or abandoned. It was only to support some internal back-door access
|
||||||
png_ptr->skip_length > 0)
|
* to png_struct) in libpng-1.4.x.
|
||||||
{
|
|
||||||
/* At the end of png_process_data the buffer size must be 0 (see the loop
|
|
||||||
* above) so we can detect a broken call here:
|
|
||||||
*/
|
*/
|
||||||
if (png_ptr->buffer_size != 0)
|
png_app_warning(png_ptr,
|
||||||
png_error(png_ptr,
|
"png_process_data_skip is not implemented in any current version of libpng");
|
||||||
"png_process_data_skip called inside png_process_data");
|
return 0;
|
||||||
|
|
||||||
/* If is impossible for there to be a saved buffer at this point -
|
|
||||||
* otherwise we could not be in SKIP mode. This will also happen if
|
|
||||||
* png_process_skip is called inside png_process_data (but only very
|
|
||||||
* rarely.)
|
|
||||||
*/
|
|
||||||
if (png_ptr->save_buffer_size != 0)
|
|
||||||
png_error(png_ptr, "png_process_data_skip called with saved data");
|
|
||||||
|
|
||||||
remaining = png_ptr->skip_length;
|
|
||||||
png_ptr->skip_length = 0;
|
|
||||||
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return remaining;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* What we do with the incoming data depends on what we were previously
|
/* What we do with the incoming data depends on what we were previously
|
||||||
|
@ -135,12 +116,6 @@ png_process_some_data(png_structrp png_ptr, png_inforp info_ptr)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case PNG_SKIP_MODE:
|
|
||||||
{
|
|
||||||
png_push_crc_finish(png_ptr);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
png_ptr->buffer_size = 0;
|
png_ptr->buffer_size = 0;
|
||||||
|
@ -439,69 +414,6 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
|
||||||
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
|
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
|
||||||
}
|
}
|
||||||
|
|
||||||
void /* PRIVATE */
|
|
||||||
png_push_crc_skip(png_structrp png_ptr, png_uint_32 skip)
|
|
||||||
{
|
|
||||||
png_ptr->process_mode = PNG_SKIP_MODE;
|
|
||||||
png_ptr->skip_length = skip;
|
|
||||||
}
|
|
||||||
|
|
||||||
void /* PRIVATE */
|
|
||||||
png_push_crc_finish(png_structrp png_ptr)
|
|
||||||
{
|
|
||||||
if (png_ptr->skip_length != 0 && png_ptr->save_buffer_size != 0)
|
|
||||||
{
|
|
||||||
png_size_t save_size = png_ptr->save_buffer_size;
|
|
||||||
png_uint_32 skip_length = png_ptr->skip_length;
|
|
||||||
|
|
||||||
/* We want the smaller of 'skip_length' and 'save_buffer_size', but
|
|
||||||
* they are of different types and we don't know which variable has the
|
|
||||||
* fewest bits. Carefully select the smaller and cast it to the type of
|
|
||||||
* the larger - this cannot overflow. Do not cast in the following test
|
|
||||||
* - it will break on either 16 or 64 bit platforms.
|
|
||||||
*/
|
|
||||||
if (skip_length < save_size)
|
|
||||||
save_size = (png_size_t)skip_length;
|
|
||||||
|
|
||||||
else
|
|
||||||
skip_length = (png_uint_32)save_size;
|
|
||||||
|
|
||||||
png_calculate_crc(png_ptr, png_ptr->save_buffer_ptr, save_size);
|
|
||||||
|
|
||||||
png_ptr->skip_length -= skip_length;
|
|
||||||
png_ptr->buffer_size -= save_size;
|
|
||||||
png_ptr->save_buffer_size -= save_size;
|
|
||||||
png_ptr->save_buffer_ptr += save_size;
|
|
||||||
}
|
|
||||||
if (png_ptr->skip_length != 0 && png_ptr->current_buffer_size != 0)
|
|
||||||
{
|
|
||||||
png_size_t save_size = png_ptr->current_buffer_size;
|
|
||||||
png_uint_32 skip_length = png_ptr->skip_length;
|
|
||||||
|
|
||||||
/* We want the smaller of 'skip_length' and 'current_buffer_size', here,
|
|
||||||
* the same problem exists as above and the same solution.
|
|
||||||
*/
|
|
||||||
if (skip_length < save_size)
|
|
||||||
save_size = (png_size_t)skip_length;
|
|
||||||
|
|
||||||
else
|
|
||||||
skip_length = (png_uint_32)save_size;
|
|
||||||
|
|
||||||
png_calculate_crc(png_ptr, png_ptr->current_buffer_ptr, save_size);
|
|
||||||
|
|
||||||
png_ptr->skip_length -= skip_length;
|
|
||||||
png_ptr->buffer_size -= save_size;
|
|
||||||
png_ptr->current_buffer_size -= save_size;
|
|
||||||
png_ptr->current_buffer_ptr += save_size;
|
|
||||||
}
|
|
||||||
if (png_ptr->skip_length == 0)
|
|
||||||
{
|
|
||||||
PNG_PUSH_SAVE_BUFFER_IF_LT(4)
|
|
||||||
png_crc_finish(png_ptr, 0);
|
|
||||||
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void PNGCBAPI
|
void PNGCBAPI
|
||||||
png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
png_push_fill_buffer(png_structp png_ptr, png_bytep buffer, png_size_t length)
|
||||||
{
|
{
|
||||||
|
@ -584,13 +496,11 @@ png_push_save_buffer(png_structrp png_ptr)
|
||||||
if (png_ptr->save_buffer == NULL)
|
if (png_ptr->save_buffer == NULL)
|
||||||
{
|
{
|
||||||
png_free(png_ptr, old_buffer);
|
png_free(png_ptr, old_buffer);
|
||||||
old_buffer = NULL;
|
|
||||||
png_error(png_ptr, "Insufficient memory for save_buffer");
|
png_error(png_ptr, "Insufficient memory for save_buffer");
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
|
memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
|
||||||
png_free(png_ptr, old_buffer);
|
png_free(png_ptr, old_buffer);
|
||||||
old_buffer = NULL;
|
|
||||||
png_ptr->save_buffer_max = new_max;
|
png_ptr->save_buffer_max = new_max;
|
||||||
}
|
}
|
||||||
if (png_ptr->current_buffer_size)
|
if (png_ptr->current_buffer_size)
|
||||||
|
@ -696,6 +606,7 @@ png_push_read_IDAT(png_structrp png_ptr)
|
||||||
png_ptr->current_buffer_size -= save_size;
|
png_ptr->current_buffer_size -= save_size;
|
||||||
png_ptr->current_buffer_ptr += save_size;
|
png_ptr->current_buffer_ptr += save_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (png_ptr->idat_size == 0)
|
if (png_ptr->idat_size == 0)
|
||||||
{
|
{
|
||||||
PNG_PUSH_SAVE_BUFFER_IF_LT(4)
|
PNG_PUSH_SAVE_BUFFER_IF_LT(4)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
/* pngpriv.h - private declarations for use inside libpng
|
/* pngpriv.h - private declarations for use inside libpng
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.17 [March 26, 2015]
|
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2015 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.)
|
||||||
|
@ -118,8 +118,12 @@
|
||||||
* to compile with an appropriate #error if ALIGNED_MEMORY has been turned
|
* to compile with an appropriate #error if ALIGNED_MEMORY has been turned
|
||||||
* off.
|
* off.
|
||||||
*
|
*
|
||||||
* Note that gcc-4.9 defines __ARM_NEON instead of __ARM_NEON__, so we
|
* Note that gcc-4.9 defines __ARM_NEON instead of the deprecated
|
||||||
* check both variants.
|
* __ARM_NEON__, so we check both variants.
|
||||||
|
*
|
||||||
|
* To disable ARM_NEON optimizations entirely, and skip compiling the
|
||||||
|
* associated assembler code, pass --enable-arm-neon=no to configure
|
||||||
|
* or put -DPNG_ARM_NEON_OPT=0 in CPPFLAGS.
|
||||||
*/
|
*/
|
||||||
# if (defined(__ARM_NEON__) || defined(__ARM_NEON)) && \
|
# if (defined(__ARM_NEON__) || defined(__ARM_NEON)) && \
|
||||||
defined(PNG_ALIGNED_MEMORY_SUPPORTED)
|
defined(PNG_ALIGNED_MEMORY_SUPPORTED)
|
||||||
|
@ -248,17 +252,18 @@
|
||||||
* always be used to declare an extern data or function object in this file.
|
* always be used to declare an extern data or function object in this file.
|
||||||
*/
|
*/
|
||||||
#ifndef PNG_INTERNAL_DATA
|
#ifndef PNG_INTERNAL_DATA
|
||||||
# define PNG_INTERNAL_DATA(type, name, array) extern type name array
|
# define PNG_INTERNAL_DATA(type, name, array) PNG_LINKAGE_DATA type name array
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PNG_INTERNAL_FUNCTION
|
#ifndef PNG_INTERNAL_FUNCTION
|
||||||
# define PNG_INTERNAL_FUNCTION(type, name, args, attributes)\
|
# define PNG_INTERNAL_FUNCTION(type, name, args, attributes)\
|
||||||
extern PNG_FUNCTION(type, name, args, PNG_EMPTY attributes)
|
PNG_LINKAGE_FUNCTION PNG_FUNCTION(type, name, args, PNG_EMPTY attributes)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef PNG_INTERNAL_CALLBACK
|
#ifndef PNG_INTERNAL_CALLBACK
|
||||||
# define PNG_INTERNAL_CALLBACK(type, name, args, attributes)\
|
# define PNG_INTERNAL_CALLBACK(type, name, args, attributes)\
|
||||||
extern PNG_FUNCTION(type, (PNGCBAPI name), args, PNG_EMPTY attributes)
|
PNG_LINKAGE_CALLBACK PNG_FUNCTION(type, (PNGCBAPI name), args,\
|
||||||
|
PNG_EMPTY attributes)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If floating or fixed point APIs are disabled they may still be compiled
|
/* If floating or fixed point APIs are disabled they may still be compiled
|
||||||
|
@ -296,6 +301,22 @@
|
||||||
# define PNG_DLL_EXPORT
|
# define PNG_DLL_EXPORT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* This is a global switch to set the compilation for an installed system
|
||||||
|
* (a release build). It can be set for testing debug builds to ensure that
|
||||||
|
* they will compile when the build type is switched to RC or STABLE, the
|
||||||
|
* default is just to use PNG_LIBPNG_BUILD_BASE_TYPE. Set this in CPPFLAGS
|
||||||
|
* with either:
|
||||||
|
*
|
||||||
|
* -DPNG_RELEASE_BUILD Turns on the release compile path
|
||||||
|
* -DPNG_RELEASE_BUILD=0 Turns it off
|
||||||
|
* or in your pngusr.h with
|
||||||
|
* #define PNG_RELEASE_BUILD=1 Turns on the release compile path
|
||||||
|
* #define PNG_RELEASE_BUILD=0 Turns it off
|
||||||
|
*/
|
||||||
|
#ifndef PNG_RELEASE_BUILD
|
||||||
|
# define PNG_RELEASE_BUILD (PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC)
|
||||||
|
#endif
|
||||||
|
|
||||||
/* SECURITY and SAFETY:
|
/* SECURITY and SAFETY:
|
||||||
*
|
*
|
||||||
* libpng is built with support for internal limits on image dimensions and
|
* libpng is built with support for internal limits on image dimensions and
|
||||||
|
@ -777,6 +798,24 @@
|
||||||
#include "pngstruct.h"
|
#include "pngstruct.h"
|
||||||
#include "pnginfo.h"
|
#include "pnginfo.h"
|
||||||
|
|
||||||
|
/* Validate the include paths - the include path used to generate pnglibconf.h
|
||||||
|
* must match that used in the build, or we must be using pnglibconf.h.prebuilt:
|
||||||
|
*/
|
||||||
|
#if PNG_ZLIB_VERNUM != 0 && PNG_ZLIB_VERNUM != ZLIB_VERNUM
|
||||||
|
# error ZLIB_VERNUM != PNG_ZLIB_VERNUM \
|
||||||
|
"-I (include path) error: see the notes in pngpriv.h"
|
||||||
|
/* This means that when pnglibconf.h was built the copy of zlib.h that it
|
||||||
|
* used is not the same as the one being used here. Because the build of
|
||||||
|
* libpng makes decisions to use inflateInit2 and inflateReset2 based on the
|
||||||
|
* zlib version number and because this affects handling of certain broken
|
||||||
|
* PNG files the -I directives must match.
|
||||||
|
*
|
||||||
|
* The most likely explanation is that you passed a -I in CFLAGS. This will
|
||||||
|
* not work; all the preprocessor directories and in particular all the -I
|
||||||
|
* directives must be in CPPFLAGS.
|
||||||
|
*/
|
||||||
|
#endif
|
||||||
|
|
||||||
/* This is used for 16 bit gamma tables -- only the top level pointers are
|
/* This is used for 16 bit gamma tables -- only the top level pointers are
|
||||||
* const; this could be changed:
|
* const; this could be changed:
|
||||||
*/
|
*/
|
||||||
|
@ -1354,10 +1393,6 @@ PNG_INTERNAL_FUNCTION(void,png_push_read_chunk,(png_structrp png_ptr,
|
||||||
PNG_INTERNAL_FUNCTION(void,png_push_read_sig,(png_structrp png_ptr,
|
PNG_INTERNAL_FUNCTION(void,png_push_read_sig,(png_structrp png_ptr,
|
||||||
png_inforp info_ptr),PNG_EMPTY);
|
png_inforp info_ptr),PNG_EMPTY);
|
||||||
PNG_INTERNAL_FUNCTION(void,png_push_check_crc,(png_structrp png_ptr),PNG_EMPTY);
|
PNG_INTERNAL_FUNCTION(void,png_push_check_crc,(png_structrp png_ptr),PNG_EMPTY);
|
||||||
PNG_INTERNAL_FUNCTION(void,png_push_crc_skip,(png_structrp png_ptr,
|
|
||||||
png_uint_32 length),PNG_EMPTY);
|
|
||||||
PNG_INTERNAL_FUNCTION(void,png_push_crc_finish,(png_structrp png_ptr),
|
|
||||||
PNG_EMPTY);
|
|
||||||
PNG_INTERNAL_FUNCTION(void,png_push_save_buffer,(png_structrp png_ptr),
|
PNG_INTERNAL_FUNCTION(void,png_push_save_buffer,(png_structrp png_ptr),
|
||||||
PNG_EMPTY);
|
PNG_EMPTY);
|
||||||
PNG_INTERNAL_FUNCTION(void,png_push_restore_buffer,(png_structrp png_ptr,
|
PNG_INTERNAL_FUNCTION(void,png_push_restore_buffer,(png_structrp png_ptr,
|
||||||
|
|
|
@ -63,7 +63,7 @@ png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||||
/* In stable builds only warn if an application error can be completely
|
/* In stable builds only warn if an application error can be completely
|
||||||
* handled.
|
* handled.
|
||||||
*/
|
*/
|
||||||
# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
|
# if PNG_RELEASE_BUILD
|
||||||
png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;
|
png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;
|
||||||
# endif
|
# endif
|
||||||
# endif
|
# endif
|
||||||
|
|
|
@ -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.17 [March 26, 2015]
|
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2015 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.)
|
||||||
|
@ -4460,7 +4460,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||||
|
|
||||||
for (i = 0; i < row_width; i++)
|
for (i = 0; i < row_width; i++)
|
||||||
{
|
{
|
||||||
if (*sp == gray)
|
if ((*sp & 0xffU) == gray)
|
||||||
*dp-- = 0;
|
*dp-- = 0;
|
||||||
|
|
||||||
else
|
else
|
||||||
|
@ -4478,7 +4478,8 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
||||||
dp = row + (row_info->rowbytes << 1) - 1;
|
dp = row + (row_info->rowbytes << 1) - 1;
|
||||||
for (i = 0; i < row_width; i++)
|
for (i = 0; i < row_width; i++)
|
||||||
{
|
{
|
||||||
if (*(sp - 1) == gray_high && *(sp) == gray_low)
|
if ((*(sp - 1) & 0xffU) == gray_high &&
|
||||||
|
(*(sp) & 0xffU) == gray_low)
|
||||||
{
|
{
|
||||||
*dp-- = 0;
|
*dp-- = 0;
|
||||||
*dp-- = 0;
|
*dp-- = 0;
|
||||||
|
|
|
@ -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.17 [March 26, 2015]
|
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2015 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.)
|
||||||
|
@ -341,7 +341,7 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
|
||||||
* are minimal.
|
* are minimal.
|
||||||
*/
|
*/
|
||||||
(void)png_safecat(msg, (sizeof msg), 4, " using zstream");
|
(void)png_safecat(msg, (sizeof msg), 4, " using zstream");
|
||||||
#if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
|
#if PNG_RELEASE_BUILD
|
||||||
png_chunk_warning(png_ptr, msg);
|
png_chunk_warning(png_ptr, msg);
|
||||||
png_ptr->zowner = 0;
|
png_ptr->zowner = 0;
|
||||||
#else
|
#else
|
||||||
|
@ -575,7 +575,7 @@ png_decompress_chunk(png_structrp png_ptr,
|
||||||
*/
|
*/
|
||||||
png_alloc_size_t limit = PNG_SIZE_MAX;
|
png_alloc_size_t limit = PNG_SIZE_MAX;
|
||||||
|
|
||||||
# ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
|
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||||
if (png_ptr->user_chunk_malloc_max > 0 &&
|
if (png_ptr->user_chunk_malloc_max > 0 &&
|
||||||
png_ptr->user_chunk_malloc_max < limit)
|
png_ptr->user_chunk_malloc_max < limit)
|
||||||
limit = png_ptr->user_chunk_malloc_max;
|
limit = png_ptr->user_chunk_malloc_max;
|
||||||
|
@ -670,7 +670,6 @@ png_decompress_chunk(png_structrp png_ptr,
|
||||||
* success)
|
* success)
|
||||||
*/
|
*/
|
||||||
png_free(png_ptr, text);
|
png_free(png_ptr, text);
|
||||||
text = NULL;
|
|
||||||
|
|
||||||
/* This really is very benign, but it's still an error because
|
/* This really is very benign, but it's still an error because
|
||||||
* the extra space may otherwise be used as a Trojan Horse.
|
* the extra space may otherwise be used as a Trojan Horse.
|
||||||
|
@ -1147,11 +1146,13 @@ png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (i=0; i<truelen; ++i)
|
for (i=0; i<truelen; ++i)
|
||||||
|
{
|
||||||
if (buf[i] == 0 || buf[i] > sample_depth)
|
if (buf[i] == 0 || buf[i] > sample_depth)
|
||||||
{
|
{
|
||||||
png_chunk_benign_error(png_ptr, "invalid");
|
png_chunk_benign_error(png_ptr, "invalid");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||||
{
|
{
|
||||||
|
@ -1817,7 +1818,8 @@ png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length > png_ptr->num_palette || length > PNG_MAX_PALETTE_LENGTH ||
|
if (length > png_ptr->num_palette ||
|
||||||
|
length > (unsigned int) PNG_MAX_PALETTE_LENGTH ||
|
||||||
length == 0)
|
length == 0)
|
||||||
{
|
{
|
||||||
png_crc_finish(png_ptr, length);
|
png_crc_finish(png_ptr, length);
|
||||||
|
@ -1980,7 +1982,7 @@ png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||||
|
|
||||||
num = length / 2 ;
|
num = length / 2 ;
|
||||||
|
|
||||||
if (num != png_ptr->num_palette || num > PNG_MAX_PALETTE_LENGTH)
|
if (num != png_ptr->num_palette || num > (unsigned int) PNG_MAX_PALETTE_LENGTH)
|
||||||
{
|
{
|
||||||
png_crc_finish(png_ptr, length);
|
png_crc_finish(png_ptr, length);
|
||||||
png_chunk_benign_error(png_ptr, "invalid");
|
png_chunk_benign_error(png_ptr, "invalid");
|
||||||
|
@ -2715,7 +2717,7 @@ png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length)
|
||||||
png_ptr->unknown_chunk.data = NULL;
|
png_ptr->unknown_chunk.data = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
# ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
|
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||||
if (png_ptr->user_chunk_malloc_max > 0 &&
|
if (png_ptr->user_chunk_malloc_max > 0 &&
|
||||||
png_ptr->user_chunk_malloc_max < limit)
|
png_ptr->user_chunk_malloc_max < limit)
|
||||||
limit = png_ptr->user_chunk_malloc_max;
|
limit = png_ptr->user_chunk_malloc_max;
|
||||||
|
|
|
@ -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.17 [March 26, 2015]
|
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2015 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.)
|
||||||
|
@ -673,7 +673,6 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||||
if (new_iccp_profile == NULL)
|
if (new_iccp_profile == NULL)
|
||||||
{
|
{
|
||||||
png_free(png_ptr, new_iccp_name);
|
png_free(png_ptr, new_iccp_name);
|
||||||
new_iccp_name = NULL;
|
|
||||||
png_benign_error(png_ptr,
|
png_benign_error(png_ptr,
|
||||||
"Insufficient memory to process iCCP profile");
|
"Insufficient memory to process iCCP profile");
|
||||||
|
|
||||||
|
@ -710,7 +709,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
png_debug1(1, "in %lx storage function", png_ptr == NULL ? "unexpected" :
|
png_debug1(1, "in %lx storage function", png_ptr == NULL ? 0xabadca11 :
|
||||||
(unsigned long)png_ptr->chunk_name);
|
(unsigned long)png_ptr->chunk_name);
|
||||||
|
|
||||||
if (png_ptr == NULL || info_ptr == NULL || num_text <= 0 || text_ptr == NULL)
|
if (png_ptr == NULL || info_ptr == NULL || num_text <= 0 || text_ptr == NULL)
|
||||||
|
@ -1522,6 +1521,9 @@ png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __COVERITY__
|
#ifndef __COVERITY__
|
||||||
|
/* Some compilers complain that this is always false. However, it
|
||||||
|
* can be true when integer overflow happens.
|
||||||
|
*/
|
||||||
if (size > ZLIB_IO_MAX)
|
if (size > ZLIB_IO_MAX)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr,
|
png_warning(png_ptr,
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
|
|
||||||
/* pngstruct.h - header file for PNG reference library
|
/* pngstruct.h - header file for PNG reference library
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2015 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.)
|
||||||
*
|
*
|
||||||
|
@ -219,16 +219,18 @@ struct png_struct_def
|
||||||
png_uint_32 row_number; /* current row in interlace pass */
|
png_uint_32 row_number; /* current row in interlace pass */
|
||||||
png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */
|
png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */
|
||||||
png_bytep prev_row; /* buffer to save previous (unfiltered) row.
|
png_bytep prev_row; /* buffer to save previous (unfiltered) row.
|
||||||
* This is a pointer into big_prev_row
|
* While reading this is a pointer into
|
||||||
|
* big_prev_row; while writing it is separately
|
||||||
|
* allocated if needed.
|
||||||
*/
|
*/
|
||||||
png_bytep row_buf; /* buffer to save current (unfiltered) row.
|
png_bytep row_buf; /* buffer to save current (unfiltered) row.
|
||||||
* This is a pointer into big_row_buf
|
* While reading, this is a pointer into
|
||||||
|
* big_row_buf; while writing it is separately
|
||||||
|
* allocated.
|
||||||
*/
|
*/
|
||||||
#ifdef PNG_WRITE_SUPPORTED
|
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||||
png_bytep sub_row; /* buffer to save "sub" row when filtering */
|
png_bytep try_row; /* buffer to save trial row when filtering */
|
||||||
png_bytep up_row; /* buffer to save "up" row when filtering */
|
png_bytep tst_row; /* buffer to save best trial row when filtering */
|
||||||
png_bytep avg_row; /* buffer to save "avg" row when filtering */
|
|
||||||
png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
|
|
||||||
#endif
|
#endif
|
||||||
png_size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */
|
png_size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */
|
||||||
|
|
||||||
|
@ -346,16 +348,6 @@ struct png_struct_def
|
||||||
png_bytep quantize_index; /* index translation for palette files */
|
png_bytep quantize_index; /* index translation for palette files */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
|
||||||
png_byte heuristic_method; /* heuristic for row filter selection */
|
|
||||||
png_byte num_prev_filters; /* number of weights for previous rows */
|
|
||||||
png_bytep prev_filters; /* filter type(s) of previous row(s) */
|
|
||||||
png_uint_16p filter_weights; /* weight(s) for previous line(s) */
|
|
||||||
png_uint_16p inv_filter_weights; /* 1/weight(s) for previous line(s) */
|
|
||||||
png_uint_16p filter_costs; /* relative filter calculation cost */
|
|
||||||
png_uint_16p inv_filter_costs; /* 1/relative filter calculation cost */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Options */
|
/* Options */
|
||||||
#ifdef PNG_SET_OPTION_SUPPORTED
|
#ifdef PNG_SET_OPTION_SUPPORTED
|
||||||
png_byte options; /* On/off state (up to 4 options) */
|
png_byte options; /* On/off state (up to 4 options) */
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.17 [March 26, 2015]
|
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2015 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.)
|
||||||
|
@ -704,7 +704,7 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
|
||||||
*/
|
*/
|
||||||
for (; rp > png_ptr->row_buf; rp--)
|
for (; rp > png_ptr->row_buf; rp--)
|
||||||
{
|
{
|
||||||
if (*rp >> padding != 0)
|
if ((*rp >> padding) != 0)
|
||||||
png_ptr->num_palette_max = 1;
|
png_ptr->num_palette_max = 1;
|
||||||
padding = 0;
|
padding = 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.17 [March 26, 2015]
|
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2015 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.)
|
||||||
|
@ -97,7 +97,8 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||||
if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) != 0 && \
|
if ((png_ptr->mode & PNG_HAVE_PNG_SIGNATURE) != 0 && \
|
||||||
png_ptr->mng_features_permitted != 0)
|
png_ptr->mng_features_permitted != 0)
|
||||||
{
|
{
|
||||||
png_warning(png_ptr, "MNG features are not allowed in a PNG datastream");
|
png_warning(png_ptr,
|
||||||
|
"MNG features are not allowed in a PNG datastream");
|
||||||
png_ptr->mng_features_permitted = 0;
|
png_ptr->mng_features_permitted = 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -117,15 +118,15 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||||
* flag set, and if it does, writes the chunk.
|
* flag set, and if it does, writes the chunk.
|
||||||
*
|
*
|
||||||
* 1.6.0: COLORSPACE support controls the writing of these chunks too, and
|
* 1.6.0: COLORSPACE support controls the writing of these chunks too, and
|
||||||
* the chunks will be written if the WRITE routine is there and information
|
* the chunks will be written if the WRITE routine is there and
|
||||||
* is available in the COLORSPACE. (See png_colorspace_sync_info in png.c
|
* information * is available in the COLORSPACE. (See
|
||||||
* for where the valid flags get set.)
|
* png_colorspace_sync_info in png.c for where the valid flags get set.)
|
||||||
*
|
*
|
||||||
* Under certain circumstances the colorspace can be invalidated without
|
* Under certain circumstances the colorspace can be invalidated without
|
||||||
* syncing the info_struct 'valid' flags; this happens if libpng detects and
|
* syncing the info_struct 'valid' flags; this happens if libpng detects
|
||||||
* error and calls png_error while the color space is being set, yet the
|
* an error and calls png_error while the color space is being set, yet
|
||||||
* application continues writing the PNG. So check the 'invalid' flag here
|
* the application continues writing the PNG. So check the 'invalid'
|
||||||
* too.
|
* flag here too.
|
||||||
*/
|
*/
|
||||||
#ifdef PNG_GAMMA_SUPPORTED
|
#ifdef PNG_GAMMA_SUPPORTED
|
||||||
# ifdef PNG_WRITE_gAMA_SUPPORTED
|
# ifdef PNG_WRITE_gAMA_SUPPORTED
|
||||||
|
@ -216,8 +217,13 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||||
if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0 &&
|
if ((png_ptr->transformations & PNG_INVERT_ALPHA) != 0 &&
|
||||||
info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||||
{
|
{
|
||||||
int j;
|
int j, jend;
|
||||||
for (j = 0; j<(int)info_ptr->num_trans; j++)
|
|
||||||
|
jend = info_ptr->num_trans;
|
||||||
|
if (jend > PNG_MAX_PALETTE_LENGTH)
|
||||||
|
jend = PNG_MAX_PALETTE_LENGTH;
|
||||||
|
|
||||||
|
for (j = 0; j<jend; ++j)
|
||||||
info_ptr->trans_alpha[j] =
|
info_ptr->trans_alpha[j] =
|
||||||
(png_byte)(255 - info_ptr->trans_alpha[j]);
|
(png_byte)(255 - info_ptr->trans_alpha[j]);
|
||||||
}
|
}
|
||||||
|
@ -538,7 +544,7 @@ png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
|
||||||
/* App warnings are warnings in release (or release candidate) builds but
|
/* App warnings are warnings in release (or release candidate) builds but
|
||||||
* are errors during development.
|
* are errors during development.
|
||||||
*/
|
*/
|
||||||
#if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
|
#if PNG_RELEASE_BUILD
|
||||||
png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;
|
png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -917,10 +923,6 @@ png_write_flush(png_structrp png_ptr)
|
||||||
}
|
}
|
||||||
#endif /* WRITE_FLUSH */
|
#endif /* WRITE_FLUSH */
|
||||||
|
|
||||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
|
||||||
static void png_reset_filter_heuristics(png_structrp png_ptr);/* forward decl */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Free any memory used in png_ptr struct without freeing the struct itself. */
|
/* Free any memory used in png_ptr struct without freeing the struct itself. */
|
||||||
static void
|
static void
|
||||||
png_write_destroy(png_structrp png_ptr)
|
png_write_destroy(png_structrp png_ptr)
|
||||||
|
@ -937,24 +939,11 @@ png_write_destroy(png_structrp png_ptr)
|
||||||
png_ptr->row_buf = NULL;
|
png_ptr->row_buf = NULL;
|
||||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||||
png_free(png_ptr, png_ptr->prev_row);
|
png_free(png_ptr, png_ptr->prev_row);
|
||||||
png_free(png_ptr, png_ptr->sub_row);
|
png_free(png_ptr, png_ptr->try_row);
|
||||||
png_free(png_ptr, png_ptr->up_row);
|
png_free(png_ptr, png_ptr->tst_row);
|
||||||
png_free(png_ptr, png_ptr->avg_row);
|
|
||||||
png_free(png_ptr, png_ptr->paeth_row);
|
|
||||||
png_ptr->prev_row = NULL;
|
png_ptr->prev_row = NULL;
|
||||||
png_ptr->sub_row = NULL;
|
png_ptr->try_row = NULL;
|
||||||
png_ptr->up_row = NULL;
|
png_ptr->tst_row = NULL;
|
||||||
png_ptr->avg_row = NULL;
|
|
||||||
png_ptr->paeth_row = NULL;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
|
|
||||||
/* Use this to save a little code space, it doesn't free the filter_costs */
|
|
||||||
png_reset_filter_heuristics(png_ptr);
|
|
||||||
png_free(png_ptr, png_ptr->filter_costs);
|
|
||||||
png_free(png_ptr, png_ptr->inv_filter_costs);
|
|
||||||
png_ptr->filter_costs = NULL;
|
|
||||||
png_ptr->inv_filter_costs = NULL;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||||
|
@ -1044,6 +1033,7 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
||||||
#endif /* WRITE_FILTER */
|
#endif /* WRITE_FILTER */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||||
/* If we have allocated the row_buf, this means we have already started
|
/* If we have allocated the row_buf, this means we have already started
|
||||||
* with the image and we should have allocated all of the filter buffers
|
* with the image and we should have allocated all of the filter buffers
|
||||||
* that have been selected. If prev_row isn't already allocated, then
|
* that have been selected. If prev_row isn't already allocated, then
|
||||||
|
@ -1052,203 +1042,76 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
||||||
* wants to start and stop using particular filters during compression,
|
* wants to start and stop using particular filters during compression,
|
||||||
* it should start out with all of the filters, and then remove them
|
* it should start out with all of the filters, and then remove them
|
||||||
* or add them back after the start of compression.
|
* or add them back after the start of compression.
|
||||||
|
*
|
||||||
|
* NOTE: this is a nasty constraint on the code, because it means that the
|
||||||
|
* prev_row buffer must be maintained even if there are currently no
|
||||||
|
* 'prev_row' requiring filters active.
|
||||||
*/
|
*/
|
||||||
if (png_ptr->row_buf != NULL)
|
if (png_ptr->row_buf != NULL)
|
||||||
{
|
{
|
||||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
int num_filters;
|
||||||
if ((png_ptr->do_filter & PNG_FILTER_SUB) != 0 &&
|
png_alloc_size_t buf_size;
|
||||||
png_ptr->sub_row == NULL)
|
|
||||||
|
/* Repeat the checks in png_write_start_row; 1 pixel high or wide
|
||||||
|
* images cannot benefit from certain filters. If this isn't done here
|
||||||
|
* the check below will fire on 1 pixel high images.
|
||||||
|
*/
|
||||||
|
if (png_ptr->height == 1)
|
||||||
|
filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH);
|
||||||
|
|
||||||
|
if (png_ptr->width == 1)
|
||||||
|
filters &= ~(PNG_FILTER_SUB|PNG_FILTER_AVG|PNG_FILTER_PAETH);
|
||||||
|
|
||||||
|
if ((filters & (PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH)) != 0
|
||||||
|
&& png_ptr->prev_row == NULL)
|
||||||
{
|
{
|
||||||
png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,
|
/* This is the error case, however it is benign - the previous row
|
||||||
(png_ptr->rowbytes + 1));
|
* is not available so the filter can't be used. Just warn here.
|
||||||
png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
|
*/
|
||||||
|
png_app_warning(png_ptr,
|
||||||
|
"png_set_filter: UP/AVG/PAETH cannot be added after start");
|
||||||
|
filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((png_ptr->do_filter & PNG_FILTER_UP) != 0 &&
|
num_filters = 0;
|
||||||
png_ptr->up_row == NULL)
|
|
||||||
{
|
|
||||||
if (png_ptr->prev_row == NULL)
|
|
||||||
{
|
|
||||||
png_warning(png_ptr, "Can't add Up filter after starting");
|
|
||||||
png_ptr->do_filter = (png_byte)(png_ptr->do_filter &
|
|
||||||
~PNG_FILTER_UP);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
if (filters & PNG_FILTER_SUB)
|
||||||
{
|
num_filters++;
|
||||||
png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
|
|
||||||
(png_ptr->rowbytes + 1));
|
|
||||||
png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((png_ptr->do_filter & PNG_FILTER_AVG) != 0 &&
|
if (filters & PNG_FILTER_UP)
|
||||||
png_ptr->avg_row == NULL)
|
num_filters++;
|
||||||
{
|
|
||||||
if (png_ptr->prev_row == NULL)
|
|
||||||
{
|
|
||||||
png_warning(png_ptr, "Can't add Average filter after starting");
|
|
||||||
png_ptr->do_filter = (png_byte)(png_ptr->do_filter &
|
|
||||||
~PNG_FILTER_AVG);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
if (filters & PNG_FILTER_AVG)
|
||||||
{
|
num_filters++;
|
||||||
png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
|
|
||||||
(png_ptr->rowbytes + 1));
|
|
||||||
png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((png_ptr->do_filter & PNG_FILTER_PAETH) != 0 &&
|
if (filters & PNG_FILTER_PAETH)
|
||||||
png_ptr->paeth_row == NULL)
|
num_filters++;
|
||||||
{
|
|
||||||
if (png_ptr->prev_row == NULL)
|
|
||||||
{
|
|
||||||
png_warning(png_ptr, "Can't add Paeth filter after starting");
|
|
||||||
png_ptr->do_filter &= (png_byte)(~PNG_FILTER_PAETH);
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
/* Allocate needed row buffers if they have not already been
|
||||||
{
|
* allocated.
|
||||||
png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,
|
*/
|
||||||
(png_ptr->rowbytes + 1));
|
buf_size = PNG_ROWBYTES(png_ptr->usr_channels * png_ptr->usr_bit_depth,
|
||||||
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
|
png_ptr->width) + 1;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (png_ptr->do_filter == PNG_NO_FILTERS)
|
if (png_ptr->try_row == NULL)
|
||||||
#endif /* WRITE_FILTER */
|
png_ptr->try_row = png_voidcast(png_bytep,
|
||||||
png_ptr->do_filter = PNG_FILTER_NONE;
|
png_malloc(png_ptr, buf_size));
|
||||||
|
|
||||||
|
if (num_filters > 1)
|
||||||
|
{
|
||||||
|
if (png_ptr->tst_row == NULL)
|
||||||
|
png_ptr->tst_row = png_voidcast(png_bytep,
|
||||||
|
png_malloc(png_ptr, buf_size));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
png_ptr->do_filter = (png_byte)filters;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
else
|
else
|
||||||
png_error(png_ptr, "Unknown custom filter method");
|
png_error(png_ptr, "Unknown custom filter method");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* This allows us to influence the way in which libpng chooses the "best"
|
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */
|
||||||
* filter for the current scanline. While the "minimum-sum-of-absolute-
|
|
||||||
* differences metric is relatively fast and effective, there is some
|
|
||||||
* question as to whether it can be improved upon by trying to keep the
|
|
||||||
* filtered data going to zlib more consistent, hopefully resulting in
|
|
||||||
* better compression.
|
|
||||||
*/
|
|
||||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* GRR 970116 */
|
|
||||||
/* Convenience reset API. */
|
|
||||||
static void
|
|
||||||
png_reset_filter_heuristics(png_structrp png_ptr)
|
|
||||||
{
|
|
||||||
/* Clear out any old values in the 'weights' - this must be done because if
|
|
||||||
* the app calls set_filter_heuristics multiple times with different
|
|
||||||
* 'num_weights' values we would otherwise potentially have wrong sized
|
|
||||||
* arrays.
|
|
||||||
*/
|
|
||||||
png_ptr->num_prev_filters = 0;
|
|
||||||
png_ptr->heuristic_method = PNG_FILTER_HEURISTIC_UNWEIGHTED;
|
|
||||||
if (png_ptr->prev_filters != NULL)
|
|
||||||
{
|
|
||||||
png_bytep old = png_ptr->prev_filters;
|
|
||||||
png_ptr->prev_filters = NULL;
|
|
||||||
png_free(png_ptr, old);
|
|
||||||
}
|
|
||||||
if (png_ptr->filter_weights != NULL)
|
|
||||||
{
|
|
||||||
png_uint_16p old = png_ptr->filter_weights;
|
|
||||||
png_ptr->filter_weights = NULL;
|
|
||||||
png_free(png_ptr, old);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (png_ptr->inv_filter_weights != NULL)
|
|
||||||
{
|
|
||||||
png_uint_16p old = png_ptr->inv_filter_weights;
|
|
||||||
png_ptr->inv_filter_weights = NULL;
|
|
||||||
png_free(png_ptr, old);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Leave the filter_costs - this array is fixed size. */
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
png_init_filter_heuristics(png_structrp png_ptr, int heuristic_method,
|
|
||||||
int num_weights)
|
|
||||||
{
|
|
||||||
if (png_ptr == NULL)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Clear out the arrays */
|
|
||||||
png_reset_filter_heuristics(png_ptr);
|
|
||||||
|
|
||||||
/* Check arguments; the 'reset' function makes the correct settings for the
|
|
||||||
* unweighted case, but we must handle the weight case by initializing the
|
|
||||||
* arrays for the caller.
|
|
||||||
*/
|
|
||||||
if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
|
|
||||||
if (num_weights > 0)
|
|
||||||
{
|
|
||||||
png_ptr->prev_filters = (png_bytep)png_malloc(png_ptr,
|
|
||||||
(png_uint_32)((sizeof (png_byte)) * num_weights));
|
|
||||||
|
|
||||||
/* To make sure that the weighting starts out fairly */
|
|
||||||
for (i = 0; i < num_weights; i++)
|
|
||||||
{
|
|
||||||
png_ptr->prev_filters[i] = 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
png_ptr->filter_weights = (png_uint_16p)png_malloc(png_ptr,
|
|
||||||
(png_uint_32)((sizeof (png_uint_16)) * num_weights));
|
|
||||||
|
|
||||||
png_ptr->inv_filter_weights = (png_uint_16p)png_malloc(png_ptr,
|
|
||||||
(png_uint_32)((sizeof (png_uint_16)) * num_weights));
|
|
||||||
|
|
||||||
for (i = 0; i < num_weights; i++)
|
|
||||||
{
|
|
||||||
png_ptr->inv_filter_weights[i] =
|
|
||||||
png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Safe to set this now */
|
|
||||||
png_ptr->num_prev_filters = (png_byte)num_weights;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* If, in the future, there are other filter methods, this would
|
|
||||||
* need to be based on png_ptr->filter.
|
|
||||||
*/
|
|
||||||
if (png_ptr->filter_costs == NULL)
|
|
||||||
{
|
|
||||||
png_ptr->filter_costs = (png_uint_16p)png_malloc(png_ptr,
|
|
||||||
(png_uint_32)((sizeof (png_uint_16)) * PNG_FILTER_VALUE_LAST));
|
|
||||||
|
|
||||||
png_ptr->inv_filter_costs = (png_uint_16p)png_malloc(png_ptr,
|
|
||||||
(png_uint_32)((sizeof (png_uint_16)) * PNG_FILTER_VALUE_LAST));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < PNG_FILTER_VALUE_LAST; i++)
|
|
||||||
{
|
|
||||||
png_ptr->inv_filter_costs[i] =
|
|
||||||
png_ptr->filter_costs[i] = PNG_COST_FACTOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* All the arrays are inited, safe to set this: */
|
|
||||||
png_ptr->heuristic_method = PNG_FILTER_HEURISTIC_WEIGHTED;
|
|
||||||
|
|
||||||
/* Return the 'ok' code. */
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if (heuristic_method == PNG_FILTER_HEURISTIC_DEFAULT ||
|
|
||||||
heuristic_method == PNG_FILTER_HEURISTIC_UNWEIGHTED)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
png_warning(png_ptr, "Unknown filter heuristic method");
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Provide floating and fixed point APIs */
|
/* Provide floating and fixed point APIs */
|
||||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||||
void PNGAPI
|
void PNGAPI
|
||||||
|
@ -1256,52 +1119,11 @@ png_set_filter_heuristics(png_structrp png_ptr, int heuristic_method,
|
||||||
int num_weights, png_const_doublep filter_weights,
|
int num_weights, png_const_doublep filter_weights,
|
||||||
png_const_doublep filter_costs)
|
png_const_doublep filter_costs)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_filter_heuristics");
|
PNG_UNUSED(png_ptr)
|
||||||
|
PNG_UNUSED(heuristic_method)
|
||||||
/* The internal API allocates all the arrays and ensures that the elements of
|
PNG_UNUSED(num_weights)
|
||||||
* those arrays are set to the default value.
|
PNG_UNUSED(filter_weights)
|
||||||
*/
|
PNG_UNUSED(filter_costs)
|
||||||
if (png_init_filter_heuristics(png_ptr, heuristic_method, num_weights) == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* If using the weighted method copy in the weights. */
|
|
||||||
if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < num_weights; i++)
|
|
||||||
{
|
|
||||||
if (filter_weights[i] <= 0.0)
|
|
||||||
{
|
|
||||||
png_ptr->inv_filter_weights[i] =
|
|
||||||
png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
png_ptr->inv_filter_weights[i] =
|
|
||||||
(png_uint_16)(PNG_WEIGHT_FACTOR*filter_weights[i]+.5);
|
|
||||||
|
|
||||||
png_ptr->filter_weights[i] =
|
|
||||||
(png_uint_16)(PNG_WEIGHT_FACTOR/filter_weights[i]+.5);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Here is where we set the relative costs of the different filters. We
|
|
||||||
* should take the desired compression level into account when setting
|
|
||||||
* the costs, so that Paeth, for instance, has a high relative cost at low
|
|
||||||
* compression levels, while it has a lower relative cost at higher
|
|
||||||
* compression settings. The filter types are in order of increasing
|
|
||||||
* relative cost, so it would be possible to do this with an algorithm.
|
|
||||||
*/
|
|
||||||
for (i = 0; i < PNG_FILTER_VALUE_LAST; i++) if (filter_costs[i] >= 1.0)
|
|
||||||
{
|
|
||||||
png_ptr->inv_filter_costs[i] =
|
|
||||||
(png_uint_16)(PNG_COST_FACTOR / filter_costs[i] + .5);
|
|
||||||
|
|
||||||
png_ptr->filter_costs[i] =
|
|
||||||
(png_uint_16)(PNG_COST_FACTOR * filter_costs[i] + .5);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif /* FLOATING_POINT */
|
#endif /* FLOATING_POINT */
|
||||||
|
|
||||||
|
@ -1311,63 +1133,11 @@ png_set_filter_heuristics_fixed(png_structrp png_ptr, int heuristic_method,
|
||||||
int num_weights, png_const_fixed_point_p filter_weights,
|
int num_weights, png_const_fixed_point_p filter_weights,
|
||||||
png_const_fixed_point_p filter_costs)
|
png_const_fixed_point_p filter_costs)
|
||||||
{
|
{
|
||||||
png_debug(1, "in png_set_filter_heuristics_fixed");
|
PNG_UNUSED(png_ptr)
|
||||||
|
PNG_UNUSED(heuristic_method)
|
||||||
/* The internal API allocates all the arrays and ensures that the elements of
|
PNG_UNUSED(num_weights)
|
||||||
* those arrays are set to the default value.
|
PNG_UNUSED(filter_weights)
|
||||||
*/
|
PNG_UNUSED(filter_costs)
|
||||||
if (png_init_filter_heuristics(png_ptr, heuristic_method, num_weights) == 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* If using the weighted method copy in the weights. */
|
|
||||||
if (heuristic_method == PNG_FILTER_HEURISTIC_WEIGHTED)
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < num_weights; i++)
|
|
||||||
{
|
|
||||||
if (filter_weights[i] <= 0)
|
|
||||||
{
|
|
||||||
png_ptr->inv_filter_weights[i] =
|
|
||||||
png_ptr->filter_weights[i] = PNG_WEIGHT_FACTOR;
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
png_ptr->inv_filter_weights[i] = (png_uint_16)
|
|
||||||
((PNG_WEIGHT_FACTOR*filter_weights[i]+PNG_FP_HALF)/PNG_FP_1);
|
|
||||||
|
|
||||||
png_ptr->filter_weights[i] = (png_uint_16)((PNG_WEIGHT_FACTOR*
|
|
||||||
PNG_FP_1+(filter_weights[i]/2))/filter_weights[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Here is where we set the relative costs of the different filters. We
|
|
||||||
* should take the desired compression level into account when setting
|
|
||||||
* the costs, so that Paeth, for instance, has a high relative cost at low
|
|
||||||
* compression levels, while it has a lower relative cost at higher
|
|
||||||
* compression settings. The filter types are in order of increasing
|
|
||||||
* relative cost, so it would be possible to do this with an algorithm.
|
|
||||||
*/
|
|
||||||
for (i = 0; i < PNG_FILTER_VALUE_LAST; i++)
|
|
||||||
if (filter_costs[i] >= PNG_FP_1)
|
|
||||||
{
|
|
||||||
png_uint_32 tmp;
|
|
||||||
|
|
||||||
/* Use a 32 bit unsigned temporary here because otherwise the
|
|
||||||
* intermediate value will be a 32 bit *signed* integer (ANSI rules)
|
|
||||||
* and this will get the wrong answer on division.
|
|
||||||
*/
|
|
||||||
tmp = PNG_COST_FACTOR*PNG_FP_1 + (filter_costs[i]/2);
|
|
||||||
tmp /= filter_costs[i];
|
|
||||||
|
|
||||||
png_ptr->inv_filter_costs[i] = (png_uint_16)tmp;
|
|
||||||
|
|
||||||
tmp = PNG_COST_FACTOR * filter_costs[i] + PNG_FP_HALF;
|
|
||||||
tmp /= PNG_FP_1;
|
|
||||||
|
|
||||||
png_ptr->filter_costs[i] = (png_uint_16)tmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif /* FIXED_POINT */
|
#endif /* FIXED_POINT */
|
||||||
#endif /* WRITE_WEIGHTED_FILTER */
|
#endif /* WRITE_WEIGHTED_FILTER */
|
||||||
|
@ -1765,10 +1535,11 @@ png_write_image_16bit(png_voidp argument)
|
||||||
++input_row; /* To point to the first component */
|
++input_row; /* To point to the first component */
|
||||||
++output_row;
|
++output_row;
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
# endif
|
|
||||||
aindex = channels;
|
aindex = channels;
|
||||||
|
# else
|
||||||
|
aindex = channels;
|
||||||
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||||
*
|
*
|
||||||
* Last changed in libpng 1.6.17 [March 26, 2015]
|
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
* Copyright (c) 1998-2015 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.)
|
||||||
|
@ -71,7 +71,8 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
png_bytep sp, dp;
|
png_bytep sp, dp;
|
||||||
int shift, v;
|
unsigned int shift;
|
||||||
|
int v;
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
png_uint_32 row_width = row_info->width;
|
png_uint_32 row_width = row_info->width;
|
||||||
|
|
||||||
|
@ -110,7 +111,8 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
||||||
case 4:
|
case 4:
|
||||||
{
|
{
|
||||||
png_bytep sp, dp;
|
png_bytep sp, dp;
|
||||||
int shift, v;
|
unsigned int shift;
|
||||||
|
int v;
|
||||||
png_uint_32 i;
|
png_uint_32 i;
|
||||||
png_uint_32 row_width = row_info->width;
|
png_uint_32 row_width = row_info->width;
|
||||||
|
|
||||||
|
@ -422,7 +424,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||||
*(dp++) = *(sp++);
|
*(dp++) = *(sp++);
|
||||||
*/
|
*/
|
||||||
sp+=3; dp = sp;
|
sp+=3; dp = sp;
|
||||||
*(dp++) = (png_byte)(255 - *(sp++));
|
*dp = (png_byte)(255 - *(sp++));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,7 +448,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||||
*/
|
*/
|
||||||
sp+=6; dp = sp;
|
sp+=6; dp = sp;
|
||||||
*(dp++) = (png_byte)(255 - *(sp++));
|
*(dp++) = (png_byte)(255 - *(sp++));
|
||||||
*(dp++) = (png_byte)(255 - *(sp++));
|
*dp = (png_byte)(255 - *(sp++));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* WRITE_16BIT */
|
#endif /* WRITE_16BIT */
|
||||||
|
@ -484,7 +486,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
||||||
*/
|
*/
|
||||||
sp+=2; dp = sp;
|
sp+=2; dp = sp;
|
||||||
*(dp++) = (png_byte)(255 - *(sp++));
|
*(dp++) = (png_byte)(255 - *(sp++));
|
||||||
*(dp++) = (png_byte)(255 - *(sp++));
|
*dp = (png_byte)(255 - *(sp++));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* WRITE_16BIT */
|
#endif /* WRITE_16BIT */
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue