From 851c67770f9cebece9c79e914a54c348f539a512 Mon Sep 17 00:00:00 2001 From: Matt Sarett Date: Wed, 23 Nov 2016 20:24:06 +0000 Subject: Revert "libpng: Upgrade to 1.6.26" This reverts commit 3586ba4f3287ed6a9e6e15b01b717e2cf1bd8647. https://b.corp.google.com/u/1/issues/33057876 Change-Id: I2c0ea5e3feba74f70009d6ccda4e43b32a17b832 --- pngwrite.c | 56 +++++++++++++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 29 deletions(-) (limited to 'pngwrite.c') diff --git a/pngwrite.c b/pngwrite.c index 07088ee..aaa2b01 100644 --- a/pngwrite.c +++ b/pngwrite.c @@ -1,7 +1,7 @@ /* pngwrite.c - general routines to write a PNG file * - * Last changed in libpng 1.6.26 [October 20, 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.) @@ -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 = (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 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 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 : (png_uint_32)nrows); + png_ptr->flush_dist = (nrows < 0 ? 0 : nrows); } /* Flush the current output buffers now */ @@ -1525,8 +1525,7 @@ 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 unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? - 3 : 1; + const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1; int aindex = 0; png_uint_32 y = image->height; @@ -1540,9 +1539,9 @@ png_write_image_16bit(png_voidp argument) ++output_row; } else - aindex = (int)channels; + aindex = channels; # else - aindex = (int)channels; + aindex = channels; # endif } @@ -1555,7 +1554,7 @@ png_write_image_16bit(png_voidp argument) */ row_end = output_row + image->width * (channels+1); - for (; y > 0; --y) + while (y-- > 0) { png_const_uint_16p in_ptr = input_row; png_uint_16p out_ptr = output_row; @@ -1576,7 +1575,7 @@ png_write_image_16bit(png_voidp argument) if (alpha > 0 && alpha < 65535) reciprocal = ((0xffff<<15)+(alpha>>1))/alpha; - c = (int)channels; + c = channels; do /* always at least one channel */ { png_uint_16 component = *in_ptr++; @@ -1611,7 +1610,7 @@ png_write_image_16bit(png_voidp argument) } png_write_row(png_ptr, png_voidcast(png_const_bytep, display->local_row)); - input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16)); + input_row += display->row_bytes/(sizeof (png_uint_16)); } return 1; @@ -1684,8 +1683,7 @@ 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 unsigned int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? - 3 : 1; + const int channels = (image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1; if ((image->format & PNG_FORMAT_FLAG_ALPHA) != 0) { @@ -1702,12 +1700,12 @@ png_write_image_8bit(png_voidp argument) else # endif - aindex = (int)channels; + aindex = channels; /* Use row_end in place of a loop counter: */ row_end = output_row + image->width * (channels+1); - for (; y > 0; --y) + while (y-- > 0) { png_const_uint_16p in_ptr = input_row; png_bytep out_ptr = output_row; @@ -1725,7 +1723,7 @@ png_write_image_8bit(png_voidp argument) if (alphabyte > 0 && alphabyte < 255) reciprocal = UNP_RECIPROCAL(alpha); - c = (int)channels; + c = channels; do /* always at least one channel */ *out_ptr++ = png_unpremultiply(*in_ptr++, alpha, reciprocal); while (--c > 0); @@ -1737,7 +1735,7 @@ png_write_image_8bit(png_voidp argument) png_write_row(png_ptr, png_voidcast(png_const_bytep, display->local_row)); - input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16)); + input_row += display->row_bytes/(sizeof (png_uint_16)); } /* while y */ } @@ -1748,7 +1746,7 @@ png_write_image_8bit(png_voidp argument) */ png_bytep row_end = output_row + image->width * channels; - for (; y > 0; --y) + while (y-- > 0) { png_const_uint_16p in_ptr = input_row; png_bytep out_ptr = output_row; @@ -1762,7 +1760,7 @@ png_write_image_8bit(png_voidp argument) } png_write_row(png_ptr, output_row); - input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16)); + input_row += display->row_bytes/(sizeof (png_uint_16)); } } @@ -1779,7 +1777,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 unsigned int channels = PNG_IMAGE_SAMPLE_CHANNELS(format); + const int channels = PNG_IMAGE_SAMPLE_CHANNELS(format); # if defined(PNG_FORMAT_BGR_SUPPORTED) &&\ defined(PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED) @@ -1811,7 +1809,7 @@ png_image_set_PLTE(png_image_write_control *display) { png_const_uint_16p entry = png_voidcast(png_const_uint_16p, cmap); - entry += (unsigned int)i * channels; + entry += i * channels; if ((channels & 1) != 0) /* no alpha */ { @@ -1867,7 +1865,7 @@ png_image_set_PLTE(png_image_write_control *display) { png_const_bytep entry = png_voidcast(png_const_bytep, cmap); - entry += (unsigned int)i * channels; + entry += i * channels; switch (channels) { @@ -1912,7 +1910,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 = (png_uint_32)entries; + image->colormap_entries = entries; } static int @@ -1942,7 +1940,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; @@ -1951,10 +1949,10 @@ png_image_write_main(png_voidp argument) display->row_stride = (png_int_32)/*SAFE*/png_row_stride; if (display->row_stride < 0) - check = (png_uint_32)(-display->row_stride); + check = -display->row_stride; else - check = (png_uint_32)display->row_stride; + check = display->row_stride; if (check >= png_row_stride) { @@ -1962,7 +1960,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 > 0xffffffffU/png_row_stride) + if (image->height > 0xFFFFFFFF/png_row_stride) png_error(image->opaque->png_ptr, "memory image too large"); } @@ -2138,7 +2136,7 @@ png_image_write_main(png_voidp argument) ptrdiff_t row_bytes = display->row_bytes; png_uint_32 y = image->height; - for (; y > 0; --y) + while (y-- > 0) { png_write_row(png_ptr, row); row += row_bytes; -- cgit v1.2.3