mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-30 01:29:42 -06:00
Update bundled libpng to version 1.6.37
This commit is contained in:
305
Externals/libpng/pngrutil.c
vendored
305
Externals/libpng/pngrutil.c
vendored
@ -1,10 +1,10 @@
|
||||
|
||||
/* pngrutil.c - utilities to read a PNG file
|
||||
*
|
||||
* Last changed in libpng 1.6.29 [March 16, 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.)
|
||||
* Copyright (c) 2018 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
|
||||
@ -102,7 +102,7 @@ png_get_int_32)(png_const_bytep buf)
|
||||
png_uint_16 (PNGAPI
|
||||
png_get_uint_16)(png_const_bytep buf)
|
||||
{
|
||||
/* ANSI-C requires an int value to accomodate at least 16 bits so this
|
||||
/* ANSI-C requires an int value to accommodate at least 16 bits so this
|
||||
* works and allows the compiler not to worry about possible narrowing
|
||||
* on 32-bit systems. (Pre-ANSI systems did not make integers smaller
|
||||
* than 16 bits either.)
|
||||
@ -120,7 +120,7 @@ png_get_uint_16)(png_const_bytep buf)
|
||||
void /* PRIVATE */
|
||||
png_read_sig(png_structrp png_ptr, png_inforp info_ptr)
|
||||
{
|
||||
png_size_t num_checked, num_to_check;
|
||||
size_t num_checked, num_to_check;
|
||||
|
||||
/* Exit if the user application does not expect a signature. */
|
||||
if (png_ptr->sig_bytes >= 8)
|
||||
@ -181,6 +181,9 @@ png_read_chunk_header(png_structrp png_ptr)
|
||||
/* Check to see if chunk name is valid. */
|
||||
png_check_chunk_name(png_ptr, png_ptr->chunk_name);
|
||||
|
||||
/* Check for too-large chunk length */
|
||||
png_check_chunk_length(png_ptr, length);
|
||||
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA;
|
||||
#endif
|
||||
@ -311,6 +314,7 @@ png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn)
|
||||
|
||||
if (buffer != NULL)
|
||||
{
|
||||
memset(buffer, 0, new_size); /* just in case */
|
||||
png_ptr->read_buffer = buffer;
|
||||
png_ptr->read_buffer_size = new_size;
|
||||
}
|
||||
@ -670,6 +674,8 @@ png_decompress_chunk(png_structrp png_ptr,
|
||||
|
||||
if (text != NULL)
|
||||
{
|
||||
memset(text, 0, buffer_size);
|
||||
|
||||
ret = png_inflate(png_ptr, png_ptr->chunk_name, 1/*finish*/,
|
||||
png_ptr->read_buffer + prefix_size, &lzsize,
|
||||
text + prefix_size, newlength);
|
||||
@ -733,9 +739,7 @@ png_decompress_chunk(png_structrp png_ptr,
|
||||
{
|
||||
/* inflateReset failed, store the error message */
|
||||
png_zstream_error(png_ptr, ret);
|
||||
|
||||
if (ret == Z_STREAM_END)
|
||||
ret = PNG_UNEXPECTED_ZLIB_RETURN;
|
||||
ret = PNG_UNEXPECTED_ZLIB_RETURN;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1377,11 +1381,13 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
* chunk is just ignored, so does not invalidate the color space. An
|
||||
* alternative is to set the 'invalid' flags at the start of this routine
|
||||
* and only clear them in they were not set before and all the tests pass.
|
||||
* The minimum 'deflate' stream is assumed to be just the 2 byte header and
|
||||
* 4 byte checksum. The keyword must be at least one character and there is
|
||||
* a terminator (0) byte and the compression method.
|
||||
*/
|
||||
if (length < 9)
|
||||
|
||||
/* The keyword must be at least one character and there is a
|
||||
* terminator (0) byte and the compression method byte, and the
|
||||
* 'zlib' datastream is at least 11 bytes.
|
||||
*/
|
||||
if (length < 14)
|
||||
{
|
||||
png_crc_finish(png_ptr, length);
|
||||
png_chunk_benign_error(png_ptr, "too short");
|
||||
@ -1413,6 +1419,16 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
png_crc_read(png_ptr, (png_bytep)keyword, read_length);
|
||||
length -= read_length;
|
||||
|
||||
/* The minimum 'zlib' stream is assumed to be just the 2 byte header,
|
||||
* 5 bytes minimum 'deflate' stream, and the 4 byte checksum.
|
||||
*/
|
||||
if (length < 11)
|
||||
{
|
||||
png_crc_finish(png_ptr, length);
|
||||
png_chunk_benign_error(png_ptr, "too short");
|
||||
return;
|
||||
}
|
||||
|
||||
keyword_length = 0;
|
||||
while (keyword_length < 80 && keyword_length < read_length &&
|
||||
keyword[keyword_length] != 0)
|
||||
@ -1431,7 +1447,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
|
||||
if (png_inflate_claim(png_ptr, png_iCCP) == Z_OK)
|
||||
{
|
||||
Byte profile_header[132];
|
||||
Byte profile_header[132]={0};
|
||||
Byte local_buffer[PNG_INFLATE_BUF_SIZE];
|
||||
png_alloc_size_t size = (sizeof profile_header);
|
||||
|
||||
@ -1445,8 +1461,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
{
|
||||
/* We have the ICC profile header; do the basic header checks.
|
||||
*/
|
||||
const png_uint_32 profile_length =
|
||||
png_get_uint_32(profile_header);
|
||||
png_uint_32 profile_length = png_get_uint_32(profile_header);
|
||||
|
||||
if (png_icc_check_length(png_ptr, &png_ptr->colorspace,
|
||||
keyword, profile_length) != 0)
|
||||
@ -1461,10 +1476,10 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
/* Now read the tag table; a variable size buffer is
|
||||
* needed at this point, allocate one for the whole
|
||||
* profile. The header check has already validated
|
||||
* that none of these stuff will overflow.
|
||||
* that none of this stuff will overflow.
|
||||
*/
|
||||
const png_uint_32 tag_count = png_get_uint_32(
|
||||
profile_header+128);
|
||||
png_uint_32 tag_count =
|
||||
png_get_uint_32(profile_header + 128);
|
||||
png_bytep profile = png_read_buffer(png_ptr,
|
||||
profile_length, 2/*silent*/);
|
||||
|
||||
@ -1568,19 +1583,11 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
else if (size > 0)
|
||||
errmsg = "truncated";
|
||||
|
||||
#ifndef __COVERITY__
|
||||
else
|
||||
if (errmsg == NULL)
|
||||
errmsg = png_ptr->zstream.msg;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* else png_icc_check_tag_table output an error */
|
||||
}
|
||||
|
||||
else /* profile truncated */
|
||||
errmsg = png_ptr->zstream.msg;
|
||||
}
|
||||
@ -1640,7 +1647,7 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
int entry_size, i;
|
||||
png_uint_32 skip = 0;
|
||||
png_uint_32 dl;
|
||||
png_size_t max_dl;
|
||||
size_t max_dl;
|
||||
|
||||
png_debug(1, "in png_handle_sPLT");
|
||||
|
||||
@ -1989,6 +1996,15 @@ png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
|
||||
else if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0) /* GRAY */
|
||||
{
|
||||
if (png_ptr->bit_depth <= 8)
|
||||
{
|
||||
if (buf[0] != 0 || buf[1] >= (unsigned int)(1 << png_ptr->bit_depth))
|
||||
{
|
||||
png_chunk_benign_error(png_ptr, "invalid gray level");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
background.index = 0;
|
||||
background.red =
|
||||
background.green =
|
||||
@ -1998,6 +2014,15 @@ png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
|
||||
else
|
||||
{
|
||||
if (png_ptr->bit_depth <= 8)
|
||||
{
|
||||
if (buf[0] != 0 || buf[2] != 0 || buf[4] != 0)
|
||||
{
|
||||
png_chunk_benign_error(png_ptr, "invalid color");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
background.index = 0;
|
||||
background.red = png_get_uint_16(buf);
|
||||
background.green = png_get_uint_16(buf + 2);
|
||||
@ -2009,6 +2034,69 @@ png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_eXIf_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
png_handle_eXIf(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
png_debug(1, "in png_handle_eXIf");
|
||||
|
||||
if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
|
||||
png_chunk_error(png_ptr, "missing IHDR");
|
||||
|
||||
if (length < 2)
|
||||
{
|
||||
png_crc_finish(png_ptr, length);
|
||||
png_chunk_benign_error(png_ptr, "too short");
|
||||
return;
|
||||
}
|
||||
|
||||
else if (info_ptr == NULL || (info_ptr->valid & PNG_INFO_eXIf) != 0)
|
||||
{
|
||||
png_crc_finish(png_ptr, length);
|
||||
png_chunk_benign_error(png_ptr, "duplicate");
|
||||
return;
|
||||
}
|
||||
|
||||
info_ptr->free_me |= PNG_FREE_EXIF;
|
||||
|
||||
info_ptr->eXIf_buf = png_voidcast(png_bytep,
|
||||
png_malloc_warn(png_ptr, length));
|
||||
|
||||
if (info_ptr->eXIf_buf == NULL)
|
||||
{
|
||||
png_crc_finish(png_ptr, length);
|
||||
png_chunk_benign_error(png_ptr, "out of memory");
|
||||
return;
|
||||
}
|
||||
|
||||
for (i = 0; i < length; i++)
|
||||
{
|
||||
png_byte buf[1];
|
||||
png_crc_read(png_ptr, buf, 1);
|
||||
info_ptr->eXIf_buf[i] = buf[0];
|
||||
if (i == 1 && buf[0] != 'M' && buf[0] != 'I'
|
||||
&& info_ptr->eXIf_buf[0] != buf[0])
|
||||
{
|
||||
png_crc_finish(png_ptr, length);
|
||||
png_chunk_benign_error(png_ptr, "incorrect byte-order specifier");
|
||||
png_free(png_ptr, info_ptr->eXIf_buf);
|
||||
info_ptr->eXIf_buf = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (png_crc_finish(png_ptr, 0) != 0)
|
||||
return;
|
||||
|
||||
png_set_eXIf_1(png_ptr, info_ptr, length, info_ptr->eXIf_buf);
|
||||
|
||||
png_free(png_ptr, info_ptr->eXIf_buf);
|
||||
info_ptr->eXIf_buf = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_hIST_SUPPORTED
|
||||
void /* PRIVATE */
|
||||
png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
@ -2288,7 +2376,7 @@ void /* PRIVATE */
|
||||
png_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
{
|
||||
png_bytep buffer;
|
||||
png_size_t i;
|
||||
size_t i;
|
||||
int state;
|
||||
|
||||
png_debug(1, "in png_handle_sCAL");
|
||||
@ -2358,7 +2446,7 @@ png_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
|
||||
else
|
||||
{
|
||||
png_size_t heighti = i;
|
||||
size_t heighti = i;
|
||||
|
||||
state = 0;
|
||||
if (png_check_fp_number((png_const_charp)buffer, length,
|
||||
@ -2537,6 +2625,9 @@ png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
|
||||
png_ptr->mode |= PNG_AFTER_IDAT;
|
||||
|
||||
/* Note, "length" is sufficient here; we won't be adding
|
||||
* a null terminator later.
|
||||
*/
|
||||
buffer = png_read_buffer(png_ptr, length, 2/*silent*/);
|
||||
|
||||
if (buffer == NULL)
|
||||
@ -2583,23 +2674,28 @@ png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
{
|
||||
png_text text;
|
||||
|
||||
/* It worked; png_ptr->read_buffer now looks like a tEXt chunk except
|
||||
* for the extra compression type byte and the fact that it isn't
|
||||
* necessarily '\0' terminated.
|
||||
*/
|
||||
buffer = png_ptr->read_buffer;
|
||||
buffer[uncompressed_length+(keyword_length+2)] = 0;
|
||||
if (png_ptr->read_buffer == NULL)
|
||||
errmsg="Read failure in png_handle_zTXt";
|
||||
else
|
||||
{
|
||||
/* It worked; png_ptr->read_buffer now looks like a tEXt chunk
|
||||
* except for the extra compression type byte and the fact that
|
||||
* it isn't necessarily '\0' terminated.
|
||||
*/
|
||||
buffer = png_ptr->read_buffer;
|
||||
buffer[uncompressed_length+(keyword_length+2)] = 0;
|
||||
|
||||
text.compression = PNG_TEXT_COMPRESSION_zTXt;
|
||||
text.key = (png_charp)buffer;
|
||||
text.text = (png_charp)(buffer + keyword_length+2);
|
||||
text.text_length = uncompressed_length;
|
||||
text.itxt_length = 0;
|
||||
text.lang = NULL;
|
||||
text.lang_key = NULL;
|
||||
text.compression = PNG_TEXT_COMPRESSION_zTXt;
|
||||
text.key = (png_charp)buffer;
|
||||
text.text = (png_charp)(buffer + keyword_length+2);
|
||||
text.text_length = uncompressed_length;
|
||||
text.itxt_length = 0;
|
||||
text.lang = NULL;
|
||||
text.lang_key = NULL;
|
||||
|
||||
if (png_set_text_2(png_ptr, info_ptr, &text, 1) != 0)
|
||||
errmsg = "insufficient memory";
|
||||
if (png_set_text_2(png_ptr, info_ptr, &text, 1) != 0)
|
||||
errmsg = "insufficient memory";
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
@ -2788,7 +2884,7 @@ png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length)
|
||||
{
|
||||
PNG_CSTRING_FROM_CHUNK(png_ptr->unknown_chunk.name, png_ptr->chunk_name);
|
||||
/* The following is safe because of the PNG_SIZE_MAX init above */
|
||||
png_ptr->unknown_chunk.size = (png_size_t)length/*SAFE*/;
|
||||
png_ptr->unknown_chunk.size = (size_t)length/*SAFE*/;
|
||||
/* 'mode' is a flag array, only the bottom four bits matter here */
|
||||
png_ptr->unknown_chunk.location = (png_byte)png_ptr->mode/*SAFE*/;
|
||||
|
||||
@ -2975,7 +3071,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
case 2:
|
||||
png_ptr->user_chunk_cache_max = 1;
|
||||
png_chunk_benign_error(png_ptr, "no space in chunk cache");
|
||||
/* FALL THROUGH */
|
||||
/* FALLTHROUGH */
|
||||
case 1:
|
||||
/* NOTE: prior to 1.6.0 this case resulted in an unknown critical
|
||||
* chunk being skipped, now there will be a hard error below.
|
||||
@ -2984,7 +3080,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
default: /* not at limit */
|
||||
--(png_ptr->user_chunk_cache_max);
|
||||
/* FALL THROUGH */
|
||||
/* FALLTHROUGH */
|
||||
case 0: /* no limit */
|
||||
# endif /* USER_LIMITS */
|
||||
/* Here when the limit isn't reached or when limits are compiled
|
||||
@ -3035,20 +3131,61 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
|
||||
*/
|
||||
|
||||
void /* PRIVATE */
|
||||
png_check_chunk_name(png_structrp png_ptr, png_uint_32 chunk_name)
|
||||
png_check_chunk_name(png_const_structrp png_ptr, png_uint_32 chunk_name)
|
||||
{
|
||||
int i;
|
||||
png_uint_32 cn=chunk_name;
|
||||
|
||||
png_debug(1, "in png_check_chunk_name");
|
||||
|
||||
for (i=1; i<=4; ++i)
|
||||
{
|
||||
int c = chunk_name & 0xff;
|
||||
int c = cn & 0xff;
|
||||
|
||||
if (c < 65 || c > 122 || (c > 90 && c < 97))
|
||||
png_chunk_error(png_ptr, "invalid chunk type");
|
||||
|
||||
chunk_name >>= 8;
|
||||
cn >>= 8;
|
||||
}
|
||||
}
|
||||
|
||||
void /* PRIVATE */
|
||||
png_check_chunk_length(png_const_structrp png_ptr, png_uint_32 length)
|
||||
{
|
||||
png_alloc_size_t limit = PNG_UINT_31_MAX;
|
||||
|
||||
# ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
if (png_ptr->user_chunk_malloc_max > 0 &&
|
||||
png_ptr->user_chunk_malloc_max < limit)
|
||||
limit = png_ptr->user_chunk_malloc_max;
|
||||
# elif PNG_USER_CHUNK_MALLOC_MAX > 0
|
||||
if (PNG_USER_CHUNK_MALLOC_MAX < limit)
|
||||
limit = PNG_USER_CHUNK_MALLOC_MAX;
|
||||
# endif
|
||||
if (png_ptr->chunk_name == png_IDAT)
|
||||
{
|
||||
png_alloc_size_t idat_limit = PNG_UINT_31_MAX;
|
||||
size_t row_factor =
|
||||
(size_t)png_ptr->width
|
||||
* (size_t)png_ptr->channels
|
||||
* (png_ptr->bit_depth > 8? 2: 1)
|
||||
+ 1
|
||||
+ (png_ptr->interlaced? 6: 0);
|
||||
if (png_ptr->height > PNG_UINT_32_MAX/row_factor)
|
||||
idat_limit = PNG_UINT_31_MAX;
|
||||
else
|
||||
idat_limit = png_ptr->height * row_factor;
|
||||
row_factor = row_factor > 32566? 32566 : row_factor;
|
||||
idat_limit += 6 + 5*(idat_limit/row_factor+1); /* zlib+deflate overhead */
|
||||
idat_limit=idat_limit < PNG_UINT_31_MAX? idat_limit : PNG_UINT_31_MAX;
|
||||
limit = limit < idat_limit? idat_limit : limit;
|
||||
}
|
||||
|
||||
if (length > limit)
|
||||
{
|
||||
png_debug2(0," length = %lu, limit = %lu",
|
||||
(unsigned long)length,(unsigned long)limit);
|
||||
png_chunk_error(png_ptr, "chunk data is too large");
|
||||
}
|
||||
}
|
||||
|
||||
@ -3225,7 +3362,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
/* Hence the pre-compiled masks indexed by PACKSWAP (or not), depth and
|
||||
* then pass:
|
||||
*/
|
||||
static PNG_CONST png_uint_32 row_mask[2/*PACKSWAP*/][3/*depth*/][6] =
|
||||
static const png_uint_32 row_mask[2/*PACKSWAP*/][3/*depth*/][6] =
|
||||
{
|
||||
/* Little-endian byte masks for PACKSWAP */
|
||||
{ S_MASKS(1,0), S_MASKS(2,0), S_MASKS(4,0) },
|
||||
@ -3236,7 +3373,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
/* display_mask has only three entries for the odd passes, so index by
|
||||
* pass>>1.
|
||||
*/
|
||||
static PNG_CONST png_uint_32 display_mask[2][3][3] =
|
||||
static const png_uint_32 display_mask[2][3][3] =
|
||||
{
|
||||
/* Little-endian byte masks for PACKSWAP */
|
||||
{ B_MASKS(1,0), B_MASKS(2,0), B_MASKS(4,0) },
|
||||
@ -3377,7 +3514,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
*/
|
||||
do
|
||||
{
|
||||
dp[0] = sp[0], dp[1] = sp[1];
|
||||
dp[0] = sp[0]; dp[1] = sp[1];
|
||||
|
||||
if (row_width <= bytes_to_jump)
|
||||
return;
|
||||
@ -3398,7 +3535,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display)
|
||||
*/
|
||||
for (;;)
|
||||
{
|
||||
dp[0] = sp[0], dp[1] = sp[1], dp[2] = sp[2];
|
||||
dp[0] = sp[0]; dp[1] = sp[1]; dp[2] = sp[2];
|
||||
|
||||
if (row_width <= bytes_to_jump)
|
||||
return;
|
||||
@ -3549,7 +3686,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 unsigned int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||
static 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)
|
||||
@ -3562,8 +3699,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
{
|
||||
case 1:
|
||||
{
|
||||
png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 3);
|
||||
png_bytep dp = row + (png_size_t)((final_width - 1) >> 3);
|
||||
png_bytep sp = row + (size_t)((row_info->width - 1) >> 3);
|
||||
png_bytep dp = row + (size_t)((final_width - 1) >> 3);
|
||||
unsigned int sshift, dshift;
|
||||
unsigned int s_start, s_end;
|
||||
int s_inc;
|
||||
@ -3689,8 +3826,8 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
|
||||
case 4:
|
||||
{
|
||||
png_bytep sp = row + (png_size_t)((row_info->width - 1) >> 1);
|
||||
png_bytep dp = row + (png_size_t)((final_width - 1) >> 1);
|
||||
png_bytep sp = row + (size_t)((row_info->width - 1) >> 1);
|
||||
png_bytep dp = row + (size_t)((final_width - 1) >> 1);
|
||||
unsigned int sshift, dshift;
|
||||
unsigned int s_start, s_end;
|
||||
int s_inc;
|
||||
@ -3752,12 +3889,12 @@ png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
|
||||
|
||||
default:
|
||||
{
|
||||
png_size_t pixel_bytes = (row_info->pixel_depth >> 3);
|
||||
size_t pixel_bytes = (row_info->pixel_depth >> 3);
|
||||
|
||||
png_bytep sp = row + (png_size_t)(row_info->width - 1)
|
||||
png_bytep sp = row + (size_t)(row_info->width - 1)
|
||||
* pixel_bytes;
|
||||
|
||||
png_bytep dp = row + (png_size_t)(final_width - 1) * pixel_bytes;
|
||||
png_bytep dp = row + (size_t)(final_width - 1) * pixel_bytes;
|
||||
|
||||
int jstop = (int)png_pass_inc[pass];
|
||||
png_uint_32 i;
|
||||
@ -3794,8 +3931,8 @@ static void
|
||||
png_read_filter_row_sub(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
png_size_t i;
|
||||
png_size_t istop = row_info->rowbytes;
|
||||
size_t i;
|
||||
size_t istop = row_info->rowbytes;
|
||||
unsigned int bpp = (row_info->pixel_depth + 7) >> 3;
|
||||
png_bytep rp = row + bpp;
|
||||
|
||||
@ -3812,8 +3949,8 @@ static void
|
||||
png_read_filter_row_up(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
png_size_t i;
|
||||
png_size_t istop = row_info->rowbytes;
|
||||
size_t i;
|
||||
size_t istop = row_info->rowbytes;
|
||||
png_bytep rp = row;
|
||||
png_const_bytep pp = prev_row;
|
||||
|
||||
@ -3828,11 +3965,11 @@ static void
|
||||
png_read_filter_row_avg(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
png_size_t i;
|
||||
size_t i;
|
||||
png_bytep rp = row;
|
||||
png_const_bytep pp = prev_row;
|
||||
unsigned int bpp = (row_info->pixel_depth + 7) >> 3;
|
||||
png_size_t istop = row_info->rowbytes - bpp;
|
||||
size_t istop = row_info->rowbytes - bpp;
|
||||
|
||||
for (i = 0; i < bpp; i++)
|
||||
{
|
||||
@ -3887,7 +4024,10 @@ png_read_filter_row_paeth_1byte_pixel(png_row_infop row_info, png_bytep row,
|
||||
/* Find the best predictor, the least of pa, pb, pc favoring the earlier
|
||||
* ones in the case of a tie.
|
||||
*/
|
||||
if (pb < pa) pa = pb, a = b;
|
||||
if (pb < pa)
|
||||
{
|
||||
pa = pb; a = b;
|
||||
}
|
||||
if (pc < pa) a = c;
|
||||
|
||||
/* Calculate the current pixel in a, and move the previous row pixel to c
|
||||
@ -3939,7 +4079,10 @@ png_read_filter_row_paeth_multibyte_pixel(png_row_infop row_info, png_bytep row,
|
||||
pc = (p + pc) < 0 ? -(p + pc) : p + pc;
|
||||
#endif
|
||||
|
||||
if (pb < pa) pa = pb, a = b;
|
||||
if (pb < pa)
|
||||
{
|
||||
pa = pb; a = b;
|
||||
}
|
||||
if (pc < pa) a = c;
|
||||
|
||||
a += *row;
|
||||
@ -4185,16 +4328,16 @@ png_read_finish_row(png_structrp png_ptr)
|
||||
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||
|
||||
/* Start of interlace block */
|
||||
static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
|
||||
static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
|
||||
|
||||
/* Offset to next interlace block */
|
||||
static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||
static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||
|
||||
/* Start of interlace block in the y direction */
|
||||
static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
|
||||
static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
|
||||
|
||||
/* 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};
|
||||
static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
||||
|
||||
png_debug(1, "in png_read_finish_row");
|
||||
png_ptr->row_number++;
|
||||
@ -4250,19 +4393,19 @@ png_read_start_row(png_structrp png_ptr)
|
||||
/* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
|
||||
|
||||
/* Start of interlace block */
|
||||
static PNG_CONST png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
|
||||
static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
|
||||
|
||||
/* Offset to next interlace block */
|
||||
static PNG_CONST png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||
static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
|
||||
|
||||
/* Start of interlace block in the y direction */
|
||||
static PNG_CONST png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
|
||||
static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
|
||||
|
||||
/* 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};
|
||||
static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
|
||||
|
||||
unsigned int max_pixel_depth;
|
||||
png_size_t row_bytes;
|
||||
size_t row_bytes;
|
||||
|
||||
png_debug(1, "in png_read_start_row");
|
||||
|
||||
|
Reference in New Issue
Block a user