mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-22 15:02:20 +00:00
libpng updated to version 1.6.18.
This commit is contained in:
parent
f1a3e81770
commit
83b47b1893
21 changed files with 1150 additions and 1787 deletions
|
@ -10,21 +10,17 @@ this sentence.
|
|||
|
||||
This code is released under the libpng license.
|
||||
|
||||
libpng versions 1.2.6, August 15, 2004, through 1.6.16, December 22, 2014, are
|
||||
Copyright (c) 2004, 2006-2014 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
|
||||
libpng versions 1.0.7, July 1, 2000, through 1.6.18, July 23, 2015, are
|
||||
Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, and are
|
||||
distributed according to the same disclaimer and license as libpng-1.0.6
|
||||
with the following individuals added to the list of Contributing Authors
|
||||
with the following individuals added to the list of Contributing Authors:
|
||||
|
||||
Simon-Pierre Cadieux
|
||||
Eric S. Raymond
|
||||
Mans Rullgard
|
||||
Cosmin Truta
|
||||
Gilles Vollant
|
||||
James Yu
|
||||
|
||||
and with the following additions to the disclaimer:
|
||||
|
||||
|
@ -36,17 +32,17 @@ and with the following additions to the disclaimer:
|
|||
the user.
|
||||
|
||||
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
||||
Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are
|
||||
distributed according to the same disclaimer and license as libpng-0.96,
|
||||
with the following individuals added to the list of Contributing Authors:
|
||||
Copyright (c) 1998-2000 Glenn Randers-Pehrson, and are distributed according
|
||||
to the same disclaimer and license as libpng-0.96, with the following
|
||||
individuals added to the list of Contributing Authors:
|
||||
|
||||
Tom Lane
|
||||
Glenn Randers-Pehrson
|
||||
Willem van Schaik
|
||||
|
||||
libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
||||
Copyright (c) 1996, 1997 Andreas Dilger
|
||||
Distributed according to the same disclaimer and license as libpng-0.88,
|
||||
Copyright (c) 1996-1997 Andreas Dilger, and are
|
||||
distributed according to the same disclaimer and license as libpng-0.88,
|
||||
with the following individuals added to the list of Contributing Authors:
|
||||
|
||||
John Bowler
|
||||
|
@ -57,7 +53,7 @@ with the following individuals added to the list of Contributing Authors:
|
|||
Tom Tanner
|
||||
|
||||
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"
|
||||
is defined as the following set of individuals:
|
||||
|
@ -80,12 +76,12 @@ Permission is hereby granted to use, copy, modify, and distribute this
|
|||
source code, or portions hereof, for any purpose, without fee, subject
|
||||
to the following restrictions:
|
||||
|
||||
1. The origin of this source code must not be misrepresented.
|
||||
1. The origin of this source code must not be misrepresented.
|
||||
|
||||
2. Altered versions must be plainly marked as such and must not
|
||||
2. Altered versions must be plainly marked as such and must not
|
||||
be misrepresented as being the original source.
|
||||
|
||||
3. This Copyright notice may not be removed or altered from any
|
||||
3. This Copyright notice may not be removed or altered from any
|
||||
source or altered source distribution.
|
||||
|
||||
The Contributing Authors and Group 42, Inc. specifically permit, without
|
||||
|
@ -94,18 +90,18 @@ supporting the PNG file format in commercial products. If you use this
|
|||
source code in a product, acknowledgment is not required but would be
|
||||
appreciated.
|
||||
|
||||
|
||||
A "png_get_copyright" function is available, for convenient use in "about"
|
||||
boxes and the like:
|
||||
|
||||
printf("%s",png_get_copyright(NULL));
|
||||
printf("%s", png_get_copyright(NULL));
|
||||
|
||||
Also, the PNG logo (in PNG format, of course) is supplied in the
|
||||
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
|
||||
|
||||
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
|
||||
certification mark of the Open Source Initiative.
|
||||
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
|
||||
a certification mark of the Open Source Initiative. OSI has not addressed
|
||||
the additional disclaimers inserted at version 1.0.7.
|
||||
|
||||
Glenn Randers-Pehrson
|
||||
glennrp at users.sourceforge.net
|
||||
December 22, 2014
|
||||
July 23, 2015
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* png.c - location for general purpose libpng functions
|
||||
*
|
||||
* Last changed in libpng 1.6.16 [December 22, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -14,7 +14,7 @@
|
|||
#include "pngpriv.h"
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef png_libpng_version_1_6_16 Your_png_h_is_not_version_1_6_16;
|
||||
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
|
||||
* of the PNG file signature. If the PNG data is embedded into another
|
||||
|
@ -34,7 +34,7 @@ png_set_sig_bytes(png_structrp png_ptr, int num_bytes)
|
|||
if (num_bytes > 8)
|
||||
png_error(png_ptr, "Too many bytes for PNG signature");
|
||||
|
||||
png_ptr->sig_bytes = (png_byte)(num_bytes < 0 ? 0 : num_bytes);
|
||||
png_ptr->sig_bytes = (png_byte)((num_bytes < 0 ? 0 : num_bytes) & 0xff);
|
||||
}
|
||||
|
||||
/* Checks whether the supplied bytes match the PNG signature. We allow
|
||||
|
@ -101,7 +101,7 @@ png_zfree(voidpf png_ptr, voidpf ptr)
|
|||
void /* PRIVATE */
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
* 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
|
||||
* necessary to perform a loop here.
|
||||
*/
|
||||
|
@ -140,8 +140,10 @@ png_calculate_crc(png_structrp png_ptr, png_const_bytep ptr, png_size_t length)
|
|||
do
|
||||
{
|
||||
uInt safe_length = (uInt)length;
|
||||
#ifndef __COVERITY__
|
||||
if (safe_length == 0)
|
||||
safe_length = (uInt)-1; /* evil, but safe */
|
||||
#endif
|
||||
|
||||
crc = crc32(crc, ptr, safe_length);
|
||||
|
||||
|
@ -273,7 +275,9 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
|
|||
|
||||
# ifdef PNG_SETJMP_SUPPORTED
|
||||
if (!setjmp(create_jmp_buf))
|
||||
# endif
|
||||
{
|
||||
# ifdef PNG_SETJMP_SUPPORTED
|
||||
/* Temporarily fake out the longjmp information until we have
|
||||
* successfully completed this function. This only works if we have
|
||||
* setjmp() support compiled in, but it is safe - this stuff should
|
||||
|
@ -282,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_size = 0; /*stack allocation*/
|
||||
create_struct.longjmp_fn = longjmp;
|
||||
# else
|
||||
{
|
||||
# endif
|
||||
/* Call the general version checker (shared with read and write code):
|
||||
*/
|
||||
|
@ -476,9 +478,10 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
|
|||
/* Free any tRNS entry */
|
||||
if (((mask & PNG_FREE_TRNS) & info_ptr->free_me) != 0)
|
||||
{
|
||||
info_ptr->valid &= ~PNG_INFO_tRNS;
|
||||
png_free(png_ptr, info_ptr->trans_alpha);
|
||||
info_ptr->trans_alpha = NULL;
|
||||
info_ptr->valid &= ~PNG_INFO_tRNS;
|
||||
info_ptr->num_trans = 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -543,8 +546,6 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
|
|||
}
|
||||
|
||||
else
|
||||
{
|
||||
if (info_ptr->splt_palettes_num != 0)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -557,7 +558,6 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
|
|||
png_free(png_ptr, info_ptr->splt_palettes);
|
||||
info_ptr->splt_palettes = NULL;
|
||||
info_ptr->splt_palettes_num = 0;
|
||||
}
|
||||
info_ptr->valid &= ~PNG_INFO_sPLT;
|
||||
}
|
||||
}
|
||||
|
@ -577,8 +577,6 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
|
|||
{
|
||||
int i;
|
||||
|
||||
if (info_ptr->unknown_chunks_num != 0)
|
||||
{
|
||||
for (i = 0; i < info_ptr->unknown_chunks_num; i++)
|
||||
png_free(png_ptr, info_ptr->unknown_chunks[i].data);
|
||||
|
||||
|
@ -587,7 +585,6 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
|
|||
info_ptr->unknown_chunks_num = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_hIST_SUPPORTED
|
||||
|
@ -666,7 +663,7 @@ png_init_io(png_structrp png_ptr, png_FILE_p fp)
|
|||
}
|
||||
# endif
|
||||
|
||||
#ifdef PNG_SAVE_INT_32_SUPPORTED
|
||||
# ifdef PNG_SAVE_INT_32_SUPPORTED
|
||||
/* The png_save_int_32 function assumes integers are stored in two's
|
||||
* complement format. If this isn't the case, then this routine needs to
|
||||
* be modified to write data in two's complement format. Note that,
|
||||
|
@ -681,7 +678,7 @@ png_save_int_32(png_bytep buf, png_int_32 i)
|
|||
buf[2] = (png_byte)((i >> 8) & 0xff);
|
||||
buf[3] = (png_byte)(i & 0xff);
|
||||
}
|
||||
#endif
|
||||
# endif
|
||||
|
||||
# ifdef PNG_TIME_RFC1123_SUPPORTED
|
||||
/* Convert the supplied time into an RFC 1123 string suitable for use in
|
||||
|
@ -755,7 +752,7 @@ png_convert_to_rfc1123(png_structrp png_ptr, png_const_timep ptime)
|
|||
|
||||
return NULL;
|
||||
}
|
||||
# endif
|
||||
# endif /* LIBPNG_VER < 10700 */
|
||||
# endif /* TIME_RFC1123 */
|
||||
|
||||
#endif /* READ || WRITE */
|
||||
|
@ -769,14 +766,14 @@ png_get_copyright(png_const_structrp png_ptr)
|
|||
#else
|
||||
# ifdef __STDC__
|
||||
return PNG_STRING_NEWLINE \
|
||||
"libpng version 1.6.16 - December 22, 2014" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1998-2014 Glenn Randers-Pehrson" 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) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
|
||||
PNG_STRING_NEWLINE;
|
||||
# else
|
||||
return "libpng version 1.6.16 - December 22, 2014\
|
||||
Copyright (c) 1998-2014 Glenn Randers-Pehrson\
|
||||
return "libpng version 1.6.18 - July 23, 2015\
|
||||
Copyright (c) 1998-2015 Glenn Randers-Pehrson\
|
||||
Copyright (c) 1996-1997 Andreas Dilger\
|
||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
|
||||
# endif
|
||||
|
@ -872,9 +869,9 @@ png_build_grayscale_palette(int bit_depth, png_colorp palette)
|
|||
|
||||
for (i = 0, v = 0; i < num_palette; i++, v += color_inc)
|
||||
{
|
||||
palette[i].red = (png_byte)v;
|
||||
palette[i].green = (png_byte)v;
|
||||
palette[i].blue = (png_byte)v;
|
||||
palette[i].red = (png_byte)(v & 0xff);
|
||||
palette[i].green = (png_byte)(v & 0xff);
|
||||
palette[i].blue = (png_byte)(v & 0xff);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -947,8 +944,6 @@ png_access_version_number(void)
|
|||
return((png_uint_32)PNG_LIBPNG_VER);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
/* Ensure that png_ptr->zstream.msg holds some appropriate error message string.
|
||||
* If it doesn't 'ret' is used to set it to something appropriate, even in cases
|
||||
|
@ -1181,7 +1176,7 @@ png_colorspace_sync(png_const_structrp png_ptr, png_inforp info_ptr)
|
|||
png_colorspace_sync_info(png_ptr, info_ptr);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif /* GAMMA */
|
||||
|
||||
#ifdef PNG_COLORSPACE_SUPPORTED
|
||||
/* Added at libpng-1.5.5 to support read and write of true CIEXYZ values for
|
||||
|
@ -1240,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
|
||||
* 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->redy < 0 || xy->redy > PNG_FP_1-xy->redx) return 1;
|
||||
|
@ -1249,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->bluey < 0 || xy->bluey > PNG_FP_1-xy->bluex) 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
|
||||
* value had 9 independent values (red,green,blue)x(X,Y,Z) however only 8
|
||||
|
@ -2166,7 +2162,8 @@ png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
|||
return 1; /* success, maybe with warnings */
|
||||
}
|
||||
|
||||
#if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0
|
||||
#ifdef PNG_sRGB_SUPPORTED
|
||||
#if PNG_sRGB_PROFILE_CHECKS >= 0
|
||||
/* Information about the known ICC sRGB profiles */
|
||||
static const struct
|
||||
{
|
||||
|
@ -2280,7 +2277,7 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
|
|||
|
||||
/* Length *and* intent must match */
|
||||
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. */
|
||||
if (adler == 0)
|
||||
|
@ -2324,8 +2321,8 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
|
|||
*/
|
||||
else if (png_sRGB_checks[i].have_md5 == 0)
|
||||
{
|
||||
png_chunk_report(png_ptr, "out-of-date sRGB profile with"
|
||||
" no signature",
|
||||
png_chunk_report(png_ptr,
|
||||
"out-of-date sRGB profile with no signature",
|
||||
PNG_CHUNK_WARNING);
|
||||
}
|
||||
|
||||
|
@ -2338,8 +2335,8 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
|
|||
* way. This probably indicates a data error or uninformed hacking.
|
||||
* Fall through to "no match".
|
||||
*/
|
||||
png_chunk_report(png_ptr, "Not recognizing known sRGB profile that"
|
||||
" has been edited",
|
||||
png_chunk_report(png_ptr,
|
||||
"Not recognizing known sRGB profile that has been edited",
|
||||
PNG_CHUNK_WARNING);
|
||||
break;
|
||||
# endif
|
||||
|
@ -2349,9 +2346,8 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
|
|||
|
||||
return 0; /* no match */
|
||||
}
|
||||
#endif
|
||||
#endif /* PNG_sRGB_PROFILE_CHECKS >= 0 */
|
||||
|
||||
#ifdef PNG_sRGB_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
png_icc_set_sRGB(png_const_structrp png_ptr,
|
||||
png_colorspacerp colorspace, png_const_bytep profile, uLong adler)
|
||||
|
@ -2365,7 +2361,7 @@ png_icc_set_sRGB(png_const_structrp png_ptr,
|
|||
(void)png_colorspace_set_sRGB(png_ptr, colorspace,
|
||||
(int)/*already checked*/png_get_uint_32(profile+64));
|
||||
}
|
||||
#endif /* READ_sRGB */
|
||||
#endif /* sRGB */
|
||||
|
||||
int /* PRIVATE */
|
||||
png_colorspace_set_ICC(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
|
@ -2457,7 +2453,7 @@ png_colorspace_set_rgb_coefficients(png_structrp png_ptr)
|
|||
png_error(png_ptr, "internal error handling cHRM->XYZ");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* READ_RGB_TO_GRAY */
|
||||
|
||||
#endif /* COLORSPACE */
|
||||
|
||||
|
@ -2486,18 +2482,19 @@ png_check_IHDR(png_const_structrp png_ptr,
|
|||
png_warning(png_ptr, "Image width is zero in IHDR");
|
||||
error = 1;
|
||||
}
|
||||
else if (width > PNG_UINT_31_MAX)
|
||||
|
||||
if (width > PNG_UINT_31_MAX)
|
||||
{
|
||||
png_warning(png_ptr, "Invalid image width in IHDR");
|
||||
error = 1;
|
||||
}
|
||||
|
||||
else if (png_gt(width,
|
||||
(PNG_SIZE_MAX >> 3) /* 8-byte RGBA pixels */
|
||||
if (png_gt(((width + 7) & (~7)),
|
||||
((PNG_SIZE_MAX
|
||||
- 48 /* big_row_buf hack */
|
||||
- 1 /* filter byte */
|
||||
- 7*8 /* rounding width to multiple of 8 pix */
|
||||
- 8)) /* extra max_pixel_depth pad */
|
||||
- 1) /* filter byte */
|
||||
/ 8) /* 8-byte RGBA pixels */
|
||||
- 1)) /* extra max_pixel_depth pad */
|
||||
{
|
||||
/* The size of the row must be within the limits of this architecture.
|
||||
* Because the read code can perform arbitrary transformations the
|
||||
|
@ -2513,41 +2510,38 @@ png_check_IHDR(png_const_structrp png_ptr,
|
|||
png_warning(png_ptr, "Image width is too large for this architecture");
|
||||
error = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
|
||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
if (width > png_ptr->user_width_max)
|
||||
# else
|
||||
#else
|
||||
if (width > PNG_USER_WIDTH_MAX)
|
||||
# endif
|
||||
#endif
|
||||
{
|
||||
png_warning(png_ptr, "Image width exceeds user limit in IHDR");
|
||||
error = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (height == 0)
|
||||
{
|
||||
png_warning(png_ptr, "Image height is zero in IHDR");
|
||||
error = 1;
|
||||
}
|
||||
else if (height > PNG_UINT_31_MAX)
|
||||
|
||||
if (height > PNG_UINT_31_MAX)
|
||||
{
|
||||
png_warning(png_ptr, "Invalid image height in IHDR");
|
||||
error = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
|
||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
if (height > png_ptr->user_height_max)
|
||||
# else
|
||||
#else
|
||||
if (height > PNG_USER_HEIGHT_MAX)
|
||||
# endif
|
||||
#endif
|
||||
{
|
||||
png_warning(png_ptr, "Image height exceeds user limit in IHDR");
|
||||
error = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Check other values */
|
||||
if (bit_depth != 1 && bit_depth != 2 && bit_depth != 4 &&
|
||||
|
@ -2585,7 +2579,7 @@ png_check_IHDR(png_const_structrp png_ptr,
|
|||
error = 1;
|
||||
}
|
||||
|
||||
# ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
/* Accept filter_method 64 (intrapixel differencing) only if
|
||||
* 1. Libpng was compiled with PNG_MNG_FEATURES_SUPPORTED and
|
||||
* 2. Libpng did not read a PNG signature (this filter_method is only
|
||||
|
@ -2618,13 +2612,13 @@ png_check_IHDR(png_const_structrp png_ptr,
|
|||
}
|
||||
}
|
||||
|
||||
# else
|
||||
#else
|
||||
if (filter_type != PNG_FILTER_TYPE_BASE)
|
||||
{
|
||||
png_warning(png_ptr, "Unknown filter method in IHDR");
|
||||
error = 1;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
if (error == 1)
|
||||
png_error(png_ptr, "Invalid IHDR data");
|
||||
|
@ -2898,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];
|
||||
|
||||
/* Allow up to two leading zeros - this will not lengthen
|
||||
|
@ -2928,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
|
||||
* that the final digit is rounded.
|
||||
*/
|
||||
if (cdigits+czero-clead+1 < (int)precision)
|
||||
if (cdigits+czero+1 < precision+clead)
|
||||
fp = modf(fp, &d);
|
||||
|
||||
else
|
||||
|
@ -3034,14 +3028,14 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
|||
*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 */
|
||||
|
||||
/* Check for an exponent, if we don't need one we are
|
||||
* done and just need to terminate the string. At
|
||||
* this point exp_b10==(-1) is effectively if flag - it got
|
||||
* to '-1' because of the decrement after outputing
|
||||
* to '-1' because of the decrement after outputting
|
||||
* the decimal point above (the exponent required is
|
||||
* *not* -1!)
|
||||
*/
|
||||
|
@ -3049,7 +3043,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
|||
{
|
||||
/* The following only happens if we didn't output the
|
||||
* leading zeros above for negative exponent, so this
|
||||
* doest add to the digit requirement. Note that the
|
||||
* doesn't add to the digit requirement. Note that the
|
||||
* two zeros here can only be output if the two leading
|
||||
* zeros were *not* output, so this doesn't increase
|
||||
* the output count.
|
||||
|
@ -3102,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
|
||||
* this need not be considered above.
|
||||
*/
|
||||
if ((int)size > cdigits)
|
||||
if (size > cdigits)
|
||||
{
|
||||
while (cdigits > 0) *ascii++ = exponent[--cdigits];
|
||||
|
||||
|
@ -3206,7 +3200,7 @@ png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii,
|
|||
png_error(png_ptr, "ASCII conversion buffer too small");
|
||||
}
|
||||
# endif /* FIXED_POINT */
|
||||
#endif /* READ_SCAL */
|
||||
#endif /* SCAL */
|
||||
|
||||
#if defined(PNG_FLOATING_POINT_SUPPORTED) && \
|
||||
!defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \
|
||||
|
@ -3405,29 +3399,29 @@ png_gamma_significant(png_fixed_point gamma_val)
|
|||
#endif
|
||||
|
||||
#ifdef PNG_READ_GAMMA_SUPPORTED
|
||||
#if defined(PNG_16BIT_SUPPORTED) || !defined(PNG_FLOATING_ARITHMETIC_SUPPORTED)
|
||||
#ifdef PNG_16BIT_SUPPORTED
|
||||
/* A local convenience routine. */
|
||||
static png_fixed_point
|
||||
png_product2(png_fixed_point a, png_fixed_point b)
|
||||
{
|
||||
/* 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;
|
||||
r *= b;
|
||||
r = floor(r+.5);
|
||||
|
||||
if (r <= 2147483647. && r >= -2147483648.)
|
||||
return (png_fixed_point)r;
|
||||
# else
|
||||
#else
|
||||
png_fixed_point res;
|
||||
|
||||
if (png_muldiv(&res, a, b, 100000) != 0)
|
||||
return res;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return 0; /* overflow */
|
||||
}
|
||||
#endif /* 16BIT || !FLOATING_ARITHMETIC */
|
||||
#endif /* 16BIT */
|
||||
|
||||
/* The inverse of the above. */
|
||||
png_fixed_point
|
||||
|
@ -3435,12 +3429,15 @@ png_reciprocal2(png_fixed_point a, png_fixed_point b)
|
|||
{
|
||||
/* The required result is 1/a * 1/b; the following preserves accuracy. */
|
||||
#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
|
||||
if (a != 0 && b != 0)
|
||||
{
|
||||
double r = 1E15/a;
|
||||
r /= b;
|
||||
r = floor(r+.5);
|
||||
|
||||
if (r <= 2147483647. && r >= -2147483648.)
|
||||
return (png_fixed_point)r;
|
||||
}
|
||||
#else
|
||||
/* This may overflow because the range of png_fixed_point isn't symmetric,
|
||||
* but this API is only used for the product of file and screen gamma so it
|
||||
|
@ -3731,7 +3728,7 @@ png_exp8bit(png_fixed_point lg2)
|
|||
* step.
|
||||
*/
|
||||
x -= x >> 8;
|
||||
return (png_byte)((x + 0x7fffffU) >> 24);
|
||||
return (png_byte)(((x + 0x7fffffU) >> 24) & 0xff);
|
||||
}
|
||||
|
||||
#ifdef PNG_16BIT_SUPPORTED
|
||||
|
@ -3792,7 +3789,7 @@ png_gamma_8bit_correct(unsigned int value, png_fixed_point gamma_val)
|
|||
# endif
|
||||
}
|
||||
|
||||
return (png_byte)value;
|
||||
return (png_byte)(value & 0xff);
|
||||
}
|
||||
|
||||
#ifdef PNG_16BIT_SUPPORTED
|
||||
|
@ -4014,7 +4011,7 @@ png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable,
|
|||
|
||||
else
|
||||
for (i=0; i<256; ++i)
|
||||
table[i] = (png_byte)i;
|
||||
table[i] = (png_byte)(i & 0xff);
|
||||
}
|
||||
|
||||
/* Used from png_read_destroy and below to release the memory used by the gamma
|
||||
|
@ -4154,7 +4151,8 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth)
|
|||
*
|
||||
*/
|
||||
if (sig_bit > 0 && sig_bit < 16U)
|
||||
shift = (png_byte)(16U - sig_bit); /* shift == insignificant bits */
|
||||
/* shift == insignificant bits */
|
||||
shift = (png_byte)((16U - sig_bit) & 0xff);
|
||||
|
||||
else
|
||||
shift = 0; /* keep all 16 bits */
|
||||
|
@ -4223,7 +4221,7 @@ png_set_option(png_structrp png_ptr, int option, int onoff)
|
|||
int setting = (2 + (onoff != 0)) << option;
|
||||
int current = png_ptr->options;
|
||||
|
||||
png_ptr->options = (png_byte)((current & ~mask) | setting);
|
||||
png_ptr->options = (png_byte)(((current & ~mask) | setting) & 0xff);
|
||||
|
||||
return (current & mask) >> option;
|
||||
}
|
||||
|
@ -4239,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
|
||||
* specification (see the article at http://en.wikipedia.org/wiki/SRGB)
|
||||
* 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:
|
||||
*
|
||||
* For all possible (255*65535+1) input values:
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng version 1.6.16, December 22, 2014
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* libpng version 1.6.18, July 23, 2015
|
||||
*
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -10,8 +11,8 @@
|
|||
*
|
||||
* Authors and maintainers:
|
||||
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
||||
* libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||
* libpng versions 0.97, January 1998, through 1.6.16, December 22, 2014: Glenn
|
||||
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||
* libpng versions 0.97, January 1998, through 1.6.18, July 23, 2015: Glenn
|
||||
* See also "Contributing Authors", below.
|
||||
*
|
||||
* Note about libpng version numbers:
|
||||
|
@ -212,6 +213,12 @@
|
|||
* 1.6.16beta01-03 16 10616 16.so.16.16[.0]
|
||||
* 1.6.16rc01-02 16 10616 16.so.16.16[.0]
|
||||
* 1.6.16 16 10616 16.so.16.16[.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.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
|
||||
* and minor numbers; the shared-library major version number will be
|
||||
|
@ -243,21 +250,16 @@
|
|||
*
|
||||
* This code is released under the libpng license.
|
||||
*
|
||||
* libpng versions 1.2.6, August 15, 2004, through 1.6.16, December 22, 2014, are
|
||||
* Copyright (c) 2004, 2006-2014 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
|
||||
* libpng versions 1.0.7, July 1, 2000, through 1.6.18, July 23, 2015, are
|
||||
* Copyright (c) 2000-2002, 2004, 2006-2015 Glenn Randers-Pehrson, and are
|
||||
* distributed according to the same disclaimer and license as libpng-1.0.6
|
||||
* with the following individuals added to the list of Contributing Authors:
|
||||
*
|
||||
* Simon-Pierre Cadieux
|
||||
* Eric S. Raymond
|
||||
* Mans Rullgard
|
||||
* Cosmin Truta
|
||||
* Gilles Vollant
|
||||
* James Yu
|
||||
*
|
||||
* and with the following additions to the disclaimer:
|
||||
*
|
||||
|
@ -269,17 +271,18 @@
|
|||
* the user.
|
||||
*
|
||||
* libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
||||
* Copyright (c) 1998, 1999, 2000 Glenn Randers-Pehrson, and are
|
||||
* distributed according to the same disclaimer and license as libpng-0.96,
|
||||
* with the following individuals added to the list of Contributing Authors:
|
||||
* Copyright (c) 1998-2000 Glenn Randers-Pehrson, and are distributed according
|
||||
* to the same disclaimer and license as libpng-0.96, with the following
|
||||
* individuals added to the list of Contributing Authors:
|
||||
*
|
||||
* Tom Lane
|
||||
* Glenn Randers-Pehrson
|
||||
* Eric S. Raymond
|
||||
* Willem van Schaik
|
||||
*
|
||||
* libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
||||
* Copyright (c) 1996, 1997 Andreas Dilger
|
||||
* Distributed according to the same disclaimer and license as libpng-0.88,
|
||||
* Copyright (c) 1996-1997 Andreas Dilger, and are
|
||||
* distributed according to the same disclaimer and license as libpng-0.88,
|
||||
* with the following individuals added to the list of Contributing Authors:
|
||||
*
|
||||
* John Bowler
|
||||
|
@ -290,7 +293,7 @@
|
|||
* Tom Tanner
|
||||
*
|
||||
* 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"
|
||||
* is defined as the following set of individuals:
|
||||
|
@ -318,8 +321,8 @@
|
|||
* 2. Altered versions must be plainly marked as such and must not
|
||||
* be misrepresented as being the original source.
|
||||
*
|
||||
* 3. This Copyright notice may not be removed or altered from
|
||||
* any source or altered source distribution.
|
||||
* 3. This Copyright notice may not be removed or altered from any
|
||||
* source or altered source distribution.
|
||||
*
|
||||
* The Contributing Authors and Group 42, Inc. specifically permit, without
|
||||
* fee, and encourage the use of this source code as a component to
|
||||
|
@ -339,8 +342,9 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* Libpng is OSI Certified Open Source Software. OSI Certified is a
|
||||
* certification mark of the Open Source Initiative.
|
||||
* Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
|
||||
* a certification mark of the Open Source Initiative. OSI has not addressed
|
||||
* the additional disclaimers inserted at version 1.0.7.
|
||||
*/
|
||||
|
||||
/*
|
||||
|
@ -355,13 +359,13 @@
|
|||
* Y2K compliance in libpng:
|
||||
* =========================
|
||||
*
|
||||
* December 22, 2014
|
||||
* July 23, 2015
|
||||
*
|
||||
* Since the PNG Development group is an ad-hoc body, we can't make
|
||||
* an official declaration.
|
||||
*
|
||||
* This is your unofficial assurance that libpng from version 0.71 and
|
||||
* upward through 1.6.16 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.
|
||||
*
|
||||
* Libpng only has two year fields. One is a 2-byte unsigned integer
|
||||
|
@ -423,9 +427,9 @@
|
|||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.6.16"
|
||||
#define PNG_LIBPNG_VER_STRING "1.6.18"
|
||||
#define PNG_HEADER_VERSION_STRING \
|
||||
" libpng version 1.6.16 - December 22, 2014\n"
|
||||
" libpng version 1.6.18 - July 23, 2015\n"
|
||||
|
||||
#define PNG_LIBPNG_VER_SONUM 16
|
||||
#define PNG_LIBPNG_VER_DLLNUM 16
|
||||
|
@ -433,7 +437,7 @@
|
|||
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
|
||||
#define PNG_LIBPNG_VER_MAJOR 1
|
||||
#define PNG_LIBPNG_VER_MINOR 6
|
||||
#define PNG_LIBPNG_VER_RELEASE 16
|
||||
#define PNG_LIBPNG_VER_RELEASE 18
|
||||
|
||||
/* This should match the numeric part of the final component of
|
||||
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
|
||||
|
@ -464,7 +468,7 @@
|
|||
* version 1.0.0 was mis-numbered 100 instead of 10000). From
|
||||
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
|
||||
*/
|
||||
#define PNG_LIBPNG_VER 10616 /* 1.6.16 */
|
||||
#define PNG_LIBPNG_VER 10618 /* 1.6.18 */
|
||||
|
||||
/* Library configuration: these options cannot be changed after
|
||||
* the library has been built.
|
||||
|
@ -569,7 +573,7 @@ extern "C" {
|
|||
/* This triggers a compiler error in png.c, if png.c and png.h
|
||||
* do not agree upon the version number.
|
||||
*/
|
||||
typedef char* png_libpng_version_1_6_16;
|
||||
typedef char* png_libpng_version_1_6_18;
|
||||
|
||||
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
|
||||
*
|
||||
|
@ -1578,6 +1582,7 @@ PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action,
|
|||
#define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */
|
||||
#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
/* These functions give the user control over the scan-line filtering in
|
||||
* libpng and the compression methods used by zlib. These functions are
|
||||
* mainly useful for testing, as the defaults should work with most users.
|
||||
|
@ -1591,6 +1596,7 @@ PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action,
|
|||
*/
|
||||
PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,
|
||||
int filters));
|
||||
#endif /* WRITE */
|
||||
|
||||
/* Flags for png_set_filter() to say which filters to use. The flags
|
||||
* are chosen so that they don't conflict with real filter types
|
||||
|
@ -1616,35 +1622,8 @@ PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,
|
|||
#define PNG_FILTER_VALUE_PAETH 4
|
||||
#define PNG_FILTER_VALUE_LAST 5
|
||||
|
||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* EXPERIMENTAL */
|
||||
/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_
|
||||
* defines, either the default (minimum-sum-of-absolute-differences), or
|
||||
* 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.
|
||||
*/
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */
|
||||
PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr,
|
||||
int heuristic_method, int num_weights, png_const_doublep filter_weights,
|
||||
png_const_doublep filter_costs))
|
||||
|
@ -1654,15 +1633,12 @@ PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
|
|||
png_const_fixed_point_p filter_costs))
|
||||
#endif /* WRITE_WEIGHTED_FILTER */
|
||||
|
||||
/* Heuristic used for row filter selection. These defines should NOT be
|
||||
* changed.
|
||||
*/
|
||||
/* The following are no longer used and will be removed from libpng-1.7: */
|
||||
#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */
|
||||
#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */
|
||||
#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */
|
||||
#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */
|
||||
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
/* Set the library compression level. Currently, valid values range from
|
||||
* 0 - 9, corresponding directly to the zlib compression levels 0 - 9
|
||||
* (0 - no compression, 9 - "maximal" compression). Note that tests have
|
||||
|
@ -1670,6 +1646,7 @@ PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
|
|||
* for PNG images, and do considerably fewer caclulations. In the future,
|
||||
* these values may not correspond directly to the zlib compression levels.
|
||||
*/
|
||||
#ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
|
||||
PNG_EXPORT(69, void, png_set_compression_level, (png_structrp png_ptr,
|
||||
int level));
|
||||
|
||||
|
@ -1687,7 +1664,7 @@ PNG_EXPORT(72, void, png_set_compression_window_bits, (png_structrp png_ptr,
|
|||
|
||||
PNG_EXPORT(73, void, png_set_compression_method, (png_structrp png_ptr,
|
||||
int method));
|
||||
#endif
|
||||
#endif /* WRITE_CUSTOMIZE_COMPRESSION */
|
||||
|
||||
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
/* Also set zlib parameters for compressing non-IDAT chunks */
|
||||
|
@ -1709,6 +1686,7 @@ PNG_EXPORT(225, void, png_set_text_compression_window_bits,
|
|||
PNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr,
|
||||
int method));
|
||||
#endif /* WRITE_CUSTOMIZE_ZTXT_COMPRESSION */
|
||||
#endif /* WRITE */
|
||||
|
||||
/* These next functions are called for input/output, memory, and error
|
||||
* handling. They are in the file pngrio.c, pngwio.c, and pngerror.c,
|
||||
|
@ -1819,7 +1797,7 @@ PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp));
|
|||
*
|
||||
* The integer return from the callback function is interpreted thus:
|
||||
*
|
||||
* negative: An error occured, png_chunk_error will be called.
|
||||
* negative: An error occurred; png_chunk_error will be called.
|
||||
* zero: The chunk was not handled, the chunk will be saved. A critical
|
||||
* chunk will cause an error at this point unless it is to be saved.
|
||||
* positive: The chunk was handled, libpng will ignore/discard it.
|
||||
|
@ -2664,26 +2642,28 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
|
|||
* (png_uint_16)(alpha) \
|
||||
+ (png_uint_16)(bg)*(png_uint_16)(255 \
|
||||
- (png_uint_16)(alpha)) + 128); \
|
||||
(composite) = (png_byte)((temp + (temp >> 8)) >> 8); }
|
||||
(composite) = (png_byte)(((temp + (temp >> 8)) >> 8) & 0xff); }
|
||||
|
||||
# define png_composite_16(composite, fg, alpha, bg) \
|
||||
{ png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \
|
||||
* (png_uint_32)(alpha) \
|
||||
+ (png_uint_32)(bg)*(65535 \
|
||||
- (png_uint_32)(alpha)) + 32768); \
|
||||
(composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); }
|
||||
(composite) = (png_uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); }
|
||||
|
||||
#else /* Standard method using integer division */
|
||||
|
||||
# define png_composite(composite, fg, alpha, bg) \
|
||||
(composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \
|
||||
(composite) = \
|
||||
(png_byte)(0xff & (((png_uint_16)(fg) * (png_uint_16)(alpha) + \
|
||||
(png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \
|
||||
127) / 255)
|
||||
127) / 255))
|
||||
|
||||
# define png_composite_16(composite, fg, alpha, bg) \
|
||||
(composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \
|
||||
(composite) = \
|
||||
(png_uint_16)(0xffff & (((png_uint_32)(fg) * (png_uint_32)(alpha) + \
|
||||
(png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \
|
||||
32767) / 65535)
|
||||
32767) / 65535))
|
||||
#endif /* READ_COMPOSITE_NODIV */
|
||||
|
||||
#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
|
||||
|
@ -2773,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:
|
||||
*
|
||||
* 1) Declare a 'png_image' structure (see below) on the stack and set the
|
||||
* version field to PNG_IMAGE_VERSION.
|
||||
* 1) Declare a 'png_image' structure (see below) on the stack, set the
|
||||
* 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.
|
||||
* 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.
|
||||
|
@ -3199,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
|
||||
* 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 /* SIMPLIFIED_WRITE */
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng version 1.6.16,December 22, 2014
|
||||
* libpng version 1.6.18, July 23, 2015
|
||||
*
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -11,9 +11,7 @@
|
|||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*
|
||||
*/
|
||||
|
||||
/* Any machine specific code is near the front of this file, so if you
|
||||
* Any machine specific code is near the front of this file, so if you
|
||||
* are configuring libpng for a machine, you may want to read the section
|
||||
* starting here down to where it starts to typedef png_color, png_text,
|
||||
* and png_info.
|
||||
|
@ -22,26 +20,6 @@
|
|||
#ifndef PNGCONF_H
|
||||
#define PNGCONF_H
|
||||
|
||||
/* To do: Do all of this in scripts/pnglibconf.dfa */
|
||||
#ifdef PNG_SAFE_LIMITS_SUPPORTED
|
||||
# ifdef PNG_USER_WIDTH_MAX
|
||||
# undef PNG_USER_WIDTH_MAX
|
||||
# define PNG_USER_WIDTH_MAX 1000000L
|
||||
# endif
|
||||
# ifdef PNG_USER_HEIGHT_MAX
|
||||
# undef PNG_USER_HEIGHT_MAX
|
||||
# define PNG_USER_HEIGHT_MAX 1000000L
|
||||
# endif
|
||||
# ifdef PNG_USER_CHUNK_MALLOC_MAX
|
||||
# undef PNG_USER_CHUNK_MALLOC_MAX
|
||||
# define PNG_USER_CHUNK_MALLOC_MAX 4000000L
|
||||
# endif
|
||||
# ifdef PNG_USER_CHUNK_CACHE_MAX
|
||||
# undef PNG_USER_CHUNK_CACHE_MAX
|
||||
# define PNG_USER_CHUNK_CACHE_MAX 128
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */
|
||||
|
||||
/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C
|
||||
|
@ -317,11 +295,11 @@
|
|||
* table entries, so we discard it here. See the .dfn files in the
|
||||
* scripts directory.
|
||||
*/
|
||||
#ifndef PNG_EXPORTA
|
||||
|
||||
# define PNG_EXPORTA(ordinal, type, name, args, attributes)\
|
||||
PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \
|
||||
extern attributes)
|
||||
#ifndef PNG_EXPORTA
|
||||
# define PNG_EXPORTA(ordinal, type, name, args, attributes) \
|
||||
PNG_FUNCTION(PNG_EXPORT_TYPE(type), (PNGAPI name), PNGARG(args), \
|
||||
PNG_LINKAGE_API attributes)
|
||||
#endif
|
||||
|
||||
/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument,
|
||||
|
@ -329,7 +307,7 @@
|
|||
*/
|
||||
#define PNG_EMPTY /*empty list*/
|
||||
|
||||
#define PNG_EXPORT(ordinal, type, name, args)\
|
||||
#define PNG_EXPORT(ordinal, type, name, args) \
|
||||
PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY)
|
||||
|
||||
/* Use PNG_REMOVED to comment out a removed interface. */
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
|
||||
/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c
|
||||
*
|
||||
* Last changed in libpng 1.6.8 [December 19, 2013]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* Last changed in libpng 1.6.8 [December 19, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.17 [March 26, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -799,13 +799,19 @@ png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
|||
{
|
||||
png_debug1(1, "in %s retrieval function", "IHDR");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL || width == NULL ||
|
||||
height == NULL || bit_depth == NULL || color_type == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return (0);
|
||||
|
||||
if (width != NULL)
|
||||
*width = info_ptr->width;
|
||||
|
||||
if (height != NULL)
|
||||
*height = info_ptr->height;
|
||||
|
||||
if (bit_depth != NULL)
|
||||
*bit_depth = info_ptr->bit_depth;
|
||||
|
||||
if (color_type != NULL)
|
||||
*color_type = info_ptr->color_type;
|
||||
|
||||
if (compression_type != NULL)
|
||||
|
@ -1135,21 +1141,21 @@ png_get_compression_buffer_size(png_const_structrp png_ptr)
|
|||
if (png_ptr == NULL)
|
||||
return 0;
|
||||
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
|
||||
# endif
|
||||
#endif
|
||||
{
|
||||
# ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
return png_ptr->IDAT_read_size;
|
||||
# else
|
||||
#else
|
||||
return PNG_IDAT_READ_SIZE;
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
# ifdef PNG_WRITE_SUPPORTED
|
||||
#ifdef PNG_WRITE_SUPPORTED
|
||||
else
|
||||
return png_ptr->zbuffer_size;
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
|
||||
/* pnginfo.h - header file for PNG reference library
|
||||
*
|
||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/* pnglibconf.h - library build configuration */
|
||||
|
||||
/* libpng version 1.6.8 - December 19, 2013 */
|
||||
/* libpng version 1.6.18, July 23, 2015 */
|
||||
|
||||
/* Copyright (c) 1998-2012 Glenn Randers-Pehrson */
|
||||
/* Copyright (c) 1998-2014 Glenn Randers-Pehrson */
|
||||
|
||||
/* This code is released under the libpng license. */
|
||||
/* For conditions of distribution and use, see the disclaimer */
|
||||
|
@ -95,13 +95,10 @@
|
|||
#define PNG_READ_tIME_SUPPORTED
|
||||
#define PNG_READ_tRNS_SUPPORTED
|
||||
#define PNG_READ_zTXt_SUPPORTED
|
||||
/*#undef PNG_SAFE_LIMITS_SUPPORTED*/
|
||||
#define PNG_SAVE_INT_32_SUPPORTED
|
||||
#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_SEQUENTIAL_READ_SUPPORTED
|
||||
#define PNG_SETJMP_SUPPORTED
|
||||
#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED
|
||||
#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
|
||||
#define PNG_SET_OPTION_SUPPORTED
|
||||
#define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
#define PNG_SET_USER_LIMITS_SUPPORTED
|
||||
|
@ -127,6 +124,7 @@
|
|||
#define PNG_WRITE_BGR_SUPPORTED
|
||||
#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
|
||||
#define PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
|
||||
#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
#define PNG_WRITE_FILLER_SUPPORTED
|
||||
#define PNG_WRITE_FILTER_SUPPORTED
|
||||
|
@ -185,18 +183,25 @@
|
|||
/* end of options */
|
||||
/* settings */
|
||||
#define PNG_API_RULE 0
|
||||
#define PNG_CALLOC_SUPPORTED
|
||||
#define PNG_COST_SHIFT 3
|
||||
#define PNG_DEFAULT_READ_MACROS 1
|
||||
#define PNG_GAMMA_THRESHOLD_FIXED 5000
|
||||
#define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE
|
||||
#define PNG_INFLATE_BUF_SIZE 1024
|
||||
#define PNG_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_QUANTIZE_BLUE_BITS 5
|
||||
#define PNG_QUANTIZE_GREEN_BITS 5
|
||||
#define PNG_QUANTIZE_RED_BITS 5
|
||||
#define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1)
|
||||
#define PNG_TEXT_Z_DEFAULT_STRATEGY 0
|
||||
#define PNG_USER_CHUNK_CACHE_MAX 1000
|
||||
#define PNG_USER_CHUNK_MALLOC_MAX 8000000
|
||||
#define PNG_USER_HEIGHT_MAX 1000000
|
||||
#define PNG_USER_WIDTH_MAX 1000000
|
||||
#define PNG_WEIGHT_SHIFT 8
|
||||
#define PNG_ZBUF_SIZE 8192
|
||||
#define PNG_ZLIB_VERNUM 0x1280
|
||||
|
|
|
@ -41,7 +41,7 @@ png_destroy_png_struct(png_structrp png_ptr)
|
|||
}
|
||||
|
||||
/* Allocate memory. For reasonable files, size should never exceed
|
||||
* 64K. However, zlib may allocate more then 64K if you don't tell
|
||||
* 64K. However, zlib may allocate more than 64K if you don't tell
|
||||
* it not to. See zconf.h and png.h for more information. zlib does
|
||||
* need to allocate exactly 64K, so whatever you call here must
|
||||
* have the ability to do that.
|
||||
|
@ -77,6 +77,9 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
|
|||
PNG_UNUSED(png_ptr)
|
||||
#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
|
||||
# ifdef PNG_MAX_MALLOC_64K
|
||||
&& size <= 65536U
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -19,7 +19,6 @@
|
|||
#define PNG_READ_SIG_MODE 0
|
||||
#define PNG_READ_CHUNK_MODE 1
|
||||
#define PNG_READ_IDAT_MODE 2
|
||||
#define PNG_SKIP_MODE 3
|
||||
#define PNG_READ_tEXt_MODE 4
|
||||
#define PNG_READ_zTXt_MODE 5
|
||||
#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_process_data_skip(png_structrp png_ptr)
|
||||
{
|
||||
png_uint_32 remaining = 0;
|
||||
|
||||
if (png_ptr != NULL && png_ptr->process_mode == PNG_SKIP_MODE &&
|
||||
png_ptr->skip_length > 0)
|
||||
{
|
||||
/* 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:
|
||||
/* TODO: Deprecate and remove this API.
|
||||
* Somewhere the implementation of this seems to have been lost,
|
||||
* or abandoned. It was only to support some internal back-door access
|
||||
* to png_struct) in libpng-1.4.x.
|
||||
*/
|
||||
if (png_ptr->buffer_size != 0)
|
||||
png_error(png_ptr,
|
||||
"png_process_data_skip called inside png_process_data");
|
||||
|
||||
/* 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;
|
||||
png_app_warning(png_ptr,
|
||||
"png_process_data_skip is not implemented in any current version of libpng");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
||||
case PNG_SKIP_MODE:
|
||||
{
|
||||
png_push_crc_finish(png_ptr);
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
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
|
||||
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)
|
||||
{
|
||||
png_free(png_ptr, old_buffer);
|
||||
old_buffer = NULL;
|
||||
png_error(png_ptr, "Insufficient memory for save_buffer");
|
||||
}
|
||||
|
||||
memcpy(png_ptr->save_buffer, old_buffer, png_ptr->save_buffer_size);
|
||||
png_free(png_ptr, old_buffer);
|
||||
old_buffer = NULL;
|
||||
png_ptr->save_buffer_max = new_max;
|
||||
}
|
||||
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_ptr += save_size;
|
||||
}
|
||||
|
||||
if (png_ptr->idat_size == 0)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_LT(4)
|
||||
|
@ -726,7 +637,7 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
|
|||
* or the stream marked as finished.
|
||||
*/
|
||||
while (png_ptr->zstream.avail_in > 0 &&
|
||||
!(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED))
|
||||
(png_ptr->flags & PNG_FLAG_ZSTREAM_ENDED) == 0)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
@ -1036,6 +947,7 @@ png_push_process_row(png_structrp png_ptr)
|
|||
}
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
png_push_have_row(png_ptr, png_ptr->row_buf + 1);
|
||||
png_read_push_finish_row(png_ptr);
|
||||
|
@ -1045,6 +957,7 @@ png_push_process_row(png_structrp png_ptr)
|
|||
void /* PRIVATE */
|
||||
png_read_push_finish_row(png_structrp png_ptr)
|
||||
{
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||
|
||||
/* Start of interlace block */
|
||||
|
@ -1069,6 +982,7 @@ png_read_push_finish_row(png_structrp png_ptr)
|
|||
if (png_ptr->row_number < png_ptr->num_rows)
|
||||
return;
|
||||
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
if (png_ptr->interlaced != 0)
|
||||
{
|
||||
png_ptr->row_number = 0;
|
||||
|
@ -1103,6 +1017,7 @@ png_read_push_finish_row(png_structrp png_ptr)
|
|||
|
||||
} while (png_ptr->iwidth == 0 || png_ptr->num_rows == 0);
|
||||
}
|
||||
#endif /* READ_INTERLACING */
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
|
@ -1127,6 +1042,7 @@ png_push_have_row(png_structrp png_ptr, png_bytep row)
|
|||
(int)png_ptr->pass);
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
void PNGAPI
|
||||
png_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row,
|
||||
png_const_bytep new_row)
|
||||
|
@ -1141,6 +1057,7 @@ png_progressive_combine_row(png_const_structrp png_ptr, png_bytep old_row,
|
|||
if (new_row != NULL)
|
||||
png_combine_row(png_ptr, old_row, 1/*blocky display*/);
|
||||
}
|
||||
#endif /* READ_INTERLACING */
|
||||
|
||||
void PNGAPI
|
||||
png_set_progressive_read_fn(png_structrp png_ptr, png_voidp progressive_ptr,
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
|
||||
/* pngpriv.h - private declarations for use inside libpng
|
||||
*
|
||||
* For conditions of distribution and use, see copyright notice in png.h
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* Last changed in libpng 1.6.10 [March 6, 1014]]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
|
@ -120,8 +118,12 @@
|
|||
* to compile with an appropriate #error if ALIGNED_MEMORY has been turned
|
||||
* off.
|
||||
*
|
||||
* Note that gcc-4.9 defines __ARM_NEON instead of __ARM_NEON__, so we
|
||||
* check both variants.
|
||||
* Note that gcc-4.9 defines __ARM_NEON instead of the deprecated
|
||||
* __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)) && \
|
||||
defined(PNG_ALIGNED_MEMORY_SUPPORTED)
|
||||
|
@ -250,17 +252,18 @@
|
|||
* always be used to declare an extern data or function object in this file.
|
||||
*/
|
||||
#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
|
||||
|
||||
#ifndef PNG_INTERNAL_FUNCTION
|
||||
# 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
|
||||
|
||||
#ifndef PNG_INTERNAL_CALLBACK
|
||||
# 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
|
||||
|
||||
/* If floating or fixed point APIs are disabled they may still be compiled
|
||||
|
@ -298,48 +301,27 @@
|
|||
# define PNG_DLL_EXPORT
|
||||
#endif
|
||||
|
||||
/* SECURITY and SAFETY:
|
||||
/* 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:
|
||||
*
|
||||
* By default libpng is built without any internal limits on image size,
|
||||
* individual heap (png_malloc) allocations or the total amount of memory used.
|
||||
* If PNG_SAFE_LIMITS_SUPPORTED is defined, however, the limits below are used
|
||||
* (unless individually overridden). These limits are believed to be fairly
|
||||
* safe, but builders of secure systems should verify the values against the
|
||||
* real system capabilities.
|
||||
* -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
|
||||
*/
|
||||
#ifdef PNG_SAFE_LIMITS_SUPPORTED
|
||||
/* 'safe' limits */
|
||||
# ifndef PNG_USER_WIDTH_MAX
|
||||
# define PNG_USER_WIDTH_MAX 1000000
|
||||
# endif
|
||||
# ifndef PNG_USER_HEIGHT_MAX
|
||||
# define PNG_USER_HEIGHT_MAX 1000000
|
||||
# endif
|
||||
# ifndef PNG_USER_CHUNK_CACHE_MAX
|
||||
# define PNG_USER_CHUNK_CACHE_MAX 128
|
||||
# endif
|
||||
# ifndef PNG_USER_CHUNK_MALLOC_MAX
|
||||
# define PNG_USER_CHUNK_MALLOC_MAX 8000000
|
||||
# endif
|
||||
#else
|
||||
/* values for no limits */
|
||||
# ifndef PNG_USER_WIDTH_MAX
|
||||
# define PNG_USER_WIDTH_MAX 0x7fffffff
|
||||
# endif
|
||||
# ifndef PNG_USER_HEIGHT_MAX
|
||||
# define PNG_USER_HEIGHT_MAX 0x7fffffff
|
||||
# endif
|
||||
# ifndef PNG_USER_CHUNK_CACHE_MAX
|
||||
# define PNG_USER_CHUNK_CACHE_MAX 0
|
||||
# endif
|
||||
# ifndef PNG_USER_CHUNK_MALLOC_MAX
|
||||
# define PNG_USER_CHUNK_MALLOC_MAX 0
|
||||
# endif
|
||||
#ifndef PNG_RELEASE_BUILD
|
||||
# define PNG_RELEASE_BUILD (PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC)
|
||||
#endif
|
||||
|
||||
/* Moved to pngpriv.h at libpng-1.5.0 */
|
||||
/* NOTE: some of these may have been used in external applications as
|
||||
* these definitions were exposed in pngconf.h prior to 1.5.
|
||||
/* SECURITY and SAFETY:
|
||||
*
|
||||
* libpng is built with support for internal limits on image dimensions and
|
||||
* memory usage. These are documented in scripts/pnglibconf.dfa of the
|
||||
* source and recorded in the machine generated header file pnglibconf.h.
|
||||
*/
|
||||
|
||||
/* If you are running on a machine where you cannot allocate more
|
||||
|
@ -780,15 +762,17 @@
|
|||
* macro will fail on top-bit-set values because of the sign extension.
|
||||
*/
|
||||
#define PNG_CHUNK_FROM_STRING(s)\
|
||||
PNG_U32(0xff&(s)[0], 0xff&(s)[1], 0xff&(s)[2], 0xff&(s)[3])
|
||||
PNG_U32(0xff & (s)[0], 0xff & (s)[1], 0xff & (s)[2], 0xff & (s)[3])
|
||||
|
||||
/* This uses (char), not (png_byte) to avoid warnings on systems where (char) is
|
||||
* signed and the argument is a (char[]) This macro will fail miserably on
|
||||
* systems where (char) is more than 8 bits.
|
||||
*/
|
||||
#define PNG_STRING_FROM_CHUNK(s,c)\
|
||||
(void)(((char*)(s))[0]=(char)((c)>>24), ((char*)(s))[1]=(char)((c)>>16),\
|
||||
((char*)(s))[2]=(char)((c)>>8), ((char*)(s))[3]=(char)((c)))
|
||||
(void)(((char*)(s))[0]=(char)(((c)>>24) & 0xff), \
|
||||
((char*)(s))[1]=(char)(((c)>>16) & 0xff),\
|
||||
((char*)(s))[2]=(char)(((c)>>8) & 0xff), \
|
||||
((char*)(s))[3]=(char)((c & 0xff)))
|
||||
|
||||
/* Do the same but terminate with a null character. */
|
||||
#define PNG_CSTRING_FROM_CHUNK(s,c)\
|
||||
|
@ -850,8 +834,9 @@ PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_table, [256]);
|
|||
PNG_INTERNAL_DATA(const png_uint_16, png_sRGB_base, [512]);
|
||||
PNG_INTERNAL_DATA(const png_byte, png_sRGB_delta, [512]);
|
||||
|
||||
#define PNG_sRGB_FROM_LINEAR(linear) ((png_byte)((png_sRGB_base[(linear)>>15] +\
|
||||
((((linear)&0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8))
|
||||
#define PNG_sRGB_FROM_LINEAR(linear) \
|
||||
((png_byte)(0xff & ((png_sRGB_base[(linear)>>15] \
|
||||
+ ((((linear) & 0x7fff)*png_sRGB_delta[(linear)>>15])>>12)) >> 8)))
|
||||
/* Given a value 'linear' in the range 0..255*65535 calculate the 8-bit sRGB
|
||||
* encoded value with maximum error 0.646365. Note that the input is not a
|
||||
* 16-bit value; it has been multiplied by 255! */
|
||||
|
@ -1408,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_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_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_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_push_restore_buffer,(png_structrp png_ptr,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.17 [March 26, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -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
|
||||
* handled.
|
||||
*/
|
||||
# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
|
||||
# if PNG_RELEASE_BUILD
|
||||
png_ptr->flags |= PNG_FLAG_APP_WARNINGS_WARN;
|
||||
# endif
|
||||
# endif
|
||||
|
@ -814,8 +814,7 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
|
|||
/* Zero length IDATs are legal after the last IDAT has been
|
||||
* read, but not after other chunks have been read.
|
||||
*/
|
||||
if ((length > 0) ||
|
||||
(png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
|
||||
if ((length > 0) || (png_ptr->mode & PNG_HAVE_CHUNK_AFTER_IDAT) != 0)
|
||||
png_benign_error(png_ptr, "Too many IDATs found");
|
||||
|
||||
png_crc_finish(png_ptr, length);
|
||||
|
@ -1824,6 +1823,7 @@ png_create_colormap_entry(png_image_read_control *display,
|
|||
y = (y + 128) >> 8;
|
||||
y *= 255;
|
||||
y = PNG_sRGB_FROM_LINEAR((y + 64) >> 7);
|
||||
alpha = PNG_DIV257(alpha);
|
||||
encoding = P_sRGB;
|
||||
}
|
||||
|
||||
|
@ -2286,8 +2286,14 @@ png_image_read_colormap(png_voidp argument)
|
|||
output_processing = PNG_CMAP_NONE;
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef __COVERITY__
|
||||
/* Coverity claims that output_encoding cannot be 2 (P_LINEAR)
|
||||
* here.
|
||||
*/
|
||||
back_alpha = 255;
|
||||
#else
|
||||
back_alpha = output_encoding == P_LINEAR ? 65535 : 255;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* output_processing means that the libpng-processed row will be
|
||||
|
@ -2412,7 +2418,14 @@ png_image_read_colormap(png_voidp argument)
|
|||
*/
|
||||
background_index = i;
|
||||
png_create_colormap_entry(display, i++, back_r, back_g, back_b,
|
||||
output_encoding == P_LINEAR ? 65535U : 255U, output_encoding);
|
||||
#ifdef __COVERITY__
|
||||
/* Coverity claims that output_encoding cannot be 2 (P_LINEAR)
|
||||
* here.
|
||||
*/ 255U,
|
||||
#else
|
||||
output_encoding == P_LINEAR ? 65535U : 255U,
|
||||
#endif
|
||||
output_encoding);
|
||||
|
||||
/* For non-opaque input composite on the sRGB background - this
|
||||
* requires inverting the encoding for each component. The input
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.17 [March 26, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -26,7 +26,7 @@
|
|||
* reads from a file pointer. Note that this routine sometimes gets called
|
||||
* with very small lengths, so you should implement some kind of simple
|
||||
* buffering if you are using unbuffered reads. This should never be asked
|
||||
* to read more then 64K on a 16 bit machine.
|
||||
* to read more than 64K on a 16 bit machine.
|
||||
*/
|
||||
void /* PRIVATE */
|
||||
png_read_data(png_structrp png_ptr, png_bytep data, png_size_t length)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -394,7 +394,7 @@ png_set_alpha_mode(png_structrp png_ptr, int mode, double output_gamma)
|
|||
/* Dither file to 8-bit. Supply a palette, the current number
|
||||
* of elements in the palette, the maximum number of elements
|
||||
* allowed, and a histogram if possible. If the current number
|
||||
* of colors is greater then the maximum number, the palette will be
|
||||
* of colors is greater than the maximum number, the palette will be
|
||||
* modified to fit in the maximum number. "full_quantize" indicates
|
||||
* whether we need a quantizing cube set up for RGB images, or if we
|
||||
* simply are reducing the number of colors in a paletted image.
|
||||
|
@ -2357,7 +2357,7 @@ png_do_unshift(png_row_infop row_info, png_bytep row,
|
|||
if (++channel >= channels)
|
||||
channel = 0;
|
||||
*bp++ = (png_byte)(value >> 8);
|
||||
*bp++ = (png_byte)(value & 0xff);
|
||||
*bp++ = (png_byte)value;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -2662,9 +2662,9 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
|||
png_uint_32 row_width = row_info->width;
|
||||
|
||||
#ifdef PNG_READ_16BIT_SUPPORTED
|
||||
png_byte hi_filler = (png_byte)((filler>>8) & 0xff);
|
||||
png_byte hi_filler = (png_byte)(filler>>8);
|
||||
#endif
|
||||
png_byte lo_filler = (png_byte)(filler & 0xff);
|
||||
png_byte lo_filler = (png_byte)filler;
|
||||
|
||||
png_debug(1, "in png_do_read_filler");
|
||||
|
||||
|
@ -2715,13 +2715,13 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
|||
png_bytep dp = sp + (png_size_t)row_width * 2;
|
||||
for (i = 1; i < row_width; i++)
|
||||
{
|
||||
*(--dp) = hi_filler;
|
||||
*(--dp) = lo_filler;
|
||||
*(--dp) = hi_filler;
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
}
|
||||
*(--dp) = hi_filler;
|
||||
*(--dp) = lo_filler;
|
||||
*(--dp) = hi_filler;
|
||||
row_info->channels = 2;
|
||||
row_info->pixel_depth = 32;
|
||||
row_info->rowbytes = row_width * 4;
|
||||
|
@ -2736,8 +2736,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
|||
{
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = hi_filler;
|
||||
*(--dp) = lo_filler;
|
||||
*(--dp) = hi_filler;
|
||||
}
|
||||
row_info->channels = 2;
|
||||
row_info->pixel_depth = 32;
|
||||
|
@ -2796,8 +2796,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
|||
png_bytep dp = sp + (png_size_t)row_width * 2;
|
||||
for (i = 1; i < row_width; i++)
|
||||
{
|
||||
*(--dp) = hi_filler;
|
||||
*(--dp) = lo_filler;
|
||||
*(--dp) = hi_filler;
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
|
@ -2805,8 +2805,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
|||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
}
|
||||
*(--dp) = hi_filler;
|
||||
*(--dp) = lo_filler;
|
||||
*(--dp) = hi_filler;
|
||||
row_info->channels = 4;
|
||||
row_info->pixel_depth = 64;
|
||||
row_info->rowbytes = row_width * 8;
|
||||
|
@ -2825,8 +2825,8 @@ png_do_read_filler(png_row_infop row_info, png_bytep row,
|
|||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = *(--sp);
|
||||
*(--dp) = hi_filler;
|
||||
*(--dp) = lo_filler;
|
||||
*(--dp) = hi_filler;
|
||||
}
|
||||
|
||||
row_info->channels = 4;
|
||||
|
@ -3087,10 +3087,11 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
|
|||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
png_uint_16 red, green, blue, w;
|
||||
png_byte hi,lo;
|
||||
|
||||
red = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
|
||||
green = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
|
||||
blue = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
|
||||
hi=*(sp)++; lo=*(sp)++; red = (png_uint_16)((hi << 8) | (lo));
|
||||
hi=*(sp)++; lo=*(sp)++; green = (png_uint_16)((hi << 8) | (lo));
|
||||
hi=*(sp)++; lo=*(sp)++; blue = (png_uint_16)((hi << 8) | (lo));
|
||||
|
||||
if (red == green && red == blue)
|
||||
{
|
||||
|
@ -3104,16 +3105,16 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
|
|||
|
||||
else
|
||||
{
|
||||
png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red&0xff)
|
||||
png_uint_16 red_1 = png_ptr->gamma_16_to_1[(red & 0xff)
|
||||
>> png_ptr->gamma_shift][red>>8];
|
||||
png_uint_16 green_1 =
|
||||
png_ptr->gamma_16_to_1[(green&0xff) >>
|
||||
png_ptr->gamma_16_to_1[(green & 0xff) >>
|
||||
png_ptr->gamma_shift][green>>8];
|
||||
png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue&0xff)
|
||||
png_uint_16 blue_1 = png_ptr->gamma_16_to_1[(blue & 0xff)
|
||||
>> png_ptr->gamma_shift][blue>>8];
|
||||
png_uint_16 gray16 = (png_uint_16)((rc*red_1 + gc*green_1
|
||||
+ bc*blue_1 + 16384)>>15);
|
||||
w = png_ptr->gamma_16_from_1[(gray16&0xff) >>
|
||||
w = png_ptr->gamma_16_from_1[(gray16 & 0xff) >>
|
||||
png_ptr->gamma_shift][gray16 >> 8];
|
||||
rgb_error |= 1;
|
||||
}
|
||||
|
@ -3138,10 +3139,11 @@ png_do_rgb_to_gray(png_structrp png_ptr, png_row_infop row_info, png_bytep row)
|
|||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
png_uint_16 red, green, blue, gray16;
|
||||
png_byte hi,lo;
|
||||
|
||||
red = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
|
||||
green = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
|
||||
blue = (png_uint_16)(((*(sp)) << 8) | *(sp + 1)); sp += 2;
|
||||
hi=*(sp)++; lo=*(sp)++; red = (png_uint_16)((hi << 8) | (lo));
|
||||
hi=*(sp)++; lo=*(sp)++; green = (png_uint_16)((hi << 8) | (lo));
|
||||
hi=*(sp)++; lo=*(sp)++; blue = (png_uint_16)((hi << 8) | (lo));
|
||||
|
||||
if (red != green || red != blue)
|
||||
rgb_error |= 1;
|
||||
|
@ -3667,7 +3669,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
|||
if (optimize != 0)
|
||||
w = v;
|
||||
else
|
||||
w = gamma_16_from_1[(v&0xff) >> gamma_shift][v >> 8];
|
||||
w = gamma_16_from_1[(v & 0xff) >>
|
||||
gamma_shift][v >> 8];
|
||||
*sp = (png_byte)((w >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(w & 0xff);
|
||||
}
|
||||
|
@ -3831,7 +3834,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
|||
v = gamma_16_to_1[*(sp + 1) >> gamma_shift][*sp];
|
||||
png_composite_16(w, v, a, png_ptr->background_1.red);
|
||||
if (optimize == 0)
|
||||
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
|
||||
w = gamma_16_from_1[((w & 0xff) >> gamma_shift)][w >>
|
||||
8];
|
||||
*sp = (png_byte)((w >> 8) & 0xff);
|
||||
*(sp + 1) = (png_byte)(w & 0xff);
|
||||
|
@ -3839,7 +3842,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
|||
v = gamma_16_to_1[*(sp + 3) >> gamma_shift][*(sp + 2)];
|
||||
png_composite_16(w, v, a, png_ptr->background_1.green);
|
||||
if (optimize == 0)
|
||||
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
|
||||
w = gamma_16_from_1[((w & 0xff) >> gamma_shift)][w >>
|
||||
8];
|
||||
|
||||
*(sp + 2) = (png_byte)((w >> 8) & 0xff);
|
||||
|
@ -3848,7 +3851,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
|||
v = gamma_16_to_1[*(sp + 5) >> gamma_shift][*(sp + 4)];
|
||||
png_composite_16(w, v, a, png_ptr->background_1.blue);
|
||||
if (optimize == 0)
|
||||
w = gamma_16_from_1[((w&0xff) >> gamma_shift)][w >>
|
||||
w = gamma_16_from_1[((w & 0xff) >> gamma_shift)][w >>
|
||||
8];
|
||||
|
||||
*(sp + 4) = (png_byte)((w >> 8) & 0xff);
|
||||
|
@ -4457,7 +4460,7 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
|||
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
if (*sp == gray)
|
||||
if ((*sp & 0xffU) == gray)
|
||||
*dp-- = 0;
|
||||
|
||||
else
|
||||
|
@ -4475,7 +4478,8 @@ png_do_expand(png_row_infop row_info, png_bytep row,
|
|||
dp = row + (row_info->rowbytes << 1) - 1;
|
||||
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;
|
||||
|
@ -4837,7 +4841,7 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
|
|||
/* Because PNG_COMPOSE does the gamma transform if there is something to
|
||||
* do (if there is an alpha channel or transparency.)
|
||||
*/
|
||||
!((png_ptr->transformations & PNG_COMPOSE) &&
|
||||
!((png_ptr->transformations & PNG_COMPOSE) != 0 &&
|
||||
((png_ptr->num_trans != 0) ||
|
||||
(png_ptr->color_type & PNG_COLOR_MASK_ALPHA) != 0)) &&
|
||||
#endif
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngrutil.c - utilities to read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -341,7 +341,7 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
|
|||
* are minimal.
|
||||
*/
|
||||
(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_ptr->zowner = 0;
|
||||
#else
|
||||
|
@ -575,7 +575,7 @@ png_decompress_chunk(png_structrp png_ptr,
|
|||
*/
|
||||
png_alloc_size_t limit = PNG_SIZE_MAX;
|
||||
|
||||
# ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
|
||||
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
if (png_ptr->user_chunk_malloc_max > 0 &&
|
||||
png_ptr->user_chunk_malloc_max < limit)
|
||||
limit = png_ptr->user_chunk_malloc_max;
|
||||
|
@ -670,7 +670,6 @@ png_decompress_chunk(png_structrp png_ptr,
|
|||
* success)
|
||||
*/
|
||||
png_free(png_ptr, text);
|
||||
text = NULL;
|
||||
|
||||
/* This really is very benign, but it's still an error because
|
||||
* 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;
|
||||
|
||||
for (i=0; i<truelen; ++i)
|
||||
{
|
||||
if (buf[i] == 0 || buf[i] > sample_depth)
|
||||
{
|
||||
png_chunk_benign_error(png_ptr, "invalid");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
{
|
||||
|
@ -1515,8 +1516,10 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||
else if (size > 0)
|
||||
errmsg = "truncated";
|
||||
|
||||
#ifndef __COVERITY__
|
||||
else
|
||||
errmsg = png_ptr->zstream.msg;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* else png_icc_check_tag_table output an error */
|
||||
|
@ -1815,7 +1818,8 @@ png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||
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)
|
||||
{
|
||||
png_crc_finish(png_ptr, length);
|
||||
|
@ -1978,7 +1982,7 @@ png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||
|
||||
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_chunk_benign_error(png_ptr, "invalid");
|
||||
|
@ -2713,7 +2717,7 @@ png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length)
|
|||
png_ptr->unknown_chunk.data = NULL;
|
||||
}
|
||||
|
||||
# ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
|
||||
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
if (png_ptr->user_chunk_malloc_max > 0 &&
|
||||
png_ptr->user_chunk_malloc_max < limit)
|
||||
limit = png_ptr->user_chunk_malloc_max;
|
||||
|
@ -2804,7 +2808,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
|||
&png_ptr->unknown_chunk);
|
||||
|
||||
/* ret is:
|
||||
* negative: An error occured, png_chunk_error will be called.
|
||||
* negative: An error occurred; png_chunk_error will be called.
|
||||
* zero: The chunk was not handled, the chunk will be discarded
|
||||
* unless png_set_keep_unknown_chunks has been used to set
|
||||
* a 'keep' behavior for this particular chunk, in which
|
||||
|
@ -3810,15 +3814,15 @@ png_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row,
|
|||
p = b - c;
|
||||
pc = a - c;
|
||||
|
||||
# ifdef PNG_USE_ABS
|
||||
#ifdef PNG_USE_ABS
|
||||
pa = abs(p);
|
||||
pb = abs(pc);
|
||||
pc = abs(p + pc);
|
||||
# else
|
||||
#else
|
||||
pa = p < 0 ? -p : p;
|
||||
pb = pc < 0 ? -pc : pc;
|
||||
pc = (p + pc) < 0 ? -(p + pc) : p + pc;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Find the best predictor, the least of pa, pb, pc favoring the earlier
|
||||
* ones in the case of a tie.
|
||||
|
@ -3865,15 +3869,15 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
|
|||
p = b - c;
|
||||
pc = a - c;
|
||||
|
||||
# ifdef PNG_USE_ABS
|
||||
#ifdef PNG_USE_ABS
|
||||
pa = abs(p);
|
||||
pb = abs(pc);
|
||||
pc = abs(p + pc);
|
||||
# else
|
||||
#else
|
||||
pa = p < 0 ? -p : p;
|
||||
pb = pc < 0 ? -pc : pc;
|
||||
pc = (p + pc) < 0 ? -(p + pc) : p + pc;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
if (pb < pa) pa = pb, a = b;
|
||||
if (pc < pa) a = c;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -190,6 +190,7 @@ png_set_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
if (info_ptr->hist == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Insufficient memory for hIST chunk data");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -301,6 +302,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
if (info_ptr->pcal_purpose == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Insufficient memory for pCAL purpose");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -322,6 +324,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
if (info_ptr->pcal_units == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Insufficient memory for pCAL units");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -333,6 +336,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
if (info_ptr->pcal_params == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Insufficient memory for pCAL params");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -349,6 +353,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
if (info_ptr->pcal_params[i] == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Insufficient memory for pCAL parameter");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -398,6 +403,7 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
if (info_ptr->scal_s_width == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Memory allocation failed while processing sCAL");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -416,6 +422,7 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
info_ptr->scal_s_width = NULL;
|
||||
|
||||
png_warning(png_ptr, "Memory allocation failed while processing sCAL");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -519,6 +526,7 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
|
|||
else
|
||||
{
|
||||
png_warning(png_ptr, "Invalid palette length");
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -531,7 +539,6 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
|
|||
))
|
||||
{
|
||||
png_error(png_ptr, "Invalid palette");
|
||||
return;
|
||||
}
|
||||
|
||||
/* It may not actually be necessary to set png_ptr->palette here;
|
||||
|
@ -655,6 +662,7 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
if (new_iccp_name == NULL)
|
||||
{
|
||||
png_benign_error(png_ptr, "Insufficient memory to process iCCP chunk");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -665,9 +673,9 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
if (new_iccp_profile == NULL)
|
||||
{
|
||||
png_free(png_ptr, new_iccp_name);
|
||||
new_iccp_name = NULL;
|
||||
png_benign_error(png_ptr,
|
||||
"Insufficient memory to process iCCP profile");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -701,7 +709,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
{
|
||||
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);
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL || num_text <= 0 || text_ptr == NULL)
|
||||
|
@ -743,6 +751,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
{
|
||||
png_chunk_report(png_ptr, "too many text chunks",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -798,7 +807,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
else
|
||||
lang_key_len = 0;
|
||||
}
|
||||
# else /* PNG_iTXt_SUPPORTED */
|
||||
# else /* iTXt */
|
||||
{
|
||||
png_chunk_report(png_ptr, "iTXt chunk not supported",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
|
@ -831,6 +840,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
{
|
||||
png_chunk_report(png_ptr, "text chunk: out of memory",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -904,6 +914,7 @@ png_set_tIME(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
mod_time->second > 60)
|
||||
{
|
||||
png_warning(png_ptr, "Ignoring invalid time value");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -920,6 +931,7 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
|
|||
png_debug1(1, "in %s storage function", "tRNS");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
|
||||
return;
|
||||
|
||||
if (trans_alpha != NULL)
|
||||
|
@ -945,7 +957,10 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
|
|||
|
||||
if (trans_color != NULL)
|
||||
{
|
||||
int sample_max = (1 << info_ptr->bit_depth);
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
if (info_ptr->bit_depth < 16)
|
||||
{
|
||||
int sample_max = (1 << info_ptr->bit_depth) - 1;
|
||||
|
||||
if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY &&
|
||||
trans_color->gray > sample_max) ||
|
||||
|
@ -955,6 +970,8 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
|
|||
trans_color->blue > sample_max)))
|
||||
png_warning(png_ptr,
|
||||
"tRNS chunk has out-of-range samples for bit_depth");
|
||||
}
|
||||
#endif
|
||||
|
||||
info_ptr->trans_color = *trans_color;
|
||||
|
||||
|
@ -1001,6 +1018,7 @@ png_set_sPLT(png_const_structrp png_ptr,
|
|||
{
|
||||
/* Out of memory or too many chunks */
|
||||
png_chunk_report(png_ptr, "too many sPLT chunks", PNG_CHUNK_WRITE_ERROR);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1130,6 +1148,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
|
|||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0)
|
||||
{
|
||||
png_app_error(png_ptr, "no unknown chunk support on read");
|
||||
|
||||
return;
|
||||
}
|
||||
# endif
|
||||
|
@ -1138,6 +1157,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
|
|||
if ((png_ptr->mode & PNG_IS_READ_STRUCT) == 0)
|
||||
{
|
||||
png_app_error(png_ptr, "no unknown chunk support on write");
|
||||
|
||||
return;
|
||||
}
|
||||
# endif
|
||||
|
@ -1155,6 +1175,7 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
|
|||
{
|
||||
png_chunk_report(png_ptr, "too many unknown chunks",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1232,8 +1253,7 @@ png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
check_location(png_ptr, location);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* STORE_UNKNOWN_CHUNKS */
|
||||
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
|
@ -1264,6 +1284,7 @@ add_one_chunk(png_bytep list, unsigned int count, png_const_bytep add, int keep)
|
|||
if (memcmp(list, add, 4) == 0)
|
||||
{
|
||||
list[4] = (png_byte)keep;
|
||||
|
||||
return count;
|
||||
}
|
||||
}
|
||||
|
@ -1291,6 +1312,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
|||
if (keep < 0 || keep >= PNG_HANDLE_CHUNK_LAST)
|
||||
{
|
||||
png_app_error(png_ptr, "png_set_keep_unknown_chunks: invalid keep");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1340,6 +1362,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
|||
* which can be switched off.
|
||||
*/
|
||||
png_app_error(png_ptr, "png_set_keep_unknown_chunks: no chunk list");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1355,6 +1378,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
|||
if (num_chunks + old_num_chunks > UINT_MAX/5)
|
||||
{
|
||||
png_app_error(png_ptr, "png_set_keep_unknown_chunks: too many chunks");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1492,23 +1516,30 @@ png_set_compression_buffer_size(png_structrp png_ptr, png_size_t size)
|
|||
{
|
||||
png_warning(png_ptr,
|
||||
"Compression buffer size cannot be changed because it is in use");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#ifndef __COVERITY__
|
||||
/* Some compilers complain that this is always false. However, it
|
||||
* can be true when integer overflow happens.
|
||||
*/
|
||||
if (size > ZLIB_IO_MAX)
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Compression buffer size limited to system maximum");
|
||||
size = ZLIB_IO_MAX; /* must fit */
|
||||
}
|
||||
#endif
|
||||
|
||||
else if (size < 6)
|
||||
if (size < 6)
|
||||
{
|
||||
/* Deflate will potentially go into an infinite loop on a SYNC_FLUSH
|
||||
* if this is permitted.
|
||||
*/
|
||||
png_warning(png_ptr,
|
||||
"Compression buffer size cannot be reduced below 6");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
|
||||
/* pngstruct.h - header file for PNG reference library
|
||||
*
|
||||
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
* Last changed in libpng 1.6.1 [March 28, 2013]
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
|
@ -101,7 +100,7 @@ typedef struct png_XYZ
|
|||
#endif /* COLORSPACE */
|
||||
|
||||
#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
|
||||
/* A colorspace is all the above plus, potentially, profile information,
|
||||
/* A colorspace is all the above plus, potentially, profile information;
|
||||
* however at present libpng does not use the profile internally so it is only
|
||||
* stored in the png_info struct (if iCCP is supported.) The rendering intent
|
||||
* is retained here and is checked.
|
||||
|
@ -220,16 +219,18 @@ struct png_struct_def
|
|||
png_uint_32 row_number; /* current row in interlace pass */
|
||||
png_uint_32 chunk_name; /* PNG_CHUNK() id of current chunk */
|
||||
png_bytep prev_row; /* buffer to save previous (unfiltered) row.
|
||||
* This is a pointer into big_prev_row
|
||||
* 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.
|
||||
* 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
|
||||
png_bytep sub_row; /* buffer to save "sub" row when filtering */
|
||||
png_bytep up_row; /* buffer to save "up" row when filtering */
|
||||
png_bytep avg_row; /* buffer to save "avg" row when filtering */
|
||||
png_bytep paeth_row; /* buffer to save "Paeth" row when filtering */
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
png_bytep try_row; /* buffer to save trial row when filtering */
|
||||
png_bytep tst_row; /* buffer to save best trial row when filtering */
|
||||
#endif
|
||||
png_size_t info_rowbytes; /* Added in 1.5.4: cache of updated row bytes */
|
||||
|
||||
|
@ -347,17 +348,7 @@ struct png_struct_def
|
|||
png_bytep quantize_index; /* index translation for palette files */
|
||||
#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
|
||||
png_byte options; /* On/off state (up to 4 options) */
|
||||
#endif
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -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--)
|
||||
{
|
||||
if (*rp >> padding != 0)
|
||||
if ((*rp >> padding) != 0)
|
||||
png_ptr->num_palette_max = 1;
|
||||
padding = 0;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngwrite.c - general routines to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -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 && \
|
||||
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;
|
||||
}
|
||||
#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.
|
||||
*
|
||||
* 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
|
||||
* is available in the COLORSPACE. (See png_colorspace_sync_info in png.c
|
||||
* for where the valid flags get set.)
|
||||
* the chunks will be written if the WRITE routine is there and
|
||||
* information * is available in the COLORSPACE. (See
|
||||
* png_colorspace_sync_info in png.c for where the valid flags get set.)
|
||||
*
|
||||
* Under certain circumstances the colorspace can be invalidated without
|
||||
* syncing the info_struct 'valid' flags; this happens if libpng detects and
|
||||
* error and calls png_error while the color space is being set, yet the
|
||||
* application continues writing the PNG. So check the 'invalid' flag here
|
||||
* too.
|
||||
* syncing the info_struct 'valid' flags; this happens if libpng detects
|
||||
* an error and calls png_error while the color space is being set, yet
|
||||
* the application continues writing the PNG. So check the 'invalid'
|
||||
* flag here too.
|
||||
*/
|
||||
#ifdef PNG_GAMMA_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 &&
|
||||
info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
int j;
|
||||
for (j = 0; j<(int)info_ptr->num_trans; j++)
|
||||
int j, jend;
|
||||
|
||||
jend = info_ptr->num_trans;
|
||||
if (jend > PNG_MAX_PALETTE_LENGTH)
|
||||
jend = PNG_MAX_PALETTE_LENGTH;
|
||||
|
||||
for (j = 0; j<jend; ++j)
|
||||
info_ptr->trans_alpha[j] =
|
||||
(png_byte)(255 - info_ptr->trans_alpha[j]);
|
||||
}
|
||||
|
@ -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
|
||||
* 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;
|
||||
#endif
|
||||
|
||||
|
@ -638,8 +644,8 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
|
|||
|
||||
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
||||
{
|
||||
*(rp) = (png_byte)((*rp - *(rp + 1)) & 0xff);
|
||||
*(rp + 2) = (png_byte)((*(rp + 2) - *(rp + 1)) & 0xff);
|
||||
*(rp) = (png_byte)(*rp - *(rp + 1));
|
||||
*(rp + 2) = (png_byte)(*(rp + 2) - *(rp + 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -665,10 +671,10 @@ png_do_write_intrapixel(png_row_infop row_info, png_bytep row)
|
|||
png_uint_32 s2 = (*(rp + 4) << 8) | *(rp + 5);
|
||||
png_uint_32 red = (png_uint_32)((s0 - s1) & 0xffffL);
|
||||
png_uint_32 blue = (png_uint_32)((s2 - s1) & 0xffffL);
|
||||
*(rp ) = (png_byte)((red >> 8) & 0xff);
|
||||
*(rp + 1) = (png_byte)(red & 0xff);
|
||||
*(rp + 4) = (png_byte)((blue >> 8) & 0xff);
|
||||
*(rp + 5) = (png_byte)(blue & 0xff);
|
||||
*(rp ) = (png_byte)(red >> 8);
|
||||
*(rp + 1) = (png_byte)red;
|
||||
*(rp + 4) = (png_byte)(blue >> 8);
|
||||
*(rp + 5) = (png_byte)blue;
|
||||
}
|
||||
}
|
||||
#endif /* WRITE_16BIT */
|
||||
|
@ -917,10 +923,6 @@ png_write_flush(png_structrp png_ptr)
|
|||
}
|
||||
#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. */
|
||||
static void
|
||||
png_write_destroy(png_structrp png_ptr)
|
||||
|
@ -937,24 +939,11 @@ png_write_destroy(png_structrp png_ptr)
|
|||
png_ptr->row_buf = NULL;
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
png_free(png_ptr, png_ptr->prev_row);
|
||||
png_free(png_ptr, png_ptr->sub_row);
|
||||
png_free(png_ptr, png_ptr->up_row);
|
||||
png_free(png_ptr, png_ptr->avg_row);
|
||||
png_free(png_ptr, png_ptr->paeth_row);
|
||||
png_free(png_ptr, png_ptr->try_row);
|
||||
png_free(png_ptr, png_ptr->tst_row);
|
||||
png_ptr->prev_row = NULL;
|
||||
png_ptr->sub_row = NULL;
|
||||
png_ptr->up_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;
|
||||
png_ptr->try_row = NULL;
|
||||
png_ptr->tst_row = NULL;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
|
||||
|
@ -1044,211 +1033,85 @@ png_set_filter(png_structrp png_ptr, int method, int filters)
|
|||
#endif /* WRITE_FILTER */
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
/* If we have allocated the row_buf, this means we have already started
|
||||
* with the image and we should have allocated all of the filter buffers
|
||||
* that have been selected. If prev_row isn't already allocated, then
|
||||
* it is too late to start using the filters that need it, since we
|
||||
* will be missing the data in the previous row. If an application
|
||||
* wants to start and stop using particular filters during compression,
|
||||
* it should start out with all of the filters, and then add and
|
||||
* remove them after the start of compression.
|
||||
* it should start out with all of the filters, and then remove them
|
||||
* 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)
|
||||
{
|
||||
#ifdef PNG_WRITE_FILTER_SUPPORTED
|
||||
if ((png_ptr->do_filter & PNG_FILTER_SUB) != 0 &&
|
||||
png_ptr->sub_row == NULL)
|
||||
int num_filters;
|
||||
png_alloc_size_t buf_size;
|
||||
|
||||
/* Repeat the checks in png_write_start_row; 1 pixel high or wide
|
||||
* images cannot benefit from certain filters. If this isn't done here
|
||||
* the check below will fire on 1 pixel high images.
|
||||
*/
|
||||
if (png_ptr->height == 1)
|
||||
filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH);
|
||||
|
||||
if (png_ptr->width == 1)
|
||||
filters &= ~(PNG_FILTER_SUB|PNG_FILTER_AVG|PNG_FILTER_PAETH);
|
||||
|
||||
if ((filters & (PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH)) != 0
|
||||
&& png_ptr->prev_row == NULL)
|
||||
{
|
||||
png_ptr->sub_row = (png_bytep)png_malloc(png_ptr,
|
||||
(png_ptr->rowbytes + 1));
|
||||
png_ptr->sub_row[0] = PNG_FILTER_VALUE_SUB;
|
||||
/* This is the error case, however it is benign - the previous row
|
||||
* is not available so the filter can't be used. Just warn here.
|
||||
*/
|
||||
png_app_warning(png_ptr,
|
||||
"png_set_filter: UP/AVG/PAETH cannot be added after start");
|
||||
filters &= ~(PNG_FILTER_UP|PNG_FILTER_AVG|PNG_FILTER_PAETH);
|
||||
}
|
||||
|
||||
if ((png_ptr->do_filter & PNG_FILTER_UP) != 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);
|
||||
}
|
||||
num_filters = 0;
|
||||
|
||||
else
|
||||
{
|
||||
png_ptr->up_row = (png_bytep)png_malloc(png_ptr,
|
||||
(png_ptr->rowbytes + 1));
|
||||
png_ptr->up_row[0] = PNG_FILTER_VALUE_UP;
|
||||
}
|
||||
}
|
||||
if (filters & PNG_FILTER_SUB)
|
||||
num_filters++;
|
||||
|
||||
if ((png_ptr->do_filter & PNG_FILTER_AVG) != 0 &&
|
||||
png_ptr->avg_row == NULL)
|
||||
{
|
||||
if (png_ptr->prev_row == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Can't add Average filter after starting");
|
||||
png_ptr->do_filter = (png_byte)(png_ptr->do_filter &
|
||||
~PNG_FILTER_AVG);
|
||||
}
|
||||
if (filters & PNG_FILTER_UP)
|
||||
num_filters++;
|
||||
|
||||
else
|
||||
{
|
||||
png_ptr->avg_row = (png_bytep)png_malloc(png_ptr,
|
||||
(png_ptr->rowbytes + 1));
|
||||
png_ptr->avg_row[0] = PNG_FILTER_VALUE_AVG;
|
||||
}
|
||||
}
|
||||
if (filters & PNG_FILTER_AVG)
|
||||
num_filters++;
|
||||
|
||||
if ((png_ptr->do_filter & PNG_FILTER_PAETH) != 0 &&
|
||||
png_ptr->paeth_row == NULL)
|
||||
{
|
||||
if (png_ptr->prev_row == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Can't add Paeth filter after starting");
|
||||
png_ptr->do_filter &= (png_byte)(~PNG_FILTER_PAETH);
|
||||
}
|
||||
if (filters & PNG_FILTER_PAETH)
|
||||
num_filters++;
|
||||
|
||||
else
|
||||
{
|
||||
png_ptr->paeth_row = (png_bytep)png_malloc(png_ptr,
|
||||
(png_ptr->rowbytes + 1));
|
||||
png_ptr->paeth_row[0] = PNG_FILTER_VALUE_PAETH;
|
||||
}
|
||||
}
|
||||
/* Allocate needed row buffers if they have not already been
|
||||
* allocated.
|
||||
*/
|
||||
buf_size = PNG_ROWBYTES(png_ptr->usr_channels * png_ptr->usr_bit_depth,
|
||||
png_ptr->width) + 1;
|
||||
|
||||
if (png_ptr->do_filter == PNG_NO_FILTERS)
|
||||
#endif /* WRITE_FILTER */
|
||||
png_ptr->do_filter = PNG_FILTER_NONE;
|
||||
if (png_ptr->try_row == NULL)
|
||||
png_ptr->try_row = png_voidcast(png_bytep,
|
||||
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
|
||||
png_error(png_ptr, "Unknown custom filter method");
|
||||
}
|
||||
|
||||
/* This allows us to influence the way in which libpng chooses the "best"
|
||||
* 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;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */
|
||||
/* Provide floating and fixed point APIs */
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
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,
|
||||
png_const_doublep filter_costs)
|
||||
{
|
||||
png_debug(1, "in png_set_filter_heuristics");
|
||||
|
||||
/* The internal API allocates all the arrays and ensures that the elements of
|
||||
* those arrays are set to the default value.
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(heuristic_method)
|
||||
PNG_UNUSED(num_weights)
|
||||
PNG_UNUSED(filter_weights)
|
||||
PNG_UNUSED(filter_costs)
|
||||
}
|
||||
#endif /* FLOATING_POINT */
|
||||
|
||||
|
@ -1311,67 +1133,16 @@ png_set_filter_heuristics_fixed(png_structrp png_ptr, int heuristic_method,
|
|||
int num_weights, png_const_fixed_point_p filter_weights,
|
||||
png_const_fixed_point_p filter_costs)
|
||||
{
|
||||
png_debug(1, "in png_set_filter_heuristics_fixed");
|
||||
|
||||
/* The internal API allocates all the arrays and ensures that the elements of
|
||||
* those arrays are set to the default value.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(heuristic_method)
|
||||
PNG_UNUSED(num_weights)
|
||||
PNG_UNUSED(filter_weights)
|
||||
PNG_UNUSED(filter_costs)
|
||||
}
|
||||
#endif /* FIXED_POINT */
|
||||
#endif /* WRITE_WEIGHTED_FILTER */
|
||||
|
||||
#ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_compression_level(png_structrp png_ptr, int level)
|
||||
{
|
||||
|
@ -1417,8 +1188,8 @@ png_set_compression_window_bits(png_structrp png_ptr, int window_bits)
|
|||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* Prior to 1.6.0 this would warn but then set the window_bits value, this
|
||||
* meant that negative window bits values could be selected which would cause
|
||||
/* Prior to 1.6.0 this would warn but then set the window_bits value. This
|
||||
* meant that negative window bits values could be selected that would cause
|
||||
* libpng to write a non-standard PNG file with raw deflate or gzip
|
||||
* compressed IDAT or ancillary chunks. Such files can be read and there is
|
||||
* no warning on read, so this seems like a very bad idea.
|
||||
|
@ -1454,6 +1225,7 @@ png_set_compression_method(png_structrp png_ptr, int method)
|
|||
|
||||
png_ptr->zlib_method = method;
|
||||
}
|
||||
#endif /* WRITE_CUSTOMIZE_COMPRESSION */
|
||||
|
||||
/* The following were added to libpng-1.5.4 */
|
||||
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
|
||||
|
@ -1680,7 +1452,7 @@ png_write_png(png_structrp png_ptr, png_inforp info_ptr,
|
|||
|
||||
|
||||
#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||
#ifdef PNG_STDIO_SUPPORTED /* currently required for png_image_write_* */
|
||||
# ifdef PNG_STDIO_SUPPORTED /* currently required for png_image_write_* */
|
||||
/* Initialize the write structure - general purpose utility. */
|
||||
static int
|
||||
png_image_write_init(png_imagep image)
|
||||
|
@ -1763,10 +1535,11 @@ png_write_image_16bit(png_voidp argument)
|
|||
++input_row; /* To point to the first component */
|
||||
++output_row;
|
||||
}
|
||||
|
||||
else
|
||||
# endif
|
||||
aindex = channels;
|
||||
# else
|
||||
aindex = channels;
|
||||
# endif
|
||||
}
|
||||
|
||||
else
|
||||
|
@ -1848,7 +1621,7 @@ png_write_image_16bit(png_voidp argument)
|
|||
* calculation can be done to 15 bits of accuracy; however, the output needs to
|
||||
* be scaled in the range 0..255*65535, so include that scaling here.
|
||||
*/
|
||||
#define UNP_RECIPROCAL(alpha) ((((0xffff*0xff)<<7)+(alpha>>1))/alpha)
|
||||
# define UNP_RECIPROCAL(alpha) ((((0xffff*0xff)<<7)+(alpha>>1))/alpha)
|
||||
|
||||
static png_byte
|
||||
png_unpremultiply(png_uint_32 component, png_uint_32 alpha,
|
||||
|
@ -2287,7 +2060,9 @@ png_image_write_main(png_voidp argument)
|
|||
* it about 50 times. The speed-up in pngstest was about 10-20% of the
|
||||
* total (user) time on a heavily loaded system.
|
||||
*/
|
||||
# ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
|
||||
png_set_compression_level(png_ptr, 3);
|
||||
# endif
|
||||
}
|
||||
|
||||
/* Check for the cases that currently require a pre-transform on the row
|
||||
|
@ -2450,6 +2225,6 @@ png_image_write_to_file(png_imagep image, const char *file_name,
|
|||
else
|
||||
return 0;
|
||||
}
|
||||
#endif /* STDIO */
|
||||
# endif /* STDIO */
|
||||
#endif /* SIMPLIFIED_WRITE */
|
||||
#endif /* WRITE */
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||
* Copyright (c) 1998-2015 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -71,7 +71,8 @@ png_do_pack(png_row_infop row_info, png_bytep row, png_uint_32 bit_depth)
|
|||
case 2:
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
int shift, v;
|
||||
unsigned int shift;
|
||||
int v;
|
||||
png_uint_32 i;
|
||||
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:
|
||||
{
|
||||
png_bytep sp, dp;
|
||||
int shift, v;
|
||||
unsigned int shift;
|
||||
int v;
|
||||
png_uint_32 i;
|
||||
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++);
|
||||
*/
|
||||
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;
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
*dp = (png_byte)(255 - *(sp++));
|
||||
}
|
||||
}
|
||||
#endif /* WRITE_16BIT */
|
||||
|
@ -484,7 +486,7 @@ png_do_write_invert_alpha(png_row_infop row_info, png_bytep row)
|
|||
*/
|
||||
sp+=2; dp = sp;
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
*(dp++) = (png_byte)(255 - *(sp++));
|
||||
*dp = (png_byte)(255 - *(sp++));
|
||||
}
|
||||
}
|
||||
#endif /* WRITE_16BIT */
|
||||
|
|
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue