< prev index next >

src/share/native/sun/awt/libpng/png.c

Print this page
rev 13661 : 8217676: Upgrade libpng to 1.6.37
Reviewed-by: prr, jdv, kcr

*** 27,50 **** * This file is available under and governed by the GNU General Public * License version 2 only, as published by the Free Software Foundation. * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * ! * Last changed in libpng 1.6.35 [July 15, 2018] * Copyright (c) 1998-2002,2004,2006-2018 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.) * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer * and license in png.h */ #include "pngpriv.h" /* Generate a compiler error if there is an old png.h in the search path. */ ! typedef png_libpng_version_1_6_35 Your_png_h_is_not_version_1_6_35; #ifdef __GNUC__ /* The version tests may need to be added to, but the problem warning has * consistently been fixed in GCC versions which obtain wide-spread release. * The problem is that many versions of GCC rearrange comparison expressions in --- 27,50 ---- * This file is available under and governed by the GNU General Public * License version 2 only, as published by the Free Software Foundation. * However, the following notice accompanied the original version of this * file and, per its terms, should not be removed: * ! * Copyright (c) 2018-2019 Cosmin Truta * Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson ! * Copyright (c) 1996-1997 Andreas Dilger ! * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. * * This code is released under the libpng license. * For conditions of distribution and use, see the disclaimer * and license in png.h */ #include "pngpriv.h" /* Generate a compiler error if there is an old png.h in the search path. */ ! typedef png_libpng_version_1_6_37 Your_png_h_is_not_version_1_6_37; #ifdef __GNUC__ /* The version tests may need to be added to, but the problem warning has * consistently been fixed in GCC versions which obtain wide-spread release. * The problem is that many versions of GCC rearrange comparison expressions in
*** 762,772 **** * a "Creation Time" or other text-based time string. */ int PNGAPI png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime) { ! static PNG_CONST char short_months[12][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; if (out == NULL) return 0; --- 762,772 ---- * a "Creation Time" or other text-based time string. */ int PNGAPI png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime) { ! static const char short_months[12][4] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; if (out == NULL) return 0;
*** 840,863 **** { PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */ #ifdef PNG_STRING_COPYRIGHT return PNG_STRING_COPYRIGHT #else - # ifdef __STDC__ return PNG_STRING_NEWLINE \ ! "libpng version 1.6.35 - July 15, 2018" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2002,2004,2006-2018 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.35 - July 15, 2018\ - Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson\ - Copyright (c) 1996-1997 Andreas Dilger\ - Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc."; - # endif #endif } /* The following return the library version as a short string in the * format 1.0.0 through 99.99.99zz. To get the version of *.h files --- 840,857 ---- { PNG_UNUSED(png_ptr) /* Silence compiler warning about unused png_ptr */ #ifdef PNG_STRING_COPYRIGHT return PNG_STRING_COPYRIGHT #else return PNG_STRING_NEWLINE \ ! "libpng version 1.6.37" PNG_STRING_NEWLINE \ ! "Copyright (c) 2018-2019 Cosmin Truta" PNG_STRING_NEWLINE \ "Copyright (c) 1998-2002,2004,2006-2018 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; #endif } /* The following return the library version as a short string in the * format 1.0.0 through 99.99.99zz. To get the version of *.h files
*** 1147,1157 **** void /* PRIVATE */ png_colorspace_set_gamma(png_const_structrp png_ptr, png_colorspacerp colorspace, png_fixed_point gAMA) { /* Changed in libpng-1.5.4 to limit the values to ensure overflow can't ! * occur. Since the fixed point representation is asymetrical it is * possible for 1/gamma to overflow the limit of 21474 and this means the * gamma value must be at least 5/100000 and hence at most 20000.0. For * safety the limits here are a little narrower. The values are 0.00016 to * 6250.0, which are truly ridiculous gamma values (and will produce * displays that are all black or all white.) --- 1141,1151 ---- void /* PRIVATE */ png_colorspace_set_gamma(png_const_structrp png_ptr, png_colorspacerp colorspace, png_fixed_point gAMA) { /* Changed in libpng-1.5.4 to limit the values to ensure overflow can't ! * occur. Since the fixed point representation is asymmetrical it is * possible for 1/gamma to overflow the limit of 21474 and this means the * gamma value must be at least 5/100000 and hence at most 20000.0. For * safety the limits here are a little narrower. The values are 0.00016 to * 6250.0, which are truly ridiculous gamma values (and will produce * displays that are all black or all white.)
*** 3160,3174 **** while (cdigits+czero < precision+clead && fp > DBL_MIN); /* The total output count (max) is now 4+precision */ /* Check for an exponent, if we don't need one we are ! * done and just need to terminate the string. At ! * this point exp_b10==(-1) is effectively a flag - it got ! * to '-1' because of the decrement after outputting ! * the decimal point above (the exponent required is ! * *not* -1!) */ if (exp_b10 >= (-1) && exp_b10 <= 2) { /* The following only happens if we didn't output the * leading zeros above for negative exponent, so this --- 3154,3168 ---- while (cdigits+czero < precision+clead && fp > DBL_MIN); /* The total output count (max) is now 4+precision */ /* Check for an exponent, if we don't need one we are ! * done and just need to terminate the string. At this ! * point, exp_b10==(-1) is effectively a flag: it got ! * to '-1' because of the decrement, after outputting ! * the decimal point above. (The exponent required is ! * *not* -1.) */ if (exp_b10 >= (-1) && exp_b10 <= 2) { /* The following only happens if we didn't output the * leading zeros above for negative exponent, so this
*** 4002,4023 **** * png_error (i.e. if one of the mallocs below fails) - i.e. the *table argument * should be somewhere that will be cleaned. */ static void png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable, ! PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val) { /* Various values derived from 'shift': */ ! PNG_CONST unsigned int num = 1U << (8U - shift); #ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED /* CSE the division and work round wacky GCC warnings (see the comments * in png_gamma_8bit_correct for where these come from.) */ ! PNG_CONST double fmax = 1./(((png_int_32)1 << (16U - shift))-1); #endif ! PNG_CONST unsigned int max = (1U << (16U - shift))-1U; ! PNG_CONST unsigned int max_by_2 = 1U << (15U-shift); unsigned int i; png_uint_16pp table = *ptable = (png_uint_16pp)png_calloc(png_ptr, num * (sizeof (png_uint_16p))); --- 3996,4017 ---- * png_error (i.e. if one of the mallocs below fails) - i.e. the *table argument * should be somewhere that will be cleaned. */ static void png_build_16bit_table(png_structrp png_ptr, png_uint_16pp *ptable, ! unsigned int shift, png_fixed_point gamma_val) { /* Various values derived from 'shift': */ ! unsigned int num = 1U << (8U - shift); #ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED /* CSE the division and work round wacky GCC warnings (see the comments * in png_gamma_8bit_correct for where these come from.) */ ! double fmax = 1.0 / (((png_int_32)1 << (16U - shift)) - 1); #endif ! unsigned int max = (1U << (16U - shift)) - 1U; ! unsigned int max_by_2 = 1U << (15U - shift); unsigned int i; png_uint_16pp table = *ptable = (png_uint_16pp)png_calloc(png_ptr, num * (sizeof (png_uint_16p)));
*** 4079,4092 **** /* NOTE: this function expects the *inverse* of the overall gamma transformation * required. */ static void png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable, ! PNG_CONST unsigned int shift, PNG_CONST png_fixed_point gamma_val) { ! PNG_CONST unsigned int num = 1U << (8U - shift); ! PNG_CONST unsigned int max = (1U << (16U - shift))-1U; unsigned int i; png_uint_32 last; png_uint_16pp table = *ptable = (png_uint_16pp)png_calloc(png_ptr, num * (sizeof (png_uint_16p))); --- 4073,4086 ---- /* NOTE: this function expects the *inverse* of the overall gamma transformation * required. */ static void png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable, ! unsigned int shift, png_fixed_point gamma_val) { ! unsigned int num = 1U << (8U - shift); ! unsigned int max = (1U << (16U - shift))-1U; unsigned int i; png_uint_32 last; png_uint_16pp table = *ptable = (png_uint_16pp)png_calloc(png_ptr, num * (sizeof (png_uint_16p)));
*** 4147,4157 **** * typically much faster). Note that libpng currently does no sBIT processing * (apparently contrary to the spec) so a 256-entry table is always generated. */ static void png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable, ! PNG_CONST png_fixed_point gamma_val) { unsigned int i; png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256); if (png_gamma_significant(gamma_val) != 0) --- 4141,4151 ---- * typically much faster). Note that libpng currently does no sBIT processing * (apparently contrary to the spec) so a 256-entry table is always generated. */ static void png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable, ! png_fixed_point gamma_val) { unsigned int i; png_bytep table = *ptable = (png_bytep)png_malloc(png_ptr, 256); if (png_gamma_significant(gamma_val) != 0)
< prev index next >