mirror of
https://github.com/GRRLIB/GRRLIB.git
synced 2024-11-22 15:02:20 +00:00
Update libpng to version 1.6.28
This commit is contained in:
parent
963592548f
commit
70cc945948
21 changed files with 1431 additions and 1122 deletions
|
@ -10,8 +10,8 @@ this sentence.
|
|||
|
||||
This code is released under the libpng license.
|
||||
|
||||
libpng versions 1.0.7, July 1, 2000 through 1.6.23, June 9, 2016 are
|
||||
Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
|
||||
libpng versions 1.0.7, July 1, 2000 through 1.6.28, January 5, 2017 are
|
||||
Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
|
||||
derived from libpng-1.0.6, 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:
|
||||
|
@ -22,6 +22,7 @@ added to the list of Contributing Authors:
|
|||
Cosmin Truta
|
||||
Gilles Vollant
|
||||
James Yu
|
||||
Mandar Sahastrabuddhe
|
||||
|
||||
and with the following additions to the disclaimer:
|
||||
|
||||
|
@ -127,4 +128,4 @@ any encryption software. See the EAR, paragraphs 734.3(b)(3) and
|
|||
|
||||
Glenn Randers-Pehrson
|
||||
glennrp at users.sourceforge.net
|
||||
June 9, 2016
|
||||
January 5, 2017
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* png.c - location for general purpose libpng functions
|
||||
*
|
||||
* Last changed in libpng 1.6.19 [November 12, 2015]
|
||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.28 [January 5, 2017]
|
||||
* Copyright (c) 1998-2002,2004,2006-2017 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_23 Your_png_h_is_not_version_1_6_23;
|
||||
typedef png_libpng_version_1_6_28 Your_png_h_is_not_version_1_6_28;
|
||||
|
||||
/* 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
|
||||
|
@ -458,7 +458,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
|
|||
|
||||
#ifdef PNG_TEXT_SUPPORTED
|
||||
/* Free text item num or (if num == -1) all text items */
|
||||
if (info_ptr->text != 0 &&
|
||||
if (info_ptr->text != NULL &&
|
||||
((mask & PNG_FREE_TEXT) & info_ptr->free_me) != 0)
|
||||
{
|
||||
if (num != -1)
|
||||
|
@ -477,6 +477,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
|
|||
png_free(png_ptr, info_ptr->text);
|
||||
info_ptr->text = NULL;
|
||||
info_ptr->num_text = 0;
|
||||
info_ptr->max_text = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -541,7 +542,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
|
|||
|
||||
#ifdef PNG_sPLT_SUPPORTED
|
||||
/* Free a given sPLT entry, or (if num == -1) all sPLT entries */
|
||||
if (info_ptr->splt_palettes != 0 &&
|
||||
if (info_ptr->splt_palettes != NULL &&
|
||||
((mask & PNG_FREE_SPLT) & info_ptr->free_me) != 0)
|
||||
{
|
||||
if (num != -1)
|
||||
|
@ -571,7 +572,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
|
|||
#endif
|
||||
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
if (info_ptr->unknown_chunks != 0 &&
|
||||
if (info_ptr->unknown_chunks != NULL &&
|
||||
((mask & PNG_FREE_UNKN) & info_ptr->free_me) != 0)
|
||||
{
|
||||
if (num != -1)
|
||||
|
@ -617,7 +618,7 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
|
|||
/* Free any image bits attached to the info structure */
|
||||
if (((mask & PNG_FREE_ROWS) & info_ptr->free_me) != 0)
|
||||
{
|
||||
if (info_ptr->row_pointers != 0)
|
||||
if (info_ptr->row_pointers != NULL)
|
||||
{
|
||||
png_uint_32 row;
|
||||
for (row = 0; row < info_ptr->height; row++)
|
||||
|
@ -684,7 +685,7 @@ png_init_io(png_structrp png_ptr, png_FILE_p fp)
|
|||
void PNGAPI
|
||||
png_save_int_32(png_bytep buf, png_int_32 i)
|
||||
{
|
||||
png_save_uint_32(buf, i);
|
||||
png_save_uint_32(buf, (png_uint_32)i);
|
||||
}
|
||||
# endif
|
||||
|
||||
|
@ -775,15 +776,15 @@ png_get_copyright(png_const_structrp png_ptr)
|
|||
#else
|
||||
# ifdef __STDC__
|
||||
return PNG_STRING_NEWLINE \
|
||||
"libpng version 1.6.23 - June 9, 2016" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson" \
|
||||
"libpng version 1.6.28 - January 5, 2017" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1998-2002,2004,2006-2017 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.23 - June 9, 2016\
|
||||
Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson\
|
||||
return "libpng version 1.6.28 - January 5, 2017\
|
||||
Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson\
|
||||
Copyright (c) 1996-1997 Andreas Dilger\
|
||||
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
|
||||
# endif
|
||||
|
@ -1931,8 +1932,8 @@ png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
|||
static const png_byte D50_nCIEXYZ[12] =
|
||||
{ 0x00, 0x00, 0xf6, 0xd6, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d };
|
||||
|
||||
int /* PRIVATE */
|
||||
png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
static int /* bool */
|
||||
icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
png_const_charp name, png_uint_32 profile_length)
|
||||
{
|
||||
if (profile_length < 132)
|
||||
|
@ -1942,6 +1943,40 @@ png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
|||
return 1;
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_iCCP_SUPPORTED
|
||||
int /* PRIVATE */
|
||||
png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
png_const_charp name, png_uint_32 profile_length)
|
||||
{
|
||||
if (!icc_check_length(png_ptr, colorspace, name, profile_length))
|
||||
return 0;
|
||||
|
||||
/* This needs to be here because the 'normal' check is in
|
||||
* png_decompress_chunk, yet this happens after the attempt to
|
||||
* png_malloc_base the required data. We only need this on read; on write
|
||||
* the caller supplies the profile buffer so libpng doesn't allocate it. See
|
||||
* the call to icc_check_length below (the write case).
|
||||
*/
|
||||
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
else if (png_ptr->user_chunk_malloc_max > 0 &&
|
||||
png_ptr->user_chunk_malloc_max < profile_length)
|
||||
return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
|
||||
"exceeds application limits");
|
||||
# elif PNG_USER_CHUNK_MALLOC_MAX > 0
|
||||
else if (PNG_USER_CHUNK_MALLOC_MAX < profile_length)
|
||||
return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
|
||||
"exceeds libpng limits");
|
||||
# else /* !SET_USER_LIMITS */
|
||||
/* This will get compiled out on all 32-bit and better systems. */
|
||||
else if (PNG_SIZE_MAX < profile_length)
|
||||
return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
|
||||
"exceeds system limits");
|
||||
# endif /* !SET_USER_LIMITS */
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif /* READ_iCCP */
|
||||
|
||||
int /* PRIVATE */
|
||||
png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
png_const_charp name, png_uint_32 profile_length,
|
||||
|
@ -2354,7 +2389,6 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
|
|||
|
||||
return 0; /* no match */
|
||||
}
|
||||
#endif /* PNG_sRGB_PROFILE_CHECKS >= 0 */
|
||||
|
||||
void /* PRIVATE */
|
||||
png_icc_set_sRGB(png_const_structrp png_ptr,
|
||||
|
@ -2363,12 +2397,11 @@ png_icc_set_sRGB(png_const_structrp png_ptr,
|
|||
/* Is this profile one of the known ICC sRGB profiles? If it is, just set
|
||||
* the sRGB information.
|
||||
*/
|
||||
#if PNG_sRGB_PROFILE_CHECKS >= 0
|
||||
if (png_compare_ICC_profile_with_sRGB(png_ptr, profile, adler) != 0)
|
||||
#endif
|
||||
(void)png_colorspace_set_sRGB(png_ptr, colorspace,
|
||||
(int)/*already checked*/png_get_uint_32(profile+64));
|
||||
}
|
||||
#endif /* PNG_sRGB_PROFILE_CHECKS >= 0 */
|
||||
#endif /* sRGB */
|
||||
|
||||
int /* PRIVATE */
|
||||
|
@ -2379,13 +2412,13 @@ png_colorspace_set_ICC(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
|||
if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
|
||||
return 0;
|
||||
|
||||
if (png_icc_check_length(png_ptr, colorspace, name, profile_length) != 0 &&
|
||||
if (icc_check_length(png_ptr, colorspace, name, profile_length) != 0 &&
|
||||
png_icc_check_header(png_ptr, colorspace, name, profile_length, profile,
|
||||
color_type) != 0 &&
|
||||
png_icc_check_tag_table(png_ptr, colorspace, name, profile_length,
|
||||
profile) != 0)
|
||||
{
|
||||
# ifdef PNG_sRGB_SUPPORTED
|
||||
# if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0
|
||||
/* If no sRGB support, don't try storing sRGB information */
|
||||
png_icc_set_sRGB(png_ptr, colorspace, profile, 0);
|
||||
# endif
|
||||
|
@ -2497,7 +2530,7 @@ png_check_IHDR(png_const_structrp png_ptr,
|
|||
error = 1;
|
||||
}
|
||||
|
||||
if (png_gt(((width + 7) & (~7)),
|
||||
if (png_gt(((width + 7) & (~7U)),
|
||||
((PNG_SIZE_MAX
|
||||
- 48 /* big_row_buf hack */
|
||||
- 1) /* filter byte */
|
||||
|
@ -2908,7 +2941,7 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
|||
*/
|
||||
if (exp_b10 < 0 && exp_b10 > -3) /* PLUS 3 TOTAL 4 */
|
||||
{
|
||||
czero = -exp_b10; /* PLUS 2 digits: TOTAL 3 */
|
||||
czero = (unsigned int)(-exp_b10); /* PLUS 2 digits: TOTAL 3 */
|
||||
exp_b10 = 0; /* Dot added below before first output. */
|
||||
}
|
||||
else
|
||||
|
@ -3086,11 +3119,11 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, png_size_t size,
|
|||
if (exp_b10 < 0)
|
||||
{
|
||||
*ascii++ = 45, --size; /* '-': PLUS 1 TOTAL 3+precision */
|
||||
uexp_b10 = -exp_b10;
|
||||
uexp_b10 = (unsigned int)(-exp_b10);
|
||||
}
|
||||
|
||||
else
|
||||
uexp_b10 = exp_b10;
|
||||
uexp_b10 = (unsigned int)exp_b10;
|
||||
|
||||
cdigits = 0;
|
||||
|
||||
|
@ -3152,9 +3185,9 @@ png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii,
|
|||
|
||||
/* Avoid overflow here on the minimum integer. */
|
||||
if (fp < 0)
|
||||
*ascii++ = 45, num = -fp;
|
||||
*ascii++ = 45, num = (png_uint_32)(-fp);
|
||||
else
|
||||
num = fp;
|
||||
num = (png_uint_32)fp;
|
||||
|
||||
if (num <= 0x80000000) /* else overflowed */
|
||||
{
|
||||
|
@ -4092,9 +4125,9 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth)
|
|||
|
||||
/* Remove any existing table; this copes with multiple calls to
|
||||
* png_read_update_info. The warning is because building the gamma tables
|
||||
* multiple times is a performance hit - it's harmless but the ability to call
|
||||
* png_read_update_info() multiple times is new in 1.5.6 so it seems sensible
|
||||
* to warn if the app introduces such a hit.
|
||||
* multiple times is a performance hit - it's harmless but the ability to
|
||||
* call png_read_update_info() multiple times is new in 1.5.6 so it seems
|
||||
* sensible to warn if the app introduces such a hit.
|
||||
*/
|
||||
if (png_ptr->gamma_table != NULL || png_ptr->gamma_16_table != NULL)
|
||||
{
|
||||
|
@ -4105,7 +4138,8 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth)
|
|||
if (bit_depth <= 8)
|
||||
{
|
||||
png_build_8bit_table(png_ptr, &png_ptr->gamma_table,
|
||||
png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->colorspace.gamma,
|
||||
png_ptr->screen_gamma > 0 ?
|
||||
png_reciprocal2(png_ptr->colorspace.gamma,
|
||||
png_ptr->screen_gamma) : PNG_FP_1);
|
||||
|
||||
#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
|
||||
|
@ -4117,7 +4151,8 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth)
|
|||
png_reciprocal(png_ptr->colorspace.gamma));
|
||||
|
||||
png_build_8bit_table(png_ptr, &png_ptr->gamma_from_1,
|
||||
png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) :
|
||||
png_ptr->screen_gamma > 0 ?
|
||||
png_reciprocal(png_ptr->screen_gamma) :
|
||||
png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */);
|
||||
}
|
||||
#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
|
||||
|
@ -4148,8 +4183,8 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth)
|
|||
* pow(iv, gamma).
|
||||
*
|
||||
* Thus the gamma table consists of up to 256 256-entry tables. The table
|
||||
* is selected by the (8-gamma_shift) most significant of the low 8 bits of
|
||||
* the color value then indexed by the upper 8 bits:
|
||||
* is selected by the (8-gamma_shift) most significant of the low 8 bits
|
||||
* of the color value then indexed by the upper 8 bits:
|
||||
*
|
||||
* table[low bits][high 8 bits]
|
||||
*
|
||||
|
@ -4182,8 +4217,8 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth)
|
|||
|
||||
/* NOTE: prior to 1.5.4 this test used to include PNG_BACKGROUND (now
|
||||
* PNG_COMPOSE). This effectively smashed the background calculation for
|
||||
* 16-bit output because the 8-bit table assumes the result will be reduced
|
||||
* to 8 bits.
|
||||
* 16-bit output because the 8-bit table assumes the result will be
|
||||
* reduced to 8 bits.
|
||||
*/
|
||||
if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) != 0)
|
||||
png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift,
|
||||
|
@ -4225,11 +4260,11 @@ png_set_option(png_structrp png_ptr, int option, int onoff)
|
|||
if (png_ptr != NULL && option >= 0 && option < PNG_OPTION_NEXT &&
|
||||
(option & 1) == 0)
|
||||
{
|
||||
int mask = 3 << option;
|
||||
int setting = (2 + (onoff != 0)) << option;
|
||||
int current = png_ptr->options;
|
||||
png_uint_32 mask = 3 << option;
|
||||
png_uint_32 setting = (2 + (onoff != 0)) << option;
|
||||
png_uint_32 current = png_ptr->options;
|
||||
|
||||
png_ptr->options = (png_byte)(((current & ~mask) | setting) & 0xff);
|
||||
png_ptr->options = (png_uint_32)(((current & ~mask) | setting) & 0xff);
|
||||
|
||||
return (current & mask) >> option;
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng version 1.6.23, June 9, 2016
|
||||
* libpng version 1.6.28, January 5, 2017
|
||||
*
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -12,7 +12,7 @@
|
|||
* Authors and maintainers:
|
||||
* libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat
|
||||
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||
* libpng versions 0.97, January 1998, through 1.6.23, June 9, 2016:
|
||||
* libpng versions 0.97, January 1998, through 1.6.28, January 5, 2017:
|
||||
* Glenn Randers-Pehrson.
|
||||
* See also "Contributing Authors", below.
|
||||
*/
|
||||
|
@ -25,12 +25,8 @@
|
|||
*
|
||||
* This code is released under the libpng license.
|
||||
*
|
||||
* Some files in the "contrib" directory and some configure-generated
|
||||
* files that are distributed with libpng have other copyright owners and
|
||||
* are released under other open source licenses.
|
||||
*
|
||||
* libpng versions 1.0.7, July 1, 2000 through 1.6.23, June 9, 2016 are
|
||||
* Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are
|
||||
* libpng versions 1.0.7, July 1, 2000 through 1.6.28, January 5, 2017 are
|
||||
* Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
|
||||
* derived from libpng-1.0.6, 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:
|
||||
|
@ -41,6 +37,7 @@
|
|||
* Cosmin Truta
|
||||
* Gilles Vollant
|
||||
* James Yu
|
||||
* Mandar Sahastrabuddhe
|
||||
*
|
||||
* and with the following additions to the disclaimer:
|
||||
*
|
||||
|
@ -51,10 +48,10 @@
|
|||
* risk of satisfactory quality, performance, accuracy, and effort is with
|
||||
* the user.
|
||||
*
|
||||
* Some files in the "contrib" directory have other copyright owners and
|
||||
* Some files in the "contrib" directory and some configure-generated
|
||||
* files that are distributed with libpng have other copyright owners and
|
||||
* are released under other open source licenses.
|
||||
*
|
||||
*
|
||||
* libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
|
||||
* Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
|
||||
* libpng-0.96, and are distributed according to the same disclaimer and
|
||||
|
@ -65,9 +62,6 @@
|
|||
* Glenn Randers-Pehrson
|
||||
* Willem van Schaik
|
||||
*
|
||||
* Some files in the "scripts" directory have different copyright owners
|
||||
* but are also released under this license.
|
||||
*
|
||||
* libpng versions 0.89, June 1996, through 0.96, May 1997, are
|
||||
* Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
|
||||
* and are distributed according to the same disclaimer and license as
|
||||
|
@ -213,11 +207,11 @@
|
|||
* ...
|
||||
* 1.0.19 10 10019 10.so.0.19[.0]
|
||||
* ...
|
||||
* 1.2.56 13 10256 12.so.0.56[.0]
|
||||
* 1.2.57 13 10257 12.so.0.57[.0]
|
||||
* ...
|
||||
* 1.5.27 15 10527 15.so.15.27[.0]
|
||||
* 1.5.28 15 10527 15.so.15.28[.0]
|
||||
* ...
|
||||
* 1.6.23 16 10623 16.so.16.23[.0]
|
||||
* 1.6.28 16 10628 16.so.16.28[.0]
|
||||
*
|
||||
* Henceforth the source version will match the shared-library major
|
||||
* and minor numbers; the shared-library major version number will be
|
||||
|
@ -245,13 +239,13 @@
|
|||
* Y2K compliance in libpng:
|
||||
* =========================
|
||||
*
|
||||
* June 9, 2016
|
||||
* January 5, 2017
|
||||
*
|
||||
* 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.23 are Y2K compliant. It is my belief that
|
||||
* upward through 1.6.28 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
|
||||
|
@ -313,9 +307,8 @@
|
|||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.6.23"
|
||||
#define PNG_HEADER_VERSION_STRING \
|
||||
" libpng version 1.6.23 - June 9, 2016\n"
|
||||
#define PNG_LIBPNG_VER_STRING "1.6.28"
|
||||
#define PNG_HEADER_VERSION_STRING " libpng version 1.6.28 - January 5, 2017\n"
|
||||
|
||||
#define PNG_LIBPNG_VER_SONUM 16
|
||||
#define PNG_LIBPNG_VER_DLLNUM 16
|
||||
|
@ -323,7 +316,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 23
|
||||
#define PNG_LIBPNG_VER_RELEASE 28
|
||||
|
||||
/* This should match the numeric part of the final component of
|
||||
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
|
||||
|
@ -354,7 +347,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 10623 /* 1.6.23 */
|
||||
#define PNG_LIBPNG_VER 10628 /* 1.6.28 */
|
||||
|
||||
/* Library configuration: these options cannot be changed after
|
||||
* the library has been built.
|
||||
|
@ -464,7 +457,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_23;
|
||||
typedef char* png_libpng_version_1_6_28;
|
||||
|
||||
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
|
||||
*
|
||||
|
@ -2300,8 +2293,10 @@ PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr,
|
|||
* except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to
|
||||
* be processed by libpng.
|
||||
*/
|
||||
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
|
||||
PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr,
|
||||
int keep, png_const_bytep chunk_list, int num_chunks));
|
||||
#endif /* HANDLE_AS_UNKNOWN */
|
||||
|
||||
/* The "keep" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned;
|
||||
* the result is therefore true (non-zero) if special handling is required,
|
||||
|
@ -2309,7 +2304,7 @@ PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr,
|
|||
*/
|
||||
PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr,
|
||||
png_const_bytep chunk_name));
|
||||
#endif
|
||||
#endif /* SET_UNKNOWN_CHUNKS */
|
||||
|
||||
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr,
|
||||
|
@ -2531,18 +2526,22 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
|
|||
/* fg and bg should be in `gamma 1.0' space; alpha is the opacity */
|
||||
|
||||
# define png_composite(composite, fg, alpha, bg) \
|
||||
{ png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \
|
||||
{ \
|
||||
png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \
|
||||
* (png_uint_16)(alpha) \
|
||||
+ (png_uint_16)(bg)*(png_uint_16)(255 \
|
||||
- (png_uint_16)(alpha)) + 128); \
|
||||
(composite) = (png_byte)(((temp + (temp >> 8)) >> 8) & 0xff); }
|
||||
(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 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)(0xffff & ((temp + (temp >> 16)) >> 16)); }
|
||||
(composite) = (png_uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); \
|
||||
}
|
||||
|
||||
#else /* Standard method using integer division */
|
||||
|
||||
|
@ -3221,7 +3220,11 @@ PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory,
|
|||
#endif
|
||||
#define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */
|
||||
#define PNG_SKIP_sRGB_CHECK_PROFILE 4 /* SOFTWARE: Check ICC profile for sRGB */
|
||||
#define PNG_OPTION_NEXT 6 /* Next option - numbers must be even */
|
||||
#ifdef PNG_MIPS_MSA_API_SUPPORTED
|
||||
# define PNG_MIPS_MSA 6 /* HARDWARE: MIPS Msa SIMD instructions supported */
|
||||
#endif
|
||||
#define PNG_IGNORE_ADLER32 8
|
||||
#define PNG_OPTION_NEXT 10 /* Next option - numbers must be even */
|
||||
|
||||
/* Return values: NOTE: there are four values and 'off' is *not* zero */
|
||||
#define PNG_OPTION_UNSET 0 /* Unset - defaults to off */
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
|
||||
/* pngconf.h - machine configurable file for libpng
|
||||
*
|
||||
* libpng version 1.6.23, June 9, 2016
|
||||
* libpng version 1.6.28, January 5, 2017
|
||||
*
|
||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 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.)
|
||||
*
|
||||
|
@ -507,9 +507,9 @@
|
|||
# error "libpng requires a signed 32-bit (or more) type"
|
||||
#endif
|
||||
|
||||
#if UINT_MAX > 4294967294
|
||||
#if UINT_MAX > 4294967294U
|
||||
typedef unsigned int png_uint_32;
|
||||
#elif ULONG_MAX > 4294967294
|
||||
#elif ULONG_MAX > 4294967294U
|
||||
typedef unsigned long int png_uint_32;
|
||||
#else
|
||||
# error "libpng requires an unsigned 32-bit (or more) type"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2002,2004,2006-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.26 [October 20, 2016]
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 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.)
|
||||
*
|
||||
|
@ -573,7 +573,7 @@ png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN)
|
|||
{
|
||||
# define fixed_message "fixed point overflow in "
|
||||
# define fixed_message_ln ((sizeof fixed_message)-1)
|
||||
int iin;
|
||||
unsigned int iin;
|
||||
char msg[fixed_message_ln+PNG_MAX_ERROR_TEXT];
|
||||
memcpy(msg, fixed_message, fixed_message_ln);
|
||||
iin = 0;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* Last changed in libpng 1.6.17 [March 26, 2015]
|
||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.26 [October 20, 2016]
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson
|
||||
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
|
||||
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
|
||||
*
|
||||
|
@ -338,7 +338,7 @@ ppi_from_ppm(png_uint_32 ppm)
|
|||
png_fixed_point result;
|
||||
if (ppm <= PNG_UINT_31_MAX && png_muldiv(&result, (png_int_32)ppm, 127,
|
||||
5000) != 0)
|
||||
return result;
|
||||
return (png_uint_32)result;
|
||||
|
||||
/* Overflow. */
|
||||
return 0;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
/* pnglibconf.h - library build configuration */
|
||||
|
||||
/* libpng version 1.6.18, July 23, 2015 */
|
||||
/* libpng version 1.6.28, January 5, 2017 */
|
||||
|
||||
/* Copyright (c) 1998-2014 Glenn Randers-Pehrson */
|
||||
/* Copyright (c) 1998-2016 Glenn Randers-Pehrson */
|
||||
|
||||
/* This code is released under the libpng license. */
|
||||
/* For conditions of distribution and use, see the disclaimer */
|
||||
|
@ -107,6 +107,7 @@
|
|||
#define PNG_SIMPLIFIED_READ_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
|
||||
#define PNG_SIMPLIFIED_WRITE_SUPPORTED
|
||||
#define PNG_STDIO_SUPPORTED
|
||||
#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
|
@ -183,7 +184,6 @@
|
|||
/* end of options */
|
||||
/* settings */
|
||||
#define PNG_API_RULE 0
|
||||
#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
|
||||
|
@ -202,9 +202,8 @@
|
|||
#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
|
||||
#define PNG_ZLIB_VERNUM 0x12b0
|
||||
#define PNG_Z_DEFAULT_COMPRESSION (-1)
|
||||
#define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0
|
||||
#define PNG_Z_DEFAULT_STRATEGY 1
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngmem.c - stub functions for memory allocation
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2002,2004,2006-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.26 [October 20, 2016]
|
||||
* Copyright (c) 1998-2002,2004,2006-2014,2016 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.)
|
||||
*
|
||||
|
@ -109,7 +109,7 @@ static png_voidp
|
|||
png_malloc_array_checked(png_const_structrp png_ptr, int nelements,
|
||||
size_t element_size)
|
||||
{
|
||||
png_alloc_size_t req = nelements; /* known to be > 0 */
|
||||
png_alloc_size_t req = (png_alloc_size_t)nelements; /* known to be > 0 */
|
||||
|
||||
if (req <= PNG_SIZE_MAX/element_size)
|
||||
return png_malloc_base(png_ptr, req * element_size);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* Last changed in libpng 1.6.23 [June 9, 2016]
|
||||
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 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.)
|
||||
|
@ -683,8 +683,13 @@ png_process_IDAT_data(png_structrp png_ptr, png_bytep buffer,
|
|||
png_ptr->pass > 6)
|
||||
png_warning(png_ptr, "Truncated compressed data in IDAT");
|
||||
|
||||
else
|
||||
{
|
||||
if (ret == Z_DATA_ERROR)
|
||||
png_benign_error(png_ptr, "IDAT: ADLER32 checksum mismatch");
|
||||
else
|
||||
png_error(png_ptr, "Decompression error in IDAT");
|
||||
}
|
||||
|
||||
/* Skip the check on unprocessed input */
|
||||
return;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngpriv.h - private declarations for use inside libpng
|
||||
*
|
||||
* Last changed in libpng 1.6.22 [May 26, 2016]
|
||||
* Last changed in libpng 1.6.26 [October 20, 2016]
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 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.)
|
||||
|
@ -182,6 +182,35 @@
|
|||
# endif
|
||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||
|
||||
#ifndef PNG_MIPS_MSA_OPT
|
||||
# if defined(__mips_msa) && (__mips_isa_rev >= 5) && defined(PNG_ALIGNED_MEMORY_SUPPORTED)
|
||||
# define PNG_MIPS_MSA_OPT 2
|
||||
# else
|
||||
# define PNG_MIPS_MSA_OPT 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if PNG_MIPS_MSA_OPT > 0
|
||||
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_msa
|
||||
# ifndef PNG_MIPS_MSA_IMPLEMENTATION
|
||||
# if defined(__mips_msa)
|
||||
# if defined(__clang__)
|
||||
# elif defined(__GNUC__)
|
||||
# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
|
||||
# define PNG_MIPS_MSA_IMPLEMENTATION 2
|
||||
# endif /* no GNUC support */
|
||||
# endif /* __GNUC__ */
|
||||
# else /* !defined __mips_msa */
|
||||
# define PNG_MIPS_MSA_IMPLEMENTATION 2
|
||||
# endif /* __mips_msa */
|
||||
# endif /* !PNG_MIPS_MSA_IMPLEMENTATION */
|
||||
|
||||
# ifndef PNG_MIPS_MSA_IMPLEMENTATION
|
||||
# define PNG_MIPS_MSA_IMPLEMENTATION 1
|
||||
# endif
|
||||
#endif /* PNG_MIPS_MSA_OPT > 0 */
|
||||
|
||||
|
||||
/* Is this a build of a DLL where compilation of the object modules requires
|
||||
* different preprocessor settings to those required for a simple library? If
|
||||
* so PNG_BUILD_DLL must be set.
|
||||
|
@ -504,7 +533,8 @@
|
|||
/* This implicitly assumes alignment is always to a power of 2. */
|
||||
#ifdef png_alignof
|
||||
# define png_isaligned(ptr, type)\
|
||||
((((const char*)ptr-(const char*)0) & (png_alignof(type)-1)) == 0)
|
||||
(((type)((const char*)ptr-(const char*)0) & \
|
||||
(type)(png_alignof(type)-1)) == 0)
|
||||
#else
|
||||
# define png_isaligned(ptr, type) 0
|
||||
#endif
|
||||
|
@ -521,92 +551,92 @@
|
|||
* are defined in png.h because they need to be visible to applications
|
||||
* that call png_set_unknown_chunk().
|
||||
*/
|
||||
/* #define PNG_HAVE_IHDR 0x01 (defined in png.h) */
|
||||
/* #define PNG_HAVE_PLTE 0x02 (defined in png.h) */
|
||||
#define PNG_HAVE_IDAT 0x04
|
||||
/* #define PNG_AFTER_IDAT 0x08 (defined in png.h) */
|
||||
#define PNG_HAVE_IEND 0x10
|
||||
/* 0x20 (unused) */
|
||||
/* 0x40 (unused) */
|
||||
/* 0x80 (unused) */
|
||||
#define PNG_HAVE_CHUNK_HEADER 0x100
|
||||
#define PNG_WROTE_tIME 0x200
|
||||
#define PNG_WROTE_INFO_BEFORE_PLTE 0x400
|
||||
#define PNG_BACKGROUND_IS_GRAY 0x800
|
||||
#define PNG_HAVE_PNG_SIGNATURE 0x1000
|
||||
#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000 /* Have another chunk after IDAT */
|
||||
/* 0x4000 (unused) */
|
||||
#define PNG_IS_READ_STRUCT 0x8000 /* Else is a write struct */
|
||||
/* #define PNG_HAVE_IHDR 0x01U (defined in png.h) */
|
||||
/* #define PNG_HAVE_PLTE 0x02U (defined in png.h) */
|
||||
#define PNG_HAVE_IDAT 0x04U
|
||||
/* #define PNG_AFTER_IDAT 0x08U (defined in png.h) */
|
||||
#define PNG_HAVE_IEND 0x10U
|
||||
/* 0x20U (unused) */
|
||||
/* 0x40U (unused) */
|
||||
/* 0x80U (unused) */
|
||||
#define PNG_HAVE_CHUNK_HEADER 0x100U
|
||||
#define PNG_WROTE_tIME 0x200U
|
||||
#define PNG_WROTE_INFO_BEFORE_PLTE 0x400U
|
||||
#define PNG_BACKGROUND_IS_GRAY 0x800U
|
||||
#define PNG_HAVE_PNG_SIGNATURE 0x1000U
|
||||
#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000U /* Have another chunk after IDAT */
|
||||
/* 0x4000U (unused) */
|
||||
#define PNG_IS_READ_STRUCT 0x8000U /* Else is a write struct */
|
||||
|
||||
/* Flags for the transformations the PNG library does on the image data */
|
||||
#define PNG_BGR 0x0001
|
||||
#define PNG_INTERLACE 0x0002
|
||||
#define PNG_PACK 0x0004
|
||||
#define PNG_SHIFT 0x0008
|
||||
#define PNG_SWAP_BYTES 0x0010
|
||||
#define PNG_INVERT_MONO 0x0020
|
||||
#define PNG_QUANTIZE 0x0040
|
||||
#define PNG_COMPOSE 0x0080 /* Was PNG_BACKGROUND */
|
||||
#define PNG_BACKGROUND_EXPAND 0x0100
|
||||
#define PNG_EXPAND_16 0x0200 /* Added to libpng 1.5.2 */
|
||||
#define PNG_16_TO_8 0x0400 /* Becomes 'chop' in 1.5.4 */
|
||||
#define PNG_RGBA 0x0800
|
||||
#define PNG_EXPAND 0x1000
|
||||
#define PNG_GAMMA 0x2000
|
||||
#define PNG_GRAY_TO_RGB 0x4000
|
||||
#define PNG_FILLER 0x8000
|
||||
#define PNG_PACKSWAP 0x10000
|
||||
#define PNG_SWAP_ALPHA 0x20000
|
||||
#define PNG_STRIP_ALPHA 0x40000
|
||||
#define PNG_INVERT_ALPHA 0x80000
|
||||
#define PNG_USER_TRANSFORM 0x100000
|
||||
#define PNG_RGB_TO_GRAY_ERR 0x200000
|
||||
#define PNG_RGB_TO_GRAY_WARN 0x400000
|
||||
#define PNG_RGB_TO_GRAY 0x600000 /* two bits, RGB_TO_GRAY_ERR|WARN */
|
||||
#define PNG_ENCODE_ALPHA 0x800000 /* Added to libpng-1.5.4 */
|
||||
#define PNG_ADD_ALPHA 0x1000000 /* Added to libpng-1.2.7 */
|
||||
#define PNG_EXPAND_tRNS 0x2000000 /* Added to libpng-1.2.9 */
|
||||
#define PNG_SCALE_16_TO_8 0x4000000 /* Added to libpng-1.5.4 */
|
||||
/* 0x8000000 unused */
|
||||
/* 0x10000000 unused */
|
||||
/* 0x20000000 unused */
|
||||
/* 0x40000000 unused */
|
||||
#define PNG_BGR 0x0001U
|
||||
#define PNG_INTERLACE 0x0002U
|
||||
#define PNG_PACK 0x0004U
|
||||
#define PNG_SHIFT 0x0008U
|
||||
#define PNG_SWAP_BYTES 0x0010U
|
||||
#define PNG_INVERT_MONO 0x0020U
|
||||
#define PNG_QUANTIZE 0x0040U
|
||||
#define PNG_COMPOSE 0x0080U /* Was PNG_BACKGROUND */
|
||||
#define PNG_BACKGROUND_EXPAND 0x0100U
|
||||
#define PNG_EXPAND_16 0x0200U /* Added to libpng 1.5.2 */
|
||||
#define PNG_16_TO_8 0x0400U /* Becomes 'chop' in 1.5.4 */
|
||||
#define PNG_RGBA 0x0800U
|
||||
#define PNG_EXPAND 0x1000U
|
||||
#define PNG_GAMMA 0x2000U
|
||||
#define PNG_GRAY_TO_RGB 0x4000U
|
||||
#define PNG_FILLER 0x8000U
|
||||
#define PNG_PACKSWAP 0x10000U
|
||||
#define PNG_SWAP_ALPHA 0x20000U
|
||||
#define PNG_STRIP_ALPHA 0x40000U
|
||||
#define PNG_INVERT_ALPHA 0x80000U
|
||||
#define PNG_USER_TRANSFORM 0x100000U
|
||||
#define PNG_RGB_TO_GRAY_ERR 0x200000U
|
||||
#define PNG_RGB_TO_GRAY_WARN 0x400000U
|
||||
#define PNG_RGB_TO_GRAY 0x600000U /* two bits, RGB_TO_GRAY_ERR|WARN */
|
||||
#define PNG_ENCODE_ALPHA 0x800000U /* Added to libpng-1.5.4 */
|
||||
#define PNG_ADD_ALPHA 0x1000000U /* Added to libpng-1.2.7 */
|
||||
#define PNG_EXPAND_tRNS 0x2000000U /* Added to libpng-1.2.9 */
|
||||
#define PNG_SCALE_16_TO_8 0x4000000U /* Added to libpng-1.5.4 */
|
||||
/* 0x8000000U unused */
|
||||
/* 0x10000000U unused */
|
||||
/* 0x20000000U unused */
|
||||
/* 0x40000000U unused */
|
||||
/* Flags for png_create_struct */
|
||||
#define PNG_STRUCT_PNG 0x0001
|
||||
#define PNG_STRUCT_INFO 0x0002
|
||||
#define PNG_STRUCT_PNG 0x0001U
|
||||
#define PNG_STRUCT_INFO 0x0002U
|
||||
|
||||
/* Flags for the png_ptr->flags rather than declaring a byte for each one */
|
||||
#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001
|
||||
#define PNG_FLAG_ZSTREAM_INITIALIZED 0x0002 /* Added to libpng-1.6.0 */
|
||||
/* 0x0004 unused */
|
||||
#define PNG_FLAG_ZSTREAM_ENDED 0x0008 /* Added to libpng-1.6.0 */
|
||||
/* 0x0010 unused */
|
||||
/* 0x0020 unused */
|
||||
#define PNG_FLAG_ROW_INIT 0x0040
|
||||
#define PNG_FLAG_FILLER_AFTER 0x0080
|
||||
#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100
|
||||
#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200
|
||||
#define PNG_FLAG_CRC_CRITICAL_USE 0x0400
|
||||
#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800
|
||||
#define PNG_FLAG_ASSUME_sRGB 0x1000 /* Added to libpng-1.5.4 */
|
||||
#define PNG_FLAG_OPTIMIZE_ALPHA 0x2000 /* Added to libpng-1.5.4 */
|
||||
#define PNG_FLAG_DETECT_UNINITIALIZED 0x4000 /* Added to libpng-1.5.4 */
|
||||
/* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000 */
|
||||
/* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000 */
|
||||
#define PNG_FLAG_LIBRARY_MISMATCH 0x20000
|
||||
#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000
|
||||
#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000
|
||||
#define PNG_FLAG_BENIGN_ERRORS_WARN 0x100000 /* Added to libpng-1.4.0 */
|
||||
#define PNG_FLAG_APP_WARNINGS_WARN 0x200000 /* Added to libpng-1.6.0 */
|
||||
#define PNG_FLAG_APP_ERRORS_WARN 0x400000 /* Added to libpng-1.6.0 */
|
||||
/* 0x800000 unused */
|
||||
/* 0x1000000 unused */
|
||||
/* 0x2000000 unused */
|
||||
/* 0x4000000 unused */
|
||||
/* 0x8000000 unused */
|
||||
/* 0x10000000 unused */
|
||||
/* 0x20000000 unused */
|
||||
/* 0x40000000 unused */
|
||||
#define PNG_FLAG_ZLIB_CUSTOM_STRATEGY 0x0001U
|
||||
#define PNG_FLAG_ZSTREAM_INITIALIZED 0x0002U /* Added to libpng-1.6.0 */
|
||||
/* 0x0004U unused */
|
||||
#define PNG_FLAG_ZSTREAM_ENDED 0x0008U /* Added to libpng-1.6.0 */
|
||||
/* 0x0010U unused */
|
||||
/* 0x0020U unused */
|
||||
#define PNG_FLAG_ROW_INIT 0x0040U
|
||||
#define PNG_FLAG_FILLER_AFTER 0x0080U
|
||||
#define PNG_FLAG_CRC_ANCILLARY_USE 0x0100U
|
||||
#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200U
|
||||
#define PNG_FLAG_CRC_CRITICAL_USE 0x0400U
|
||||
#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800U
|
||||
#define PNG_FLAG_ASSUME_sRGB 0x1000U /* Added to libpng-1.5.4 */
|
||||
#define PNG_FLAG_OPTIMIZE_ALPHA 0x2000U /* Added to libpng-1.5.4 */
|
||||
#define PNG_FLAG_DETECT_UNINITIALIZED 0x4000U /* Added to libpng-1.5.4 */
|
||||
/* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000U */
|
||||
/* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000U */
|
||||
#define PNG_FLAG_LIBRARY_MISMATCH 0x20000U
|
||||
#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000U
|
||||
#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000U
|
||||
#define PNG_FLAG_BENIGN_ERRORS_WARN 0x100000U /* Added to libpng-1.4.0 */
|
||||
#define PNG_FLAG_APP_WARNINGS_WARN 0x200000U /* Added to libpng-1.6.0 */
|
||||
#define PNG_FLAG_APP_ERRORS_WARN 0x400000U /* Added to libpng-1.6.0 */
|
||||
/* 0x800000U unused */
|
||||
/* 0x1000000U unused */
|
||||
/* 0x2000000U unused */
|
||||
/* 0x4000000U unused */
|
||||
/* 0x8000000U unused */
|
||||
/* 0x10000000U unused */
|
||||
/* 0x20000000U unused */
|
||||
/* 0x40000000U unused */
|
||||
|
||||
#define PNG_FLAG_CRC_ANCILLARY_MASK (PNG_FLAG_CRC_ANCILLARY_USE | \
|
||||
PNG_FLAG_CRC_ANCILLARY_NOWARN)
|
||||
|
@ -640,6 +670,24 @@
|
|||
((png_size_t)(width) * (((png_size_t)(pixel_bits)) >> 3)) : \
|
||||
(( ((png_size_t)(width) * ((png_size_t)(pixel_bits))) + 7) >> 3) )
|
||||
|
||||
/* This returns the number of trailing bits in the last byte of a row, 0 if the
|
||||
* last byte is completely full of pixels. It is, in principle, (pixel_bits x
|
||||
* width) % 8, but that would overflow for large 'width'. The second macro is
|
||||
* the same except that it returns the number of unused bits in the last byte;
|
||||
* (8-TRAILBITS), but 0 when TRAILBITS is 0.
|
||||
*
|
||||
* NOTE: these macros are intended to be self-evidently correct and never
|
||||
* overflow on the assumption that pixel_bits is in the range 0..255. The
|
||||
* arguments are evaluated only once and they can be signed (e.g. as a result of
|
||||
* the integral promotions). The result of the expression always has type
|
||||
* (png_uint_32), however the compiler always knows it is in the range 0..7.
|
||||
*/
|
||||
#define PNG_TRAILBITS(pixel_bits, width) \
|
||||
(((pixel_bits) * ((width) % (png_uint_32)8)) % 8)
|
||||
|
||||
#define PNG_PADBITS(pixel_bits, width) \
|
||||
((8 - PNG_TRAILBITS(pixel_bits, width)) % 8)
|
||||
|
||||
/* PNG_OUT_OF_RANGE returns true if value is outside the range
|
||||
* ideal-delta..ideal+delta. Each argument is evaluated twice.
|
||||
* "ideal" and "delta" should be constants, normally simple
|
||||
|
@ -1174,6 +1222,7 @@ PNG_INTERNAL_FUNCTION(void,png_do_write_interlace,(png_row_infop row_info,
|
|||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row,(png_structrp pp, png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row, int filter),PNG_EMPTY);
|
||||
|
||||
#if PNG_ARM_NEON_OPT > 0
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_neon,(png_row_infop row_info,
|
||||
png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_neon,(png_row_infop
|
||||
|
@ -1188,6 +1237,24 @@ PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_neon,(png_row_infop
|
|||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_neon,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#if PNG_MIPS_MSA_OPT > 0
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_msa,(png_row_infop row_info,
|
||||
png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_msa,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_msa,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_msa,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_msa,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_msa,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_msa,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
/* Choose the best filter to use and filter the row data */
|
||||
PNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr,
|
||||
|
@ -1215,7 +1282,7 @@ PNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr),
|
|||
/* Initialize the row buffers, etc. */
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY);
|
||||
|
||||
#if PNG_ZLIB_VERNUM >= 0x1240
|
||||
#if ZLIB_VERNUM >= 0x1240
|
||||
PNG_INTERNAL_FUNCTION(int,png_zlib_inflate,(png_structrp png_ptr, int flush),
|
||||
PNG_EMPTY);
|
||||
# define PNG_INFLATE(pp, flush) png_zlib_inflate(pp, flush)
|
||||
|
@ -1492,9 +1559,11 @@ PNG_INTERNAL_FUNCTION(int,png_colorspace_set_ICC,(png_const_structrp png_ptr,
|
|||
/* The 'name' is used for information only */
|
||||
|
||||
/* Routines for checking parts of an ICC profile. */
|
||||
#ifdef PNG_READ_iCCP_SUPPORTED
|
||||
PNG_INTERNAL_FUNCTION(int,png_icc_check_length,(png_const_structrp png_ptr,
|
||||
png_colorspacerp colorspace, png_const_charp name,
|
||||
png_uint_32 profile_length), PNG_EMPTY);
|
||||
#endif /* READ_iCCP */
|
||||
PNG_INTERNAL_FUNCTION(int,png_icc_check_header,(png_const_structrp png_ptr,
|
||||
png_colorspacerp colorspace, png_const_charp name,
|
||||
png_uint_32 profile_length,
|
||||
|
@ -1913,10 +1982,17 @@ PNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr,
|
|||
* the builder of libpng passes the definition of PNG_FILTER_OPTIMIZATIONS in
|
||||
* CFLAGS in place of CPPFLAGS *and* uses symbol prefixing.
|
||||
*/
|
||||
# if PNG_ARM_NEON_OPT > 0
|
||||
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon,
|
||||
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#if PNG_MIPS_MSA_OPT > 0
|
||||
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_msa,
|
||||
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr,
|
||||
png_const_charp key, png_bytep new_key), PNG_EMPTY);
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.23 [June 9, 2016]
|
||||
* Last changed in libpng 1.6.26 [October 20, 2016]
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 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.)
|
||||
|
@ -359,9 +359,9 @@ png_do_read_intrapixel(png_row_infop row_info, png_bytep row)
|
|||
|
||||
for (i = 0, rp = row; i < row_width; i++, rp += bytes_per_pixel)
|
||||
{
|
||||
png_uint_32 s0 = (*(rp ) << 8) | *(rp + 1);
|
||||
png_uint_32 s1 = (*(rp + 2) << 8) | *(rp + 3);
|
||||
png_uint_32 s2 = (*(rp + 4) << 8) | *(rp + 5);
|
||||
png_uint_32 s0 = (png_uint_32)(*(rp ) << 8) | *(rp + 1);
|
||||
png_uint_32 s1 = (png_uint_32)(*(rp + 2) << 8) | *(rp + 3);
|
||||
png_uint_32 s2 = (png_uint_32)(*(rp + 4) << 8) | *(rp + 5);
|
||||
png_uint_32 red = (s0 + s1 + 65536) & 0xffff;
|
||||
png_uint_32 blue = (s2 + s1 + 65536) & 0xffff;
|
||||
*(rp ) = (png_byte)((red >> 8) & 0xff);
|
||||
|
@ -1030,8 +1030,7 @@ png_set_read_status_fn(png_structrp png_ptr, png_read_status_ptr read_row_fn)
|
|||
#ifdef PNG_INFO_IMAGE_SUPPORTED
|
||||
void PNGAPI
|
||||
png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
||||
int transforms,
|
||||
voidp params)
|
||||
int transforms, voidp params)
|
||||
{
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
@ -1394,7 +1393,9 @@ png_image_read_header(png_voidp argument)
|
|||
png_structrp png_ptr = image->opaque->png_ptr;
|
||||
png_inforp info_ptr = image->opaque->info_ptr;
|
||||
|
||||
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
|
||||
png_set_benign_errors(png_ptr, 1/*warn*/);
|
||||
#endif
|
||||
png_read_info(png_ptr, info_ptr);
|
||||
|
||||
/* Do this the fast way; just read directly out of png_struct. */
|
||||
|
@ -1432,7 +1433,7 @@ png_image_read_header(png_voidp argument)
|
|||
break;
|
||||
|
||||
case PNG_COLOR_TYPE_PALETTE:
|
||||
cmap_entries = png_ptr->num_palette;
|
||||
cmap_entries = (png_uint_32)png_ptr->num_palette;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -1967,7 +1968,7 @@ make_gray_file_colormap(png_image_read_control *display)
|
|||
for (i=0; i<256; ++i)
|
||||
png_create_colormap_entry(display, i, i, i, i, 255, P_FILE);
|
||||
|
||||
return i;
|
||||
return (int)i;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1978,7 +1979,7 @@ make_gray_colormap(png_image_read_control *display)
|
|||
for (i=0; i<256; ++i)
|
||||
png_create_colormap_entry(display, i, i, i, i, 255, P_sRGB);
|
||||
|
||||
return i;
|
||||
return (int)i;
|
||||
}
|
||||
#define PNG_GRAY_COLORMAP_ENTRIES 256
|
||||
|
||||
|
@ -2032,7 +2033,7 @@ make_ga_colormap(png_image_read_control *display)
|
|||
P_sRGB);
|
||||
}
|
||||
|
||||
return i;
|
||||
return (int)i;
|
||||
}
|
||||
|
||||
#define PNG_GA_COLORMAP_ENTRIES 256
|
||||
|
@ -2057,7 +2058,7 @@ make_rgb_colormap(png_image_read_control *display)
|
|||
}
|
||||
}
|
||||
|
||||
return i;
|
||||
return (int)i;
|
||||
}
|
||||
|
||||
#define PNG_RGB_COLORMAP_ENTRIES 216
|
||||
|
@ -2105,7 +2106,7 @@ png_image_read_colormap(png_voidp argument)
|
|||
|
||||
else if (display->background == NULL /* no way to remove it */)
|
||||
png_error(png_ptr,
|
||||
"a background color must be supplied to remove alpha/transparency");
|
||||
"background color must be supplied to remove alpha/transparency");
|
||||
|
||||
/* Get a copy of the background color (this avoids repeating the checks
|
||||
* below.) The encoding is 8-bit sRGB or 16-bit linear, depending on the
|
||||
|
@ -2250,7 +2251,7 @@ png_image_read_colormap(png_voidp argument)
|
|||
if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries)
|
||||
png_error(png_ptr, "gray[16] color-map: too few entries");
|
||||
|
||||
cmap_entries = make_gray_colormap(display);
|
||||
cmap_entries = (unsigned int)make_gray_colormap(display);
|
||||
|
||||
if (png_ptr->num_trans > 0)
|
||||
{
|
||||
|
@ -2348,7 +2349,7 @@ png_image_read_colormap(png_voidp argument)
|
|||
if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries)
|
||||
png_error(png_ptr, "gray+alpha color-map: too few entries");
|
||||
|
||||
cmap_entries = make_ga_colormap(display);
|
||||
cmap_entries = (unsigned int)make_ga_colormap(display);
|
||||
|
||||
background_index = PNG_CMAP_GA_BACKGROUND;
|
||||
output_processing = PNG_CMAP_GA;
|
||||
|
@ -2382,7 +2383,7 @@ png_image_read_colormap(png_voidp argument)
|
|||
if (PNG_GRAY_COLORMAP_ENTRIES > image->colormap_entries)
|
||||
png_error(png_ptr, "gray-alpha color-map: too few entries");
|
||||
|
||||
cmap_entries = make_gray_colormap(display);
|
||||
cmap_entries = (unsigned int)make_gray_colormap(display);
|
||||
|
||||
if (output_encoding == P_LINEAR)
|
||||
{
|
||||
|
@ -2430,8 +2431,8 @@ png_image_read_colormap(png_voidp argument)
|
|||
background_index = i;
|
||||
png_create_colormap_entry(display, i++, back_r, back_g, back_b,
|
||||
#ifdef __COVERITY__
|
||||
/* Coverity claims that output_encoding cannot be 2 (P_LINEAR)
|
||||
* here.
|
||||
/* Coverity claims that output_encoding
|
||||
* cannot be 2 (P_LINEAR) here.
|
||||
*/ 255U,
|
||||
#else
|
||||
output_encoding == P_LINEAR ? 65535U : 255U,
|
||||
|
@ -2521,7 +2522,7 @@ png_image_read_colormap(png_voidp argument)
|
|||
if (PNG_GA_COLORMAP_ENTRIES > image->colormap_entries)
|
||||
png_error(png_ptr, "rgb[ga] color-map: too few entries");
|
||||
|
||||
cmap_entries = make_ga_colormap(display);
|
||||
cmap_entries = (unsigned int)make_ga_colormap(display);
|
||||
background_index = PNG_CMAP_GA_BACKGROUND;
|
||||
output_processing = PNG_CMAP_GA;
|
||||
}
|
||||
|
@ -2547,12 +2548,12 @@ png_image_read_colormap(png_voidp argument)
|
|||
png_ptr->num_trans > 0) &&
|
||||
png_gamma_not_sRGB(png_ptr->colorspace.gamma) != 0)
|
||||
{
|
||||
cmap_entries = make_gray_file_colormap(display);
|
||||
cmap_entries = (unsigned int)make_gray_file_colormap(display);
|
||||
data_encoding = P_FILE;
|
||||
}
|
||||
|
||||
else
|
||||
cmap_entries = make_gray_colormap(display);
|
||||
cmap_entries = (unsigned int)make_gray_colormap(display);
|
||||
|
||||
/* But if the input has alpha or transparency it must be removed
|
||||
*/
|
||||
|
@ -2640,7 +2641,7 @@ png_image_read_colormap(png_voidp argument)
|
|||
if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries)
|
||||
png_error(png_ptr, "rgb+alpha color-map: too few entries");
|
||||
|
||||
cmap_entries = make_rgb_colormap(display);
|
||||
cmap_entries = (unsigned int)make_rgb_colormap(display);
|
||||
|
||||
/* Add a transparent entry. */
|
||||
png_create_colormap_entry(display, cmap_entries, 255, 255,
|
||||
|
@ -2689,7 +2690,7 @@ png_image_read_colormap(png_voidp argument)
|
|||
if (PNG_RGB_COLORMAP_ENTRIES+1+27 > image->colormap_entries)
|
||||
png_error(png_ptr, "rgb-alpha color-map: too few entries");
|
||||
|
||||
cmap_entries = make_rgb_colormap(display);
|
||||
cmap_entries = (unsigned int)make_rgb_colormap(display);
|
||||
|
||||
png_create_colormap_entry(display, cmap_entries, back_r,
|
||||
back_g, back_b, 0/*unused*/, output_encoding);
|
||||
|
@ -2774,7 +2775,7 @@ png_image_read_colormap(png_voidp argument)
|
|||
if (PNG_RGB_COLORMAP_ENTRIES > image->colormap_entries)
|
||||
png_error(png_ptr, "rgb color-map: too few entries");
|
||||
|
||||
cmap_entries = make_rgb_colormap(display);
|
||||
cmap_entries = (unsigned int)make_rgb_colormap(display);
|
||||
output_processing = PNG_CMAP_RGB;
|
||||
}
|
||||
}
|
||||
|
@ -2798,11 +2799,11 @@ png_image_read_colormap(png_voidp argument)
|
|||
|
||||
output_processing = PNG_CMAP_NONE;
|
||||
data_encoding = P_FILE; /* Don't change from color-map indices */
|
||||
cmap_entries = png_ptr->num_palette;
|
||||
cmap_entries = (unsigned int)png_ptr->num_palette;
|
||||
if (cmap_entries > 256)
|
||||
cmap_entries = 256;
|
||||
|
||||
if (cmap_entries > image->colormap_entries)
|
||||
if (cmap_entries > (unsigned int)image->colormap_entries)
|
||||
png_error(png_ptr, "palette color-map: too few entries");
|
||||
|
||||
for (i=0; i < cmap_entries; ++i)
|
||||
|
@ -2819,12 +2820,12 @@ png_image_read_colormap(png_voidp argument)
|
|||
* on the sRGB color in 'back'.
|
||||
*/
|
||||
png_create_colormap_entry(display, i,
|
||||
png_colormap_compose(display, colormap[i].red, P_FILE,
|
||||
trans[i], back_r, output_encoding),
|
||||
png_colormap_compose(display, colormap[i].green, P_FILE,
|
||||
trans[i], back_g, output_encoding),
|
||||
png_colormap_compose(display, colormap[i].blue, P_FILE,
|
||||
trans[i], back_b, output_encoding),
|
||||
png_colormap_compose(display, colormap[i].red,
|
||||
P_FILE, trans[i], back_r, output_encoding),
|
||||
png_colormap_compose(display, colormap[i].green,
|
||||
P_FILE, trans[i], back_g, output_encoding),
|
||||
png_colormap_compose(display, colormap[i].blue,
|
||||
P_FILE, trans[i], back_b, output_encoding),
|
||||
output_encoding == P_LINEAR ? trans[i] * 257U :
|
||||
trans[i],
|
||||
output_encoding);
|
||||
|
@ -2914,7 +2915,7 @@ png_image_read_colormap(png_voidp argument)
|
|||
png_error(png_ptr, "bad background index (internal error)");
|
||||
}
|
||||
|
||||
display->colormap_processing = output_processing;
|
||||
display->colormap_processing = (int)output_processing;
|
||||
|
||||
return 1/*ok*/;
|
||||
}
|
||||
|
@ -3223,14 +3224,14 @@ png_image_read_colormapped(png_voidp argument)
|
|||
|
||||
else
|
||||
{
|
||||
png_alloc_size_t row_bytes = display->row_bytes;
|
||||
png_alloc_size_t row_bytes = (png_alloc_size_t)display->row_bytes;
|
||||
|
||||
while (--passes >= 0)
|
||||
{
|
||||
png_uint_32 y = image->height;
|
||||
png_bytep row = png_voidcast(png_bytep, display->first_row);
|
||||
|
||||
while (y-- > 0)
|
||||
for (; y > 0; --y)
|
||||
{
|
||||
png_read_row(png_ptr, row, NULL);
|
||||
row += row_bytes;
|
||||
|
@ -3433,8 +3434,7 @@ png_image_read_background(png_voidp argument)
|
|||
|
||||
for (pass = 0; pass < passes; ++pass)
|
||||
{
|
||||
png_bytep row = png_voidcast(png_bytep,
|
||||
display->first_row);
|
||||
png_bytep row = png_voidcast(png_bytep, display->first_row);
|
||||
unsigned int startx, stepx, stepy;
|
||||
png_uint_32 y;
|
||||
|
||||
|
@ -3559,8 +3559,9 @@ png_image_read_background(png_voidp argument)
|
|||
* stride which was multiplied by 2 (below) to get row_bytes.
|
||||
*/
|
||||
ptrdiff_t step_row = display->row_bytes / 2;
|
||||
int preserve_alpha = (image->format & PNG_FORMAT_FLAG_ALPHA) != 0;
|
||||
unsigned int outchannels = 1+preserve_alpha;
|
||||
unsigned int preserve_alpha = (image->format &
|
||||
PNG_FORMAT_FLAG_ALPHA) != 0;
|
||||
unsigned int outchannels = 1U+preserve_alpha;
|
||||
int swap_alpha = 0;
|
||||
|
||||
# ifdef PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED
|
||||
|
@ -4057,14 +4058,14 @@ png_image_read_direct(png_voidp argument)
|
|||
|
||||
else
|
||||
{
|
||||
png_alloc_size_t row_bytes = display->row_bytes;
|
||||
png_alloc_size_t row_bytes = (png_alloc_size_t)display->row_bytes;
|
||||
|
||||
while (--passes >= 0)
|
||||
{
|
||||
png_uint_32 y = image->height;
|
||||
png_bytep row = png_voidcast(png_bytep, display->first_row);
|
||||
|
||||
while (y-- > 0)
|
||||
for (; y > 0; --y)
|
||||
{
|
||||
png_read_row(png_ptr, row, NULL);
|
||||
row += row_bytes;
|
||||
|
@ -4087,7 +4088,13 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
|
|||
*/
|
||||
const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
|
||||
|
||||
if (image->width <= 0x7FFFFFFFU/channels) /* no overflow */
|
||||
/* The following checks just the 'row_stride' calculation to ensure it
|
||||
* fits in a signed 32-bit value. Because channels/components can be
|
||||
* either 1 or 2 bytes in size the length of a row can still overflow 32
|
||||
* bits; this is just to verify that the 'row_stride' argument can be
|
||||
* represented.
|
||||
*/
|
||||
if (image->width <= 0x7fffffffU/channels) /* no overflow */
|
||||
{
|
||||
png_uint_32 check;
|
||||
const png_uint_32 png_row_stride = image->width * channels;
|
||||
|
@ -4096,18 +4103,35 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
|
|||
row_stride = (png_int_32)/*SAFE*/png_row_stride;
|
||||
|
||||
if (row_stride < 0)
|
||||
check = -row_stride;
|
||||
check = (png_uint_32)(-row_stride);
|
||||
|
||||
else
|
||||
check = row_stride;
|
||||
check = (png_uint_32)row_stride;
|
||||
|
||||
/* This verifies 'check', the absolute value of the actual stride
|
||||
* passed in and detects overflow in the application calculation (i.e.
|
||||
* if the app did actually pass in a non-zero 'row_stride'.
|
||||
*/
|
||||
if (image->opaque != NULL && buffer != NULL && check >= png_row_stride)
|
||||
{
|
||||
/* Now check for overflow of the image buffer calculation; this
|
||||
* limits the whole image size to 32 bits for API compatibility with
|
||||
* the current, 32-bit, PNG_IMAGE_BUFFER_SIZE macro.
|
||||
*
|
||||
* The PNG_IMAGE_BUFFER_SIZE macro is:
|
||||
*
|
||||
* (PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)*height*(row_stride))
|
||||
*
|
||||
* And the component size is always 1 or 2, so make sure that the
|
||||
* number of *bytes* that the application is saying are available
|
||||
* does actually fit into a 32-bit number.
|
||||
*
|
||||
* NOTE: this will be changed in 1.7 because PNG_IMAGE_BUFFER_SIZE
|
||||
* will be changed to use png_alloc_size_t; bigger images can be
|
||||
* accomodated on 64-bit systems.
|
||||
*/
|
||||
if (image->height <= 0xFFFFFFFF/png_row_stride)
|
||||
if (image->height <=
|
||||
0xffffffffU/PNG_IMAGE_PIXEL_COMPONENT_SIZE(image->format)/check)
|
||||
{
|
||||
if ((image->format & PNG_FORMAT_FLAG_COLORMAP) == 0 ||
|
||||
(image->colormap_entries > 0 && colormap != NULL))
|
||||
|
@ -4127,7 +4151,8 @@ png_image_finish_read(png_imagep image, png_const_colorp background,
|
|||
* all the setup has already been done.
|
||||
*/
|
||||
if ((image->format & PNG_FORMAT_FLAG_COLORMAP) != 0)
|
||||
result = png_safe_execute(image,
|
||||
result =
|
||||
png_safe_execute(image,
|
||||
png_image_read_colormap, &display) &&
|
||||
png_safe_execute(image,
|
||||
png_image_read_colormapped, &display);
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngrio.c - functions for data input
|
||||
*
|
||||
* Last changed in libpng 1.6.17 [March 26, 2015]
|
||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 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.)
|
||||
*
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* Last changed in libpng 1.6.22 [May 26, 2016]
|
||||
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 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.)
|
||||
|
@ -429,7 +429,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
|||
int i;
|
||||
|
||||
png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)(num_palette * (sizeof (png_byte))));
|
||||
(png_uint_32)((png_uint_32)num_palette * (sizeof (png_byte))));
|
||||
for (i = 0; i < num_palette; i++)
|
||||
png_ptr->quantize_index[i] = (png_byte)i;
|
||||
}
|
||||
|
@ -446,7 +446,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
|||
|
||||
/* Initialize an array to sort colors */
|
||||
png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)(num_palette * (sizeof (png_byte))));
|
||||
(png_uint_32)((png_uint_32)num_palette * (sizeof (png_byte))));
|
||||
|
||||
/* Initialize the quantize_sort array */
|
||||
for (i = 0; i < num_palette; i++)
|
||||
|
@ -580,9 +580,9 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
|||
|
||||
/* Initialize palette index arrays */
|
||||
png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)(num_palette * (sizeof (png_byte))));
|
||||
(png_uint_32)((png_uint_32)num_palette * (sizeof (png_byte))));
|
||||
png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
|
||||
(png_uint_32)(num_palette * (sizeof (png_byte))));
|
||||
(png_uint_32)((png_uint_32)num_palette * (sizeof (png_byte))));
|
||||
|
||||
/* Initialize the sort array */
|
||||
for (i = 0; i < num_palette; i++)
|
||||
|
@ -2150,7 +2150,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
|||
{
|
||||
png_bytep sp = row + (png_size_t)((row_width - 1) >> 3);
|
||||
png_bytep dp = row + (png_size_t)row_width - 1;
|
||||
png_uint_32 shift = 7 - (int)((row_width + 7) & 0x07);
|
||||
png_uint_32 shift = 7U - ((row_width + 7U) & 0x07);
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*dp = (png_byte)((*sp >> shift) & 0x01);
|
||||
|
@ -2174,7 +2174,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
|||
|
||||
png_bytep sp = row + (png_size_t)((row_width - 1) >> 2);
|
||||
png_bytep dp = row + (png_size_t)row_width - 1;
|
||||
png_uint_32 shift = (int)((3 - ((row_width + 3) & 0x03)) << 1);
|
||||
png_uint_32 shift = ((3U - ((row_width + 3U) & 0x03)) << 1);
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*dp = (png_byte)((*sp >> shift) & 0x03);
|
||||
|
@ -2197,7 +2197,7 @@ png_do_unpack(png_row_infop row_info, png_bytep row)
|
|||
{
|
||||
png_bytep sp = row + (png_size_t)((row_width - 1) >> 1);
|
||||
png_bytep dp = row + (png_size_t)row_width - 1;
|
||||
png_uint_32 shift = (int)((1 - ((row_width + 1) & 0x01)) << 2);
|
||||
png_uint_32 shift = ((1U - ((row_width + 1U) & 0x01)) << 2);
|
||||
for (i = 0; i < row_width; i++)
|
||||
{
|
||||
*dp = (png_byte)((*sp >> shift) & 0x0f);
|
||||
|
@ -3223,7 +3223,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
|||
== png_ptr->trans_color.gray)
|
||||
{
|
||||
unsigned int tmp = *sp & (0x7f7f >> (7 - shift));
|
||||
tmp |= png_ptr->background.gray << shift;
|
||||
tmp |=
|
||||
(unsigned int)(png_ptr->background.gray << shift);
|
||||
*sp = (png_byte)(tmp & 0xff);
|
||||
}
|
||||
|
||||
|
@ -3252,7 +3253,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
|||
== png_ptr->trans_color.gray)
|
||||
{
|
||||
unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
|
||||
tmp |= png_ptr->background.gray << shift;
|
||||
tmp |=
|
||||
(unsigned int)png_ptr->background.gray << shift;
|
||||
*sp = (png_byte)(tmp & 0xff);
|
||||
}
|
||||
|
||||
|
@ -3262,7 +3264,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
|||
unsigned int g = (gamma_table [p | (p << 2) |
|
||||
(p << 4) | (p << 6)] >> 6) & 0x03;
|
||||
unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
|
||||
tmp |= g << shift;
|
||||
tmp |= (unsigned int)(g << shift);
|
||||
*sp = (png_byte)(tmp & 0xff);
|
||||
}
|
||||
|
||||
|
@ -3288,7 +3290,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
|||
== png_ptr->trans_color.gray)
|
||||
{
|
||||
unsigned int tmp = *sp & (0x3f3f >> (6 - shift));
|
||||
tmp |= png_ptr->background.gray << shift;
|
||||
tmp |=
|
||||
(unsigned int)png_ptr->background.gray << shift;
|
||||
*sp = (png_byte)(tmp & 0xff);
|
||||
}
|
||||
|
||||
|
@ -3318,7 +3321,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
|||
== png_ptr->trans_color.gray)
|
||||
{
|
||||
unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
|
||||
tmp |= png_ptr->background.gray << shift;
|
||||
tmp |=
|
||||
(unsigned int)(png_ptr->background.gray << shift);
|
||||
*sp = (png_byte)(tmp & 0xff);
|
||||
}
|
||||
|
||||
|
@ -3328,7 +3332,7 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
|||
unsigned int g = (gamma_table[p | (p << 4)] >> 4) &
|
||||
0x0f;
|
||||
unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
|
||||
tmp |= g << shift;
|
||||
tmp |= (unsigned int)(g << shift);
|
||||
*sp = (png_byte)(tmp & 0xff);
|
||||
}
|
||||
|
||||
|
@ -3354,7 +3358,8 @@ png_do_compose(png_row_infop row_info, png_bytep row, png_structrp png_ptr)
|
|||
== png_ptr->trans_color.gray)
|
||||
{
|
||||
unsigned int tmp = *sp & (0x0f0f >> (4 - shift));
|
||||
tmp |= png_ptr->background.gray << shift;
|
||||
tmp |=
|
||||
(unsigned int)(png_ptr->background.gray << shift);
|
||||
*sp = (png_byte)(tmp & 0xff);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngrutil.c - utilities to read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.20 [December 3, 2014]
|
||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.27 [January 5, 2017]
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 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.)
|
||||
*
|
||||
|
@ -86,7 +86,7 @@ png_get_int_32)(png_const_bytep buf)
|
|||
{
|
||||
png_uint_32 uval = png_get_uint_32(buf);
|
||||
if ((uval & 0x80000000) == 0) /* non-negative */
|
||||
return uval;
|
||||
return (png_int_32)uval;
|
||||
|
||||
uval = (uval ^ 0xffffffff) + 1; /* 2's complement: -x = ~x+1 */
|
||||
if ((uval & 0x80000000) == 0) /* no overflow */
|
||||
|
@ -370,11 +370,10 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
|
|||
*/
|
||||
{
|
||||
int ret; /* zlib return code */
|
||||
#if PNG_ZLIB_VERNUM >= 0x1240
|
||||
#if ZLIB_VERNUM >= 0x1240
|
||||
int window_bits = 0;
|
||||
|
||||
# if defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_MAXIMUM_INFLATE_WINDOW)
|
||||
int window_bits;
|
||||
|
||||
if (((png_ptr->options >> PNG_MAXIMUM_INFLATE_WINDOW) & 3) ==
|
||||
PNG_OPTION_ON)
|
||||
{
|
||||
|
@ -384,14 +383,12 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
|
|||
|
||||
else
|
||||
{
|
||||
window_bits = 0;
|
||||
png_ptr->zstream_start = 1;
|
||||
}
|
||||
# else
|
||||
# define window_bits 0
|
||||
# endif
|
||||
# endif
|
||||
|
||||
#endif /* ZLIB_VERNUM >= 0x1240 */
|
||||
|
||||
/* Set this for safety, just in case the previous owner left pointers to
|
||||
* memory allocations.
|
||||
*/
|
||||
|
@ -402,25 +399,32 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
|
|||
|
||||
if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0)
|
||||
{
|
||||
#if PNG_ZLIB_VERNUM < 0x1240
|
||||
ret = inflateReset(&png_ptr->zstream);
|
||||
#else
|
||||
#if ZLIB_VERNUM >= 0x1240
|
||||
ret = inflateReset2(&png_ptr->zstream, window_bits);
|
||||
#else
|
||||
ret = inflateReset(&png_ptr->zstream);
|
||||
#endif
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
#if PNG_ZLIB_VERNUM < 0x1240
|
||||
ret = inflateInit(&png_ptr->zstream);
|
||||
#else
|
||||
#if ZLIB_VERNUM >= 0x1240
|
||||
ret = inflateInit2(&png_ptr->zstream, window_bits);
|
||||
#else
|
||||
ret = inflateInit(&png_ptr->zstream);
|
||||
#endif
|
||||
|
||||
if (ret == Z_OK)
|
||||
png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED;
|
||||
}
|
||||
|
||||
#if ZLIB_VERNUM >= 0x1281 && \
|
||||
defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_IGNORE_ADLER32)
|
||||
if (((png_ptr->options >> PNG_IGNORE_ADLER32) & 3) == PNG_OPTION_ON)
|
||||
/* Turn off validation of the ADLER32 checksum in IDAT chunks */
|
||||
ret = inflateValidate(&png_ptr->zstream, 0);
|
||||
#endif
|
||||
|
||||
if (ret == Z_OK)
|
||||
png_ptr->zowner = owner;
|
||||
|
||||
|
@ -435,7 +439,7 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
|
|||
#endif
|
||||
}
|
||||
|
||||
#if PNG_ZLIB_VERNUM >= 0x1240
|
||||
#if ZLIB_VERNUM >= 0x1240
|
||||
/* Handle the start of the inflate stream if we called inflateInit2(strm,0);
|
||||
* in this case some zlib versions skip validation of the CINFO field and, in
|
||||
* certain circumstances, libpng may end up displaying an invalid image, in
|
||||
|
@ -461,6 +465,7 @@ png_zlib_inflate(png_structrp png_ptr, int flush)
|
|||
#endif /* Zlib >= 1.2.4 */
|
||||
|
||||
#ifdef PNG_READ_COMPRESSED_TEXT_SUPPORTED
|
||||
#if defined(PNG_READ_zTXt_SUPPORTED) || defined (PNG_READ_iTXt_SUPPORTED)
|
||||
/* png_inflate now returns zlib error codes including Z_OK and Z_STREAM_END to
|
||||
* allow the caller to do multiple calls if required. If the 'finish' flag is
|
||||
* set Z_FINISH will be passed to the final inflate() call and Z_STREAM_END must
|
||||
|
@ -754,6 +759,7 @@ png_decompress_chunk(png_structrp png_ptr,
|
|||
return Z_MEM_ERROR;
|
||||
}
|
||||
}
|
||||
#endif /* READ_zTXt || READ_iTXt */
|
||||
#endif /* READ_COMPRESSED_TEXT */
|
||||
|
||||
#ifdef PNG_READ_iCCP_SUPPORTED
|
||||
|
@ -802,8 +808,8 @@ png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size,
|
|||
* the available output is produced; this allows reading of truncated
|
||||
* streams.
|
||||
*/
|
||||
ret = PNG_INFLATE(png_ptr,
|
||||
*chunk_bytes > 0 ? Z_NO_FLUSH : (finish ? Z_FINISH : Z_SYNC_FLUSH));
|
||||
ret = PNG_INFLATE(png_ptr, *chunk_bytes > 0 ?
|
||||
Z_NO_FLUSH : (finish ? Z_FINISH : Z_SYNC_FLUSH));
|
||||
}
|
||||
while (ret == Z_OK && (*out_size > 0 || png_ptr->zstream.avail_out > 0));
|
||||
|
||||
|
@ -821,7 +827,7 @@ png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size,
|
|||
return Z_STREAM_ERROR;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif /* READ_iCCP */
|
||||
|
||||
/* Read and check the IDHR chunk */
|
||||
|
||||
|
@ -1009,7 +1015,7 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
#endif
|
||||
{
|
||||
png_crc_finish(png_ptr, (int) length - num * 3);
|
||||
png_crc_finish(png_ptr, (png_uint_32) (length - (unsigned int)num * 3));
|
||||
}
|
||||
|
||||
#ifndef PNG_READ_OPT_PLTE_SUPPORTED
|
||||
|
@ -1512,7 +1518,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||
png_crc_finish(png_ptr, length);
|
||||
finished = 1;
|
||||
|
||||
# ifdef PNG_sRGB_SUPPORTED
|
||||
# if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0
|
||||
/* Check for a match against sRGB */
|
||||
png_icc_set_sRGB(png_ptr,
|
||||
&png_ptr->colorspace, profile,
|
||||
|
@ -1715,13 +1721,13 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||
data_length = length - (png_uint_32)(entry_start - buffer);
|
||||
|
||||
/* Integrity-check the data length */
|
||||
if ((data_length % entry_size) != 0)
|
||||
if ((data_length % (unsigned int)entry_size) != 0)
|
||||
{
|
||||
png_warning(png_ptr, "sPLT chunk has bad length");
|
||||
return;
|
||||
}
|
||||
|
||||
dl = (png_int_32)(data_length / entry_size);
|
||||
dl = (png_uint_32)(data_length / (unsigned int)entry_size);
|
||||
max_dl = PNG_SIZE_MAX / (sizeof (png_sPLT_entry));
|
||||
|
||||
if (dl > max_dl)
|
||||
|
@ -1730,10 +1736,10 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
|||
return;
|
||||
}
|
||||
|
||||
new_palette.nentries = (png_int_32)(data_length / entry_size);
|
||||
new_palette.nentries = (png_int_32)(data_length / (unsigned int)entry_size);
|
||||
|
||||
new_palette.entries = (png_sPLT_entryp)png_malloc_warn(
|
||||
png_ptr, new_palette.nentries * (sizeof (png_sPLT_entry)));
|
||||
new_palette.entries = (png_sPLT_entryp)png_malloc_warn(png_ptr,
|
||||
(png_alloc_size_t) new_palette.nentries * (sizeof (png_sPLT_entry)));
|
||||
|
||||
if (new_palette.entries == NULL)
|
||||
{
|
||||
|
@ -3097,7 +3103,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
|||
# ifdef PNG_READ_PACKSWAP_SUPPORTED
|
||||
if ((png_ptr->transformations & PNG_PACKSWAP) != 0)
|
||||
/* little-endian byte */
|
||||
end_mask = 0xff << end_mask;
|
||||
end_mask = (unsigned int)(0xff << end_mask);
|
||||
|
||||
else /* big-endian byte */
|
||||
# endif
|
||||
|
@ -3418,8 +3424,8 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
|||
/* Everything is aligned for png_uint_16 copies, but try for
|
||||
* png_uint_32 first.
|
||||
*/
|
||||
if (png_isaligned(dp, png_uint_32) != 0 &&
|
||||
png_isaligned(sp, png_uint_32) != 0 &&
|
||||
if (png_isaligned(dp, png_uint_32) &&
|
||||
png_isaligned(sp, png_uint_32) &&
|
||||
bytes_to_copy % (sizeof (png_uint_32)) == 0 &&
|
||||
bytes_to_jump % (sizeof (png_uint_32)) == 0)
|
||||
{
|
||||
|
@ -3543,7 +3549,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||
{
|
||||
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||
/* Offset to next interlace block */
|
||||
static PNG_CONST int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||
static PNG_CONST unsigned int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||
|
||||
png_debug(1, "in png_do_read_interlace");
|
||||
if (row != NULL && row_info != NULL)
|
||||
|
@ -3558,9 +3564,10 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||
{
|
||||
png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3);
|
||||
png_bytep dp = row + (png_size_t)((final_width - 1) >> 3);
|
||||
int sshift, dshift;
|
||||
int s_start, s_end, s_inc;
|
||||
int jstop = png_pass_inc[pass];
|
||||
unsigned int sshift, dshift;
|
||||
unsigned int s_start, s_end;
|
||||
int s_inc;
|
||||
int jstop = (int)png_pass_inc[pass];
|
||||
png_byte v;
|
||||
png_uint_32 i;
|
||||
int j;
|
||||
|
@ -3568,8 +3575,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||
#ifdef PNG_READ_PACKSWAP_SUPPORTED
|
||||
if ((transformations & PNG_PACKSWAP) != 0)
|
||||
{
|
||||
sshift = (int)((row_info->width + 7) & 0x07);
|
||||
dshift = (int)((final_width + 7) & 0x07);
|
||||
sshift = ((row_info->width + 7) & 0x07);
|
||||
dshift = ((final_width + 7) & 0x07);
|
||||
s_start = 7;
|
||||
s_end = 0;
|
||||
s_inc = -1;
|
||||
|
@ -3578,8 +3585,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||
else
|
||||
#endif
|
||||
{
|
||||
sshift = 7 - (int)((row_info->width + 7) & 0x07);
|
||||
dshift = 7 - (int)((final_width + 7) & 0x07);
|
||||
sshift = 7 - ((row_info->width + 7) & 0x07);
|
||||
dshift = 7 - ((final_width + 7) & 0x07);
|
||||
s_start = 0;
|
||||
s_end = 7;
|
||||
s_inc = 1;
|
||||
|
@ -3591,7 +3598,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||
for (j = 0; j < jstop; j++)
|
||||
{
|
||||
unsigned int tmp = *dp & (0x7f7f >> (7 - dshift));
|
||||
tmp |= v << dshift;
|
||||
tmp |= (unsigned int)(v << dshift);
|
||||
*dp = (png_byte)(tmp & 0xff);
|
||||
|
||||
if (dshift == s_end)
|
||||
|
@ -3601,7 +3608,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||
}
|
||||
|
||||
else
|
||||
dshift += s_inc;
|
||||
dshift = (unsigned int)((int)dshift + s_inc);
|
||||
}
|
||||
|
||||
if (sshift == s_end)
|
||||
|
@ -3611,7 +3618,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||
}
|
||||
|
||||
else
|
||||
sshift += s_inc;
|
||||
sshift = (unsigned int)((int)sshift + s_inc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -3620,16 +3627,17 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||
{
|
||||
png_bytep sp = row + (png_uint_32)((row_info->width - 1) >> 2);
|
||||
png_bytep dp = row + (png_uint_32)((final_width - 1) >> 2);
|
||||
int sshift, dshift;
|
||||
int s_start, s_end, s_inc;
|
||||
int jstop = png_pass_inc[pass];
|
||||
unsigned int sshift, dshift;
|
||||
unsigned int s_start, s_end;
|
||||
int s_inc;
|
||||
int jstop = (int)png_pass_inc[pass];
|
||||
png_uint_32 i;
|
||||
|
||||
#ifdef PNG_READ_PACKSWAP_SUPPORTED
|
||||
if ((transformations & PNG_PACKSWAP) != 0)
|
||||
{
|
||||
sshift = (int)(((row_info->width + 3) & 0x03) << 1);
|
||||
dshift = (int)(((final_width + 3) & 0x03) << 1);
|
||||
sshift = (((row_info->width + 3) & 0x03) << 1);
|
||||
dshift = (((final_width + 3) & 0x03) << 1);
|
||||
s_start = 6;
|
||||
s_end = 0;
|
||||
s_inc = -2;
|
||||
|
@ -3638,8 +3646,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||
else
|
||||
#endif
|
||||
{
|
||||
sshift = (int)((3 - ((row_info->width + 3) & 0x03)) << 1);
|
||||
dshift = (int)((3 - ((final_width + 3) & 0x03)) << 1);
|
||||
sshift = ((3 - ((row_info->width + 3) & 0x03)) << 1);
|
||||
dshift = ((3 - ((final_width + 3) & 0x03)) << 1);
|
||||
s_start = 0;
|
||||
s_end = 6;
|
||||
s_inc = 2;
|
||||
|
@ -3654,7 +3662,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||
for (j = 0; j < jstop; j++)
|
||||
{
|
||||
unsigned int tmp = *dp & (0x3f3f >> (6 - dshift));
|
||||
tmp |= v << dshift;
|
||||
tmp |= (unsigned int)(v << dshift);
|
||||
*dp = (png_byte)(tmp & 0xff);
|
||||
|
||||
if (dshift == s_end)
|
||||
|
@ -3664,7 +3672,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||
}
|
||||
|
||||
else
|
||||
dshift += s_inc;
|
||||
dshift = (unsigned int)((int)dshift + s_inc);
|
||||
}
|
||||
|
||||
if (sshift == s_end)
|
||||
|
@ -3674,7 +3682,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||
}
|
||||
|
||||
else
|
||||
sshift += s_inc;
|
||||
sshift = (unsigned int)((int)sshift + s_inc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -3683,16 +3691,17 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||
{
|
||||
png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1);
|
||||
png_bytep dp = row + (png_size_t)((final_width - 1) >> 1);
|
||||
int sshift, dshift;
|
||||
int s_start, s_end, s_inc;
|
||||
unsigned int sshift, dshift;
|
||||
unsigned int s_start, s_end;
|
||||
int s_inc;
|
||||
png_uint_32 i;
|
||||
int jstop = png_pass_inc[pass];
|
||||
int jstop = (int)png_pass_inc[pass];
|
||||
|
||||
#ifdef PNG_READ_PACKSWAP_SUPPORTED
|
||||
if ((transformations & PNG_PACKSWAP) != 0)
|
||||
{
|
||||
sshift = (int)(((row_info->width + 1) & 0x01) << 2);
|
||||
dshift = (int)(((final_width + 1) & 0x01) << 2);
|
||||
sshift = (((row_info->width + 1) & 0x01) << 2);
|
||||
dshift = (((final_width + 1) & 0x01) << 2);
|
||||
s_start = 4;
|
||||
s_end = 0;
|
||||
s_inc = -4;
|
||||
|
@ -3701,8 +3710,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||
else
|
||||
#endif
|
||||
{
|
||||
sshift = (int)((1 - ((row_info->width + 1) & 0x01)) << 2);
|
||||
dshift = (int)((1 - ((final_width + 1) & 0x01)) << 2);
|
||||
sshift = ((1 - ((row_info->width + 1) & 0x01)) << 2);
|
||||
dshift = ((1 - ((final_width + 1) & 0x01)) << 2);
|
||||
s_start = 0;
|
||||
s_end = 4;
|
||||
s_inc = 4;
|
||||
|
@ -3716,7 +3725,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||
for (j = 0; j < jstop; j++)
|
||||
{
|
||||
unsigned int tmp = *dp & (0xf0f >> (4 - dshift));
|
||||
tmp |= v << dshift;
|
||||
tmp |= (unsigned int)(v << dshift);
|
||||
*dp = (png_byte)(tmp & 0xff);
|
||||
|
||||
if (dshift == s_end)
|
||||
|
@ -3726,7 +3735,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||
}
|
||||
|
||||
else
|
||||
dshift += s_inc;
|
||||
dshift = (unsigned int)((int)dshift + s_inc);
|
||||
}
|
||||
|
||||
if (sshift == s_end)
|
||||
|
@ -3736,7 +3745,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||
}
|
||||
|
||||
else
|
||||
sshift += s_inc;
|
||||
sshift = (unsigned int)((int)sshift + s_inc);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -3750,7 +3759,7 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
|||
|
||||
png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes;
|
||||
|
||||
int jstop = png_pass_inc[pass];
|
||||
int jstop = (int)png_pass_inc[pass];
|
||||
png_uint_32 i;
|
||||
|
||||
for (i = 0; i < row_info->width; i++)
|
||||
|
@ -3894,7 +3903,7 @@ static void
|
|||
png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
int bpp = (row_info->pixel_depth + 7) >> 3;
|
||||
unsigned int bpp = (row_info->pixel_depth + 7) >> 3;
|
||||
png_bytep rp_end = row + bpp;
|
||||
|
||||
/* Process the first pixel in the row completely (this is the same as 'up'
|
||||
|
@ -3907,7 +3916,7 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
|
|||
}
|
||||
|
||||
/* Remainder */
|
||||
rp_end += row_info->rowbytes - bpp;
|
||||
rp_end = rp_end + (row_info->rowbytes - bpp);
|
||||
|
||||
while (row < rp_end)
|
||||
{
|
||||
|
@ -4252,7 +4261,7 @@ png_read_start_row(png_structrp png_ptr)
|
|||
/* Offset to next interlace block in the y direction */
|
||||
static PNG_CONST png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
||||
|
||||
int max_pixel_depth;
|
||||
unsigned int max_pixel_depth;
|
||||
png_size_t row_bytes;
|
||||
|
||||
png_debug(1, "in png_read_start_row");
|
||||
|
@ -4281,7 +4290,7 @@ png_read_start_row(png_structrp png_ptr)
|
|||
png_ptr->iwidth = png_ptr->width;
|
||||
}
|
||||
|
||||
max_pixel_depth = png_ptr->pixel_depth;
|
||||
max_pixel_depth = (unsigned int)png_ptr->pixel_depth;
|
||||
|
||||
/* WARNING: * png_read_transform_info (pngrtran.c) performs a simpler set of
|
||||
* calculations to calculate the final pixel depth, then
|
||||
|
@ -4416,7 +4425,7 @@ png_read_start_row(png_structrp png_ptr)
|
|||
defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||
if ((png_ptr->transformations & PNG_USER_TRANSFORM) != 0)
|
||||
{
|
||||
int user_pixel_depth = png_ptr->user_transform_depth *
|
||||
unsigned int user_pixel_depth = png_ptr->user_transform_depth *
|
||||
png_ptr->user_transform_channels;
|
||||
|
||||
if (user_pixel_depth > max_pixel_depth)
|
||||
|
@ -4438,7 +4447,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
|||
* for safety's sake
|
||||
*/
|
||||
row_bytes = PNG_ROWBYTES(max_pixel_depth, row_bytes) +
|
||||
1 + ((max_pixel_depth + 7) >> 3);
|
||||
1 + ((max_pixel_depth + 7) >> 3U);
|
||||
|
||||
#ifdef PNG_MAX_MALLOC_64K
|
||||
if (row_bytes > (png_uint_32)65536L)
|
||||
|
@ -4507,7 +4516,7 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
|||
* does not, so free the read buffer now regardless; the sequential reader
|
||||
* reallocates it on demand.
|
||||
*/
|
||||
if (png_ptr->read_buffer != 0)
|
||||
if (png_ptr->read_buffer != NULL)
|
||||
{
|
||||
png_bytep buffer = png_ptr->read_buffer;
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* Last changed in libpng 1.6.23 [June 9, 2016]
|
||||
* Last changed in libpng 1.6.26 [October 20, 2016]
|
||||
* Copyright (c) 1998-2016 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.)
|
||||
|
@ -283,17 +283,29 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
|
||||
/* Check that the type matches the specification. */
|
||||
if (type < 0 || type > 3)
|
||||
png_error(png_ptr, "Invalid pCAL equation type");
|
||||
{
|
||||
png_chunk_report(png_ptr, "Invalid pCAL equation type",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
if (nparams < 0 || nparams > 255)
|
||||
png_error(png_ptr, "Invalid pCAL parameter count");
|
||||
{
|
||||
png_chunk_report(png_ptr, "Invalid pCAL parameter count",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
/* Validate params[nparams] */
|
||||
for (i=0; i<nparams; ++i)
|
||||
{
|
||||
if (params[i] == NULL ||
|
||||
!png_check_fp_string(params[i], strlen(params[i])))
|
||||
png_error(png_ptr, "Invalid format for pCAL parameter");
|
||||
{
|
||||
png_chunk_report(png_ptr, "Invalid format for pCAL parameter",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
info_ptr->pcal_purpose = png_voidcast(png_charp,
|
||||
|
@ -301,8 +313,8 @@ 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");
|
||||
|
||||
png_chunk_report(png_ptr, "Insufficient memory for pCAL purpose",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -331,7 +343,7 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
memcpy(info_ptr->pcal_units, units, length);
|
||||
|
||||
info_ptr->pcal_params = png_voidcast(png_charpp, png_malloc_warn(png_ptr,
|
||||
(png_size_t)((nparams + 1) * (sizeof (png_charp)))));
|
||||
(png_size_t)(((unsigned int)nparams + 1) * (sizeof (png_charp)))));
|
||||
|
||||
if (info_ptr->pcal_params == NULL)
|
||||
{
|
||||
|
@ -340,7 +352,8 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
return;
|
||||
}
|
||||
|
||||
memset(info_ptr->pcal_params, 0, (nparams + 1) * (sizeof (png_charp)));
|
||||
memset(info_ptr->pcal_params, 0, ((unsigned int)nparams + 1) *
|
||||
(sizeof (png_charp)));
|
||||
|
||||
for (i = 0; i < nparams; i++)
|
||||
{
|
||||
|
@ -563,7 +576,8 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
|
|||
PNG_MAX_PALETTE_LENGTH * (sizeof (png_color))));
|
||||
|
||||
if (num_palette > 0)
|
||||
memcpy(png_ptr->palette, palette, num_palette * (sizeof (png_color)));
|
||||
memcpy(png_ptr->palette, palette, (unsigned int)num_palette *
|
||||
(sizeof (png_color)));
|
||||
info_ptr->palette = png_ptr->palette;
|
||||
info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
|
||||
|
||||
|
@ -1080,7 +1094,7 @@ png_set_sPLT(png_const_structrp png_ptr,
|
|||
* checked it when doing the allocation.
|
||||
*/
|
||||
memcpy(np->entries, entries->entries,
|
||||
entries->nentries * sizeof (png_sPLT_entry));
|
||||
(unsigned int)entries->nentries * sizeof (png_sPLT_entry));
|
||||
|
||||
/* Note that 'continue' skips the advance of the out pointer and out
|
||||
* count, so an invalid entry is not added.
|
||||
|
@ -1249,7 +1263,7 @@ png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr,
|
|||
{
|
||||
png_app_error(png_ptr, "invalid unknown chunk location");
|
||||
/* Fake out the pre 1.6.0 behavior: */
|
||||
if ((location & PNG_HAVE_IDAT) != 0) /* undocumented! */
|
||||
if (((unsigned int)location & PNG_HAVE_IDAT) != 0) /* undocumented! */
|
||||
location = PNG_AFTER_IDAT;
|
||||
|
||||
else
|
||||
|
@ -1373,7 +1387,7 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
|
|||
return;
|
||||
}
|
||||
|
||||
num_chunks = num_chunks_in;
|
||||
num_chunks = (unsigned int)num_chunks_in;
|
||||
}
|
||||
|
||||
old_num_chunks = png_ptr->num_chunk_list;
|
||||
|
@ -1563,7 +1577,7 @@ void PNGAPI
|
|||
png_set_invalid(png_const_structrp png_ptr, png_inforp info_ptr, int mask)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
info_ptr->valid &= ~mask;
|
||||
info_ptr->valid &= (unsigned int)(~mask);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1662,7 +1676,9 @@ png_set_check_for_invalid_index(png_structrp png_ptr, int allowed)
|
|||
png_uint_32 /* PRIVATE */
|
||||
png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
|
||||
{
|
||||
#ifdef PNG_WARNINGS_SUPPORTED
|
||||
png_const_charp orig_key = key;
|
||||
#endif
|
||||
png_uint_32 key_len = 0;
|
||||
int bad_character = 0;
|
||||
int space = 1;
|
||||
|
@ -1725,7 +1741,9 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
|
|||
|
||||
png_formatted_warning(png_ptr, p, "keyword \"@1\": bad character '0x@2'");
|
||||
}
|
||||
#endif /* WARNINGS */
|
||||
#else /* !WARNINGS */
|
||||
PNG_UNUSED(png_ptr)
|
||||
#endif /* !WARNINGS */
|
||||
|
||||
return key_len;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngstruct.h - header file for PNG reference library
|
||||
*
|
||||
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.28 [January 5, 2017]
|
||||
* Copyright (c) 1998-2002,2004,2006-2017 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.)
|
||||
*
|
||||
|
@ -249,7 +249,7 @@ struct png_struct_def
|
|||
png_byte filter; /* file filter type (always 0) */
|
||||
png_byte interlaced; /* PNG_INTERLACE_NONE, PNG_INTERLACE_ADAM7 */
|
||||
png_byte pass; /* current interlace pass (0 - 6) */
|
||||
png_byte do_filter; /* row filter flags (see PNG_FILTER_ below ) */
|
||||
png_byte do_filter; /* row filter flags (see PNG_FILTER_ in png.h ) */
|
||||
png_byte color_type; /* color type of file */
|
||||
png_byte bit_depth; /* bit depth of file */
|
||||
png_byte usr_bit_depth; /* bit depth of users row: write only */
|
||||
|
@ -263,7 +263,7 @@ struct png_struct_def
|
|||
/* pixel depth used for the row buffers */
|
||||
png_byte transformed_pixel_depth;
|
||||
/* pixel depth after read/write transforms */
|
||||
#if PNG_ZLIB_VERNUM >= 0x1240
|
||||
#if ZLIB_VERNUM >= 0x1240
|
||||
png_byte zstream_start; /* at start of an input zlib stream */
|
||||
#endif /* Zlib >= 1.2.4 */
|
||||
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
|
||||
|
@ -353,7 +353,7 @@ struct png_struct_def
|
|||
|
||||
/* Options */
|
||||
#ifdef PNG_SET_OPTION_SUPPORTED
|
||||
png_byte options; /* On/off state (up to 4 options) */
|
||||
png_uint_32 options; /* On/off state (up to 16 options) */
|
||||
#endif
|
||||
|
||||
#if PNG_LIBPNG_VER < 10700
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||
*
|
||||
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.26 [October 20, 2016]
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 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.)
|
||||
*
|
||||
|
@ -172,7 +172,8 @@ png_set_filler(png_structrp png_ptr, png_uint_32 filler, int filler_loc)
|
|||
* size!
|
||||
*/
|
||||
png_app_error(png_ptr,
|
||||
"png_set_filler is invalid for low bit depth gray output");
|
||||
"png_set_filler is invalid for"
|
||||
" low bit depth gray output");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -594,7 +595,7 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
|||
return; /* The filler channel has gone already */
|
||||
|
||||
/* Fix the rowbytes value. */
|
||||
row_info->rowbytes = dp-row;
|
||||
row_info->rowbytes = (unsigned int)(dp-row);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -692,7 +693,7 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
|
|||
* and this calculation is used because it avoids warnings that other
|
||||
* forms produced on either GCC or MSVC.
|
||||
*/
|
||||
int padding = (-row_info->pixel_depth * row_info->width) & 7;
|
||||
int padding = PNG_PADBITS(row_info->pixel_depth, row_info->width);
|
||||
png_bytep rp = png_ptr->row_buf + row_info->rowbytes;
|
||||
|
||||
switch (row_info->bit_depth)
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngwio.c - functions for data output
|
||||
*
|
||||
* Last changed in libpng 1.6.15 [November 20, 2014]
|
||||
* Copyright (c) 1998-2002,2004,2006-2014 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.24 [August 4, 2016]
|
||||
* Copyright (c) 1998-2002,2004,2006-2014,2016 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.)
|
||||
*
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngwrite.c - general routines to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.19 [November 12, 2015]
|
||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.26 [October 20, 2016]
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 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.)
|
||||
*
|
||||
|
@ -666,9 +666,9 @@ 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)
|
||||
{
|
||||
png_uint_32 s0 = (*(rp ) << 8) | *(rp + 1);
|
||||
png_uint_32 s1 = (*(rp + 2) << 8) | *(rp + 3);
|
||||
png_uint_32 s2 = (*(rp + 4) << 8) | *(rp + 5);
|
||||
png_uint_32 s0 = (png_uint_32)(*(rp ) << 8) | *(rp + 1);
|
||||
png_uint_32 s1 = (png_uint_32)(*(rp + 2) << 8) | *(rp + 3);
|
||||
png_uint_32 s2 = (png_uint_32)(*(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);
|
||||
|
@ -901,7 +901,7 @@ png_set_flush(png_structrp png_ptr, int nrows)
|
|||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_ptr->flush_dist = (nrows < 0 ? 0 : nrows);
|
||||
png_ptr->flush_dist = (nrows < 0 ? 0 : (png_uint_32)nrows);
|
||||
}
|
||||
|
||||
/* Flush the current output buffers now */
|
||||
|
@ -1525,7 +1525,8 @@ png_write_image_16bit(png_voidp argument)
|
|||
display->first_row);
|
||||
png_uint_16p output_row = png_voidcast(png_uint_16p, display->local_row);
|
||||
png_uint_16p row_end;
|
||||
const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
|
||||
const unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ?
|
||||
3 : 1;
|
||||
int aindex = 0;
|
||||
png_uint_32 y = image->height;
|
||||
|
||||
|
@ -1539,9 +1540,9 @@ png_write_image_16bit(png_voidp argument)
|
|||
++output_row;
|
||||
}
|
||||
else
|
||||
aindex = channels;
|
||||
aindex = (int)channels;
|
||||
# else
|
||||
aindex = channels;
|
||||
aindex = (int)channels;
|
||||
# endif
|
||||
}
|
||||
|
||||
|
@ -1554,7 +1555,7 @@ png_write_image_16bit(png_voidp argument)
|
|||
*/
|
||||
row_end = output_row + image->width * (channels+1);
|
||||
|
||||
while (y-- > 0)
|
||||
for (; y > 0; --y)
|
||||
{
|
||||
png_const_uint_16p in_ptr = input_row;
|
||||
png_uint_16p out_ptr = output_row;
|
||||
|
@ -1575,7 +1576,7 @@ png_write_image_16bit(png_voidp argument)
|
|||
if (alpha > 0 && alpha < 65535)
|
||||
reciprocal = ((0xffff<<15)+(alpha>>1))/alpha;
|
||||
|
||||
c = channels;
|
||||
c = (int)channels;
|
||||
do /* always at least one channel */
|
||||
{
|
||||
png_uint_16 component = *in_ptr++;
|
||||
|
@ -1610,7 +1611,7 @@ png_write_image_16bit(png_voidp argument)
|
|||
}
|
||||
|
||||
png_write_row(png_ptr, png_voidcast(png_const_bytep, display->local_row));
|
||||
input_row += display->row_bytes/(sizeof (png_uint_16));
|
||||
input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16));
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
@ -1683,7 +1684,8 @@ png_write_image_8bit(png_voidp argument)
|
|||
display->first_row);
|
||||
png_bytep output_row = png_voidcast(png_bytep, display->local_row);
|
||||
png_uint_32 y = image->height;
|
||||
const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
|
||||
const unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ?
|
||||
3 : 1;
|
||||
|
||||
if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0)
|
||||
{
|
||||
|
@ -1700,12 +1702,12 @@ png_write_image_8bit(png_voidp argument)
|
|||
|
||||
else
|
||||
# endif
|
||||
aindex = channels;
|
||||
aindex = (int)channels;
|
||||
|
||||
/* Use row_end in place of a loop counter: */
|
||||
row_end = output_row + image->width * (channels+1);
|
||||
|
||||
while (y-- > 0)
|
||||
for (; y > 0; --y)
|
||||
{
|
||||
png_const_uint_16p in_ptr = input_row;
|
||||
png_bytep out_ptr = output_row;
|
||||
|
@ -1723,7 +1725,7 @@ png_write_image_8bit(png_voidp argument)
|
|||
if (alphabyte > 0 && alphabyte < 255)
|
||||
reciprocal = UNP_RECIPROCAL(alpha);
|
||||
|
||||
c = channels;
|
||||
c = (int)channels;
|
||||
do /* always at least one channel */
|
||||
*out_ptr++ = png_unpremultiply(*in_ptr++, alpha, reciprocal);
|
||||
while (--c > 0);
|
||||
|
@ -1735,7 +1737,7 @@ png_write_image_8bit(png_voidp argument)
|
|||
|
||||
png_write_row(png_ptr, png_voidcast(png_const_bytep,
|
||||
display->local_row));
|
||||
input_row += display->row_bytes/(sizeof (png_uint_16));
|
||||
input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16));
|
||||
} /* while y */
|
||||
}
|
||||
|
||||
|
@ -1746,7 +1748,7 @@ png_write_image_8bit(png_voidp argument)
|
|||
*/
|
||||
png_bytep row_end = output_row + image->width * channels;
|
||||
|
||||
while (y-- > 0)
|
||||
for (; y > 0; --y)
|
||||
{
|
||||
png_const_uint_16p in_ptr = input_row;
|
||||
png_bytep out_ptr = output_row;
|
||||
|
@ -1760,7 +1762,7 @@ png_write_image_8bit(png_voidp argument)
|
|||
}
|
||||
|
||||
png_write_row(png_ptr, output_row);
|
||||
input_row += display->row_bytes/(sizeof (png_uint_16));
|
||||
input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1777,7 +1779,7 @@ png_image_set_PLTE(png_image_write_control *display)
|
|||
|
||||
/* NOTE: the caller must check for cmap != NULL and entries != 0 */
|
||||
const png_uint_32 format = image->format;
|
||||
const int channels = PNG_IMAGE_SAMPLE_CHANNELS(format);
|
||||
const unsigned int channels = PNG_IMAGE_SAMPLE_CHANNELS(format);
|
||||
|
||||
# if defined(PNG_FORMAT_BGR_SUPPORTED) &&\
|
||||
defined(PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED)
|
||||
|
@ -1809,7 +1811,7 @@ png_image_set_PLTE(png_image_write_control *display)
|
|||
{
|
||||
png_const_uint_16p entry = png_voidcast(png_const_uint_16p, cmap);
|
||||
|
||||
entry += i * channels;
|
||||
entry += (unsigned int)i * channels;
|
||||
|
||||
if ((channels & 1) != 0) /* no alpha */
|
||||
{
|
||||
|
@ -1865,7 +1867,7 @@ png_image_set_PLTE(png_image_write_control *display)
|
|||
{
|
||||
png_const_bytep entry = png_voidcast(png_const_bytep, cmap);
|
||||
|
||||
entry += i * channels;
|
||||
entry += (unsigned int)i * channels;
|
||||
|
||||
switch (channels)
|
||||
{
|
||||
|
@ -1910,7 +1912,7 @@ png_image_set_PLTE(png_image_write_control *display)
|
|||
png_set_tRNS(image->opaque->png_ptr, image->opaque->info_ptr, tRNS,
|
||||
num_trans, NULL);
|
||||
|
||||
image->colormap_entries = entries;
|
||||
image->colormap_entries = (png_uint_32)entries;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -1940,7 +1942,7 @@ png_image_write_main(png_voidp argument)
|
|||
{
|
||||
const unsigned int channels = PNG_IMAGE_PIXEL_CHANNELS(image->format);
|
||||
|
||||
if (image->width <= 0x7FFFFFFFU/channels) /* no overflow */
|
||||
if (image->width <= 0x7fffffffU/channels) /* no overflow */
|
||||
{
|
||||
png_uint_32 check;
|
||||
const png_uint_32 png_row_stride = image->width * channels;
|
||||
|
@ -1949,10 +1951,10 @@ png_image_write_main(png_voidp argument)
|
|||
display->row_stride = (png_int_32)/*SAFE*/png_row_stride;
|
||||
|
||||
if (display->row_stride < 0)
|
||||
check = -display->row_stride;
|
||||
check = (png_uint_32)(-display->row_stride);
|
||||
|
||||
else
|
||||
check = display->row_stride;
|
||||
check = (png_uint_32)display->row_stride;
|
||||
|
||||
if (check >= png_row_stride)
|
||||
{
|
||||
|
@ -1960,7 +1962,7 @@ png_image_write_main(png_voidp argument)
|
|||
* limits the whole image size to 32 bits for API compatibility with
|
||||
* the current, 32-bit, PNG_IMAGE_BUFFER_SIZE macro.
|
||||
*/
|
||||
if (image->height > 0xFFFFFFFF/png_row_stride)
|
||||
if (image->height > 0xffffffffU/png_row_stride)
|
||||
png_error(image->opaque->png_ptr, "memory image too large");
|
||||
}
|
||||
|
||||
|
@ -2136,7 +2138,7 @@ png_image_write_main(png_voidp argument)
|
|||
ptrdiff_t row_bytes = display->row_bytes;
|
||||
png_uint_32 y = image->height;
|
||||
|
||||
while (y-- > 0)
|
||||
for (; y > 0; --y)
|
||||
{
|
||||
png_write_row(png_ptr, row);
|
||||
row += row_bytes;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
/* pngwtran.c - transforms the data in a row for PNG writers
|
||||
*
|
||||
* Last changed in libpng 1.6.18 [July 23, 2015]
|
||||
* Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson
|
||||
* Last changed in libpng 1.6.26 [October 20, 2016]
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 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.)
|
||||
*
|
||||
|
@ -177,7 +177,7 @@ png_do_shift(png_row_infop row_info, png_bytep row,
|
|||
if (row_info->color_type != PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
int shift_start[4], shift_dec[4];
|
||||
int channels = 0;
|
||||
unsigned int channels = 0;
|
||||
|
||||
if ((row_info->color_type & PNG_COLOR_MASK_COLOR) != 0)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
|
||||
/* pngwutil.c - utilities to write a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.22 [May 26, 2016]
|
||||
* Last changed in libpng 1.6.26 [October 20, 2016]
|
||||
* Copyright (c) 1998-2002,2004,2006-2016 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.)
|
||||
|
@ -408,7 +408,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
|
|||
png_ptr->zstream.avail_out = 0;
|
||||
|
||||
/* Now initialize if required, setting the new parameters, otherwise just
|
||||
* to a simple reset to the previous parameters.
|
||||
* do a simple reset to the previous parameters.
|
||||
*/
|
||||
if ((png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED) != 0)
|
||||
ret = deflateReset(&png_ptr->zstream);
|
||||
|
@ -1176,7 +1176,7 @@ png_write_sPLT(png_structrp png_ptr, png_const_sPLT_tp spalette)
|
|||
png_byte new_name[80];
|
||||
png_byte entrybuf[10];
|
||||
png_size_t entry_size = (spalette->depth == 8 ? 6 : 10);
|
||||
png_size_t palette_size = entry_size * spalette->nentries;
|
||||
png_size_t palette_size = entry_size * (png_size_t)spalette->nentries;
|
||||
png_sPLT_entryp ep;
|
||||
#ifndef PNG_POINTER_INDEXING_SUPPORTED
|
||||
int i;
|
||||
|
@ -1441,7 +1441,8 @@ png_write_bKGD(png_structrp png_ptr, png_const_color_16p back, int color_type)
|
|||
#endif
|
||||
{
|
||||
png_warning(png_ptr,
|
||||
"Ignoring attempt to write 16-bit bKGD chunk when bit_depth is 8");
|
||||
"Ignoring attempt to write 16-bit bKGD chunk "
|
||||
"when bit_depth is 8");
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -1742,7 +1743,7 @@ png_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0,
|
|||
total_len = purpose_len + units_len + 10;
|
||||
|
||||
params_len = (png_size_tp)png_malloc(png_ptr,
|
||||
(png_alloc_size_t)(nparams * (sizeof (png_size_t))));
|
||||
(png_alloc_size_t)((png_alloc_size_t)nparams * (sizeof (png_size_t))));
|
||||
|
||||
/* Find the length of each parameter, making sure we don't count the
|
||||
* null terminator for the last parameter.
|
||||
|
@ -2254,7 +2255,7 @@ png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||
png_bytep rp, dp, lp;
|
||||
png_size_t i;
|
||||
png_size_t sum = 0;
|
||||
int v;
|
||||
unsigned int v;
|
||||
|
||||
png_ptr->try_row[0] = PNG_FILTER_VALUE_SUB;
|
||||
|
||||
|
@ -2262,14 +2263,22 @@ png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||
i++, rp++, dp++)
|
||||
{
|
||||
v = *dp = *rp;
|
||||
#ifdef PNG_USE_ABS
|
||||
sum += 128 - abs((int)v - 128);
|
||||
#else
|
||||
sum += (v < 128) ? v : 256 - v;
|
||||
#endif
|
||||
}
|
||||
|
||||
for (lp = png_ptr->row_buf + 1; i < row_bytes;
|
||||
i++, rp++, lp++, dp++)
|
||||
{
|
||||
v = *dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);
|
||||
#ifdef PNG_USE_ABS
|
||||
sum += 128 - abs((int)v - 128);
|
||||
#else
|
||||
sum += (v < 128) ? v : 256 - v;
|
||||
#endif
|
||||
|
||||
if (sum > lmins) /* We are already worse, don't continue. */
|
||||
break;
|
||||
|
@ -2278,6 +2287,28 @@ png_setup_sub_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||
return (sum);
|
||||
}
|
||||
|
||||
static void /* PRIVATE */
|
||||
png_setup_sub_row_only(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
const png_size_t row_bytes)
|
||||
{
|
||||
png_bytep rp, dp, lp;
|
||||
png_size_t i;
|
||||
|
||||
png_ptr->try_row[0] = PNG_FILTER_VALUE_SUB;
|
||||
|
||||
for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1; i < bpp;
|
||||
i++, rp++, dp++)
|
||||
{
|
||||
*dp = *rp;
|
||||
}
|
||||
|
||||
for (lp = png_ptr->row_buf + 1; i < row_bytes;
|
||||
i++, rp++, lp++, dp++)
|
||||
{
|
||||
*dp = (png_byte)(((int)*rp - (int)*lp) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
static png_size_t /* PRIVATE */
|
||||
png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes,
|
||||
const png_size_t lmins)
|
||||
|
@ -2285,7 +2316,7 @@ png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes,
|
|||
png_bytep rp, dp, pp;
|
||||
png_size_t i;
|
||||
png_size_t sum = 0;
|
||||
int v;
|
||||
unsigned int v;
|
||||
|
||||
png_ptr->try_row[0] = PNG_FILTER_VALUE_UP;
|
||||
|
||||
|
@ -2294,7 +2325,11 @@ png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes,
|
|||
i++, rp++, pp++, dp++)
|
||||
{
|
||||
v = *dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
|
||||
#ifdef PNG_USE_ABS
|
||||
sum += 128 - abs((int)v - 128);
|
||||
#else
|
||||
sum += (v < 128) ? v : 256 - v;
|
||||
#endif
|
||||
|
||||
if (sum > lmins) /* We are already worse, don't continue. */
|
||||
break;
|
||||
|
@ -2302,6 +2337,21 @@ png_setup_up_row(png_structrp png_ptr, const png_size_t row_bytes,
|
|||
|
||||
return (sum);
|
||||
}
|
||||
static void /* PRIVATE */
|
||||
png_setup_up_row_only(png_structrp png_ptr, const png_size_t row_bytes)
|
||||
{
|
||||
png_bytep rp, dp, pp;
|
||||
png_size_t i;
|
||||
|
||||
png_ptr->try_row[0] = PNG_FILTER_VALUE_UP;
|
||||
|
||||
for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1,
|
||||
pp = png_ptr->prev_row + 1; i < row_bytes;
|
||||
i++, rp++, pp++, dp++)
|
||||
{
|
||||
*dp = (png_byte)(((int)*rp - (int)*pp) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
static png_size_t /* PRIVATE */
|
||||
png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
|
@ -2310,7 +2360,7 @@ png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||
png_bytep rp, dp, pp, lp;
|
||||
png_uint_32 i;
|
||||
png_size_t sum = 0;
|
||||
int v;
|
||||
unsigned int v;
|
||||
|
||||
png_ptr->try_row[0] = PNG_FILTER_VALUE_AVG;
|
||||
|
||||
|
@ -2319,7 +2369,11 @@ png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||
{
|
||||
v = *dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);
|
||||
|
||||
#ifdef PNG_USE_ABS
|
||||
sum += 128 - abs((int)v - 128);
|
||||
#else
|
||||
sum += (v < 128) ? v : 256 - v;
|
||||
#endif
|
||||
}
|
||||
|
||||
for (lp = png_ptr->row_buf + 1; i < row_bytes; i++)
|
||||
|
@ -2327,7 +2381,11 @@ png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||
v = *dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2))
|
||||
& 0xff);
|
||||
|
||||
#ifdef PNG_USE_ABS
|
||||
sum += 128 - abs((int)v - 128);
|
||||
#else
|
||||
sum += (v < 128) ? v : 256 - v;
|
||||
#endif
|
||||
|
||||
if (sum > lmins) /* We are already worse, don't continue. */
|
||||
break;
|
||||
|
@ -2335,6 +2393,27 @@ png_setup_avg_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||
|
||||
return (sum);
|
||||
}
|
||||
static void /* PRIVATE */
|
||||
png_setup_avg_row_only(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
const png_size_t row_bytes)
|
||||
{
|
||||
png_bytep rp, dp, pp, lp;
|
||||
png_uint_32 i;
|
||||
|
||||
png_ptr->try_row[0] = PNG_FILTER_VALUE_AVG;
|
||||
|
||||
for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1,
|
||||
pp = png_ptr->prev_row + 1; i < bpp; i++)
|
||||
{
|
||||
*dp++ = (png_byte)(((int)*rp++ - ((int)*pp++ / 2)) & 0xff);
|
||||
}
|
||||
|
||||
for (lp = png_ptr->row_buf + 1; i < row_bytes; i++)
|
||||
{
|
||||
*dp++ = (png_byte)(((int)*rp++ - (((int)*pp++ + (int)*lp++) / 2))
|
||||
& 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
static png_size_t /* PRIVATE */
|
||||
png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
|
@ -2343,7 +2422,7 @@ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||
png_bytep rp, dp, pp, cp, lp;
|
||||
png_size_t i;
|
||||
png_size_t sum = 0;
|
||||
int v;
|
||||
unsigned int v;
|
||||
|
||||
png_ptr->try_row[0] = PNG_FILTER_VALUE_PAETH;
|
||||
|
||||
|
@ -2352,7 +2431,11 @@ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||
{
|
||||
v = *dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);
|
||||
|
||||
#ifdef PNG_USE_ABS
|
||||
sum += 128 - abs((int)v - 128);
|
||||
#else
|
||||
sum += (v < 128) ? v : 256 - v;
|
||||
#endif
|
||||
}
|
||||
|
||||
for (lp = png_ptr->row_buf + 1, cp = png_ptr->prev_row + 1; i < row_bytes;
|
||||
|
@ -2381,7 +2464,11 @@ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||
|
||||
v = *dp++ = (png_byte)(((int)*rp++ - p) & 0xff);
|
||||
|
||||
#ifdef PNG_USE_ABS
|
||||
sum += 128 - abs((int)v - 128);
|
||||
#else
|
||||
sum += (v < 128) ? v : 256 - v;
|
||||
#endif
|
||||
|
||||
if (sum > lmins) /* We are already worse, don't continue. */
|
||||
break;
|
||||
|
@ -2389,6 +2476,48 @@ png_setup_paeth_row(png_structrp png_ptr, const png_uint_32 bpp,
|
|||
|
||||
return (sum);
|
||||
}
|
||||
static void /* PRIVATE */
|
||||
png_setup_paeth_row_only(png_structrp png_ptr, const png_uint_32 bpp,
|
||||
const png_size_t row_bytes)
|
||||
{
|
||||
png_bytep rp, dp, pp, cp, lp;
|
||||
png_size_t i;
|
||||
|
||||
png_ptr->try_row[0] = PNG_FILTER_VALUE_PAETH;
|
||||
|
||||
for (i = 0, rp = png_ptr->row_buf + 1, dp = png_ptr->try_row + 1,
|
||||
pp = png_ptr->prev_row + 1; i < bpp; i++)
|
||||
{
|
||||
*dp++ = (png_byte)(((int)*rp++ - (int)*pp++) & 0xff);
|
||||
}
|
||||
|
||||
for (lp = png_ptr->row_buf + 1, cp = png_ptr->prev_row + 1; i < row_bytes;
|
||||
i++)
|
||||
{
|
||||
int a, b, c, pa, pb, pc, p;
|
||||
|
||||
b = *pp++;
|
||||
c = *cp++;
|
||||
a = *lp++;
|
||||
|
||||
p = b - c;
|
||||
pc = a - c;
|
||||
|
||||
#ifdef PNG_USE_ABS
|
||||
pa = abs(p);
|
||||
pb = abs(pc);
|
||||
pc = abs(p + pc);
|
||||
#else
|
||||
pa = p < 0 ? -p : p;
|
||||
pb = pc < 0 ? -pc : pc;
|
||||
pc = (p + pc) < 0 ? -(p + pc) : p + pc;
|
||||
#endif
|
||||
|
||||
p = (pa <= pb && pa <=pc) ? a : (pb <= pc) ? b : c;
|
||||
|
||||
*dp++ = (png_byte)(((int)*rp++ - p) & 0xff);
|
||||
}
|
||||
}
|
||||
#endif /* WRITE_FILTER */
|
||||
|
||||
void /* PRIVATE */
|
||||
|
@ -2397,7 +2526,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||
#ifndef PNG_WRITE_FILTER_SUPPORTED
|
||||
png_write_filtered_row(png_ptr, png_ptr->row_buf, row_info->rowbytes+1);
|
||||
#else
|
||||
png_byte filter_to_do = png_ptr->do_filter;
|
||||
unsigned int filter_to_do = png_ptr->do_filter;
|
||||
png_bytep row_buf;
|
||||
png_bytep best_row;
|
||||
png_uint_32 bpp;
|
||||
|
@ -2443,32 +2572,33 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||
*/
|
||||
best_row = png_ptr->row_buf;
|
||||
|
||||
|
||||
if ((filter_to_do & PNG_FILTER_NONE) != 0 && filter_to_do != PNG_FILTER_NONE)
|
||||
if (PNG_SIZE_MAX/128 <= row_bytes)
|
||||
{
|
||||
/* Overflow can occur in the calculation, just select the lowest set
|
||||
* filter.
|
||||
*/
|
||||
filter_to_do &= 0U-filter_to_do;
|
||||
}
|
||||
else if ((filter_to_do & PNG_FILTER_NONE) != 0 &&
|
||||
filter_to_do != PNG_FILTER_NONE)
|
||||
{
|
||||
/* Overflow not possible and multiple filters in the list, including the
|
||||
* 'none' filter.
|
||||
*/
|
||||
png_bytep rp;
|
||||
png_size_t sum = 0;
|
||||
png_size_t i;
|
||||
int v;
|
||||
unsigned int v;
|
||||
|
||||
if (PNG_SIZE_MAX/128 <= row_bytes)
|
||||
{
|
||||
for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++)
|
||||
{
|
||||
/* Check for overflow */
|
||||
if (sum > PNG_SIZE_MAX/128 - 256)
|
||||
break;
|
||||
|
||||
v = *rp;
|
||||
sum += (v < 128) ? v : 256 - v;
|
||||
}
|
||||
}
|
||||
else /* Overflow is not possible */
|
||||
{
|
||||
for (i = 0, rp = row_buf + 1; i < row_bytes; i++, rp++)
|
||||
{
|
||||
v = *rp;
|
||||
#ifdef PNG_USE_ABS
|
||||
sum += 128 - abs((int)v - 128);
|
||||
#else
|
||||
sum += (v < 128) ? v : 256 - v;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2479,7 +2609,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||
if (filter_to_do == PNG_FILTER_SUB)
|
||||
/* It's the only filter so no testing is needed */
|
||||
{
|
||||
(void) png_setup_sub_row(png_ptr, bpp, row_bytes, mins);
|
||||
png_setup_sub_row_only(png_ptr, bpp, row_bytes);
|
||||
best_row = png_ptr->try_row;
|
||||
}
|
||||
|
||||
|
@ -2505,7 +2635,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||
/* Up filter */
|
||||
if (filter_to_do == PNG_FILTER_UP)
|
||||
{
|
||||
(void) png_setup_up_row(png_ptr, row_bytes, mins);
|
||||
png_setup_up_row_only(png_ptr, row_bytes);
|
||||
best_row = png_ptr->try_row;
|
||||
}
|
||||
|
||||
|
@ -2531,7 +2661,7 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||
/* Avg filter */
|
||||
if (filter_to_do == PNG_FILTER_AVG)
|
||||
{
|
||||
(void) png_setup_avg_row(png_ptr, bpp, row_bytes, mins);
|
||||
png_setup_avg_row_only(png_ptr, bpp, row_bytes);
|
||||
best_row = png_ptr->try_row;
|
||||
}
|
||||
|
||||
|
@ -2555,9 +2685,9 @@ png_write_find_filter(png_structrp png_ptr, png_row_infop row_info)
|
|||
}
|
||||
|
||||
/* Paeth filter */
|
||||
if ((filter_to_do == PNG_FILTER_PAETH) != 0)
|
||||
if (filter_to_do == PNG_FILTER_PAETH)
|
||||
{
|
||||
(void) png_setup_paeth_row(png_ptr, bpp, row_bytes, mins);
|
||||
png_setup_paeth_row_only(png_ptr, bpp, row_bytes);
|
||||
best_row = png_ptr->try_row;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue