Merge branch 'libpng15' of git://github.com/jbowler/libpng into libpng15

This commit is contained in:
Glenn Randers-Pehrson 2016-12-26 19:27:37 -06:00
commit 80d36775d4
4 changed files with 32 additions and 27 deletions

View File

@ -4010,8 +4010,11 @@ check_interlace_type(int const interlace_type)
# define do_own_interlace 1 # define do_own_interlace 1
#endif /* WRITE_INTERLACING tests */ #endif /* WRITE_INTERLACING tests */
#define CAN_WRITE_INTERLACE\ #if PNG_LIBPNG_VER >= 10700 || defined PNG_WRITE_INTERLACING_SUPPORTED
PNG_LIBPNG_VER >= 10700 || defined PNG_WRITE_INTERLACING_SUPPORTED # define CAN_WRITE_INTERLACE 1
#else
# define CAN_WRITE_INTERLACE 0
#endif
/* Do the same thing for read interlacing; this controls whether read tests do /* Do the same thing for read interlacing; this controls whether read tests do
* their own de-interlace or use libpng. * their own de-interlace or use libpng.

31
png.c
View File

@ -776,6 +776,8 @@ png_access_version_number(void)
/* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */ /* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */
# ifdef PNG_CHECK_cHRM_SUPPORTED # ifdef PNG_CHECK_cHRM_SUPPORTED
static void png_64bit_product(long v1, long v2, long *hi_product,
unsigned long *lo_product);
int /* PRIVATE */ int /* PRIVATE */
png_check_cHRM_fixed(png_structp png_ptr, png_check_cHRM_fixed(png_structp png_ptr,
@ -784,7 +786,8 @@ png_check_cHRM_fixed(png_structp png_ptr,
png_fixed_point blue_x, png_fixed_point blue_y) png_fixed_point blue_x, png_fixed_point blue_y)
{ {
int ret = 1; int ret = 1;
unsigned long xy_hi,xy_lo,yx_hi,yx_lo; long xy_hi,yx_hi;
unsigned long xy_lo,yx_lo;
png_debug(1, "in function png_check_cHRM_fixed"); png_debug(1, "in function png_check_cHRM_fixed");
@ -2169,29 +2172,31 @@ png_reciprocal2(png_fixed_point a, png_fixed_point b)
* A and D, and X || Y is (X << 16) + Y. * A and D, and X || Y is (X << 16) + Y.
*/ */
void /* PRIVATE */ static void
png_64bit_product (long v1, long v2, unsigned long *hi_product, png_64bit_product(long v1, long v2, long *hi_product,
unsigned long *lo_product) unsigned long *lo_product)
{ {
int a, b, c, d; long a, b, c, d;
long lo, hi, x, y; unsigned long lo;
long hi, x, y;
a = (v1 >> 16) & 0xffff; a = v1 >> 16;
b = v1 & 0xffff; b = v1 & 0xffff;
c = (v2 >> 16) & 0xffff; c = v2 >> 16;
d = v2 & 0xffff; d = v2 & 0xffff;
lo = b * d; /* BD */ lo = b;
lo *= d; /* BD */
x = a * d + c * b; /* AD + CB */ x = a * d + c * b; /* AD + CB */
y = ((lo >> 16) & 0xffff) + x; y = (lo >> 16) + x;
lo = (lo & 0xffff) | ((y & 0xffff) << 16); lo = (lo & 0xffff) | ((y & 0xffffU) << 16);
hi = (y >> 16) & 0xffff;
hi = y >> 16;
hi += a * c; /* AC */ hi += a * c; /* AC */
*hi_product = (unsigned long)hi; *hi_product = hi;
*lo_product = (unsigned long)lo; *lo_product = lo;
} }
#endif /* CHECK_cHRM */ #endif /* CHECK_cHRM */

View File

@ -1362,13 +1362,6 @@ PNG_EXTERN int png_check_cHRM_fixed PNGARG((png_structp png_ptr,
png_fixed_point int_blue_y)); png_fixed_point int_blue_y));
#endif #endif
#ifdef PNG_CHECK_cHRM_SUPPORTED
/* Added at libpng version 1.2.34 and 1.4.0 */
/* Currently only used by png_check_cHRM_fixed */
PNG_EXTERN void png_64bit_product PNGARG((long v1, long v2,
unsigned long *hi_product, unsigned long *lo_product));
#endif
#ifdef PNG_cHRM_SUPPORTED #ifdef PNG_cHRM_SUPPORTED
/* Added at libpng version 1.5.5 */ /* Added at libpng version 1.5.5 */
typedef struct png_xy typedef struct png_xy

View File

@ -629,12 +629,16 @@ png_do_check_palette_indexes(png_structp png_ptr, png_row_infop row_info)
png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */ png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */
{ {
/* Calculations moved outside switch in an attempt to stop different /* Calculations moved outside switch in an attempt to stop different
* compiler warnings. 'padding' is in *bits* within the last byte, it is * compiler warnings.
* an 'int' because pixel_depth becomes an 'int' in the expression below, *
* and this calculation is used because it avoids warnings that other * 1.5.28: This rewritten version attempts to remove the unsigned integer
* forms produced on either GCC or MSVC. * overflow from the prior version. While this was well defined it
* resulted in unsigned overflow detection in clang. Since the result is
* always in the range 0..7 only the low three bits of of the various
* intermediates are every required, so:
*/ */
int padding = (-row_info->pixel_depth * row_info->width) & 7; unsigned int padding =
((8 - (row_info->pixel_depth & 7)) * (row_info->width & 7)) & 7;
png_bytep rp = png_ptr->row_buf + row_info->rowbytes; png_bytep rp = png_ptr->row_buf + row_info->rowbytes;
switch (row_info->bit_depth) switch (row_info->bit_depth)