[libpng16] Improved performance of new do_check_palette_indexes() function

(only update the value when it actually increases, move test for whether
the check is wanted out of the function.
This commit is contained in:
Glenn Randers-Pehrson 2012-06-06 13:30:30 -05:00
parent b1e7771d5e
commit 14ca47b453
5 changed files with 15 additions and 8 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.6.0beta23 - June 4, 2012 Libpng 1.6.0beta23 - June 6, 2012
This is not intended to be a public release. It will be replaced This is not intended to be a public release. It will be replaced
within a few weeks by a public version or by another test version. within a few weeks by a public version or by another test version.
@ -369,13 +369,16 @@ Version 1.6.0beta22 [May 23, 2012]
introducing new png_aligncast macros to do the cast in a way that clang introducing new png_aligncast macros to do the cast in a way that clang
accepts. accepts.
Version 1.6.0beta23 [June 4, 2012] Version 1.6.0beta23 [June 6, 2012]
Revised CMakeLists.txt to not attempt to make a symlink under mingw. Revised CMakeLists.txt to not attempt to make a symlink under mingw.
Made fixes for new optimization warnings from gcc 4.7.0. The compiler Made fixes for new optimization warnings from gcc 4.7.0. The compiler
performs an optimization which is safe; however it then warns about it. performs an optimization which is safe; however it then warns about it.
Changing the type of 'palette_number' in pngvalid.c removes the warning. Changing the type of 'palette_number' in pngvalid.c removes the warning.
Do not depend upon a GCC feature macro being available for use in generating Do not depend upon a GCC feature macro being available for use in generating
the linker mapfile symbol prefix. the linker mapfile symbol prefix.
Improved performance of new do_check_palette_indexes() function (only
update the value when it actually increases, move test for whether
the check is wanted out of the function.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit

View File

@ -4120,13 +4120,16 @@ Version 1.6.0beta22 [May 23, 2012]
introducing new png_aligncast macros to do the cast in a way that clang introducing new png_aligncast macros to do the cast in a way that clang
accepts. accepts.
Version 1.6.0beta23 [June 4, 2012] Version 1.6.0beta23 [June 6, 2012]
Revised CMakeLists.txt to not attempt to make a symlink under mingw. Revised CMakeLists.txt to not attempt to make a symlink under mingw.
Made fixes for new optimization warnings from gcc 4.7.0. The compiler Made fixes for new optimization warnings from gcc 4.7.0. The compiler
performs an optimization which is safe; however it then warns about it. performs an optimization which is safe; however it then warns about it.
Changing the type of 'palette_number' in pngvalid.c removes the warning. Changing the type of 'palette_number' in pngvalid.c removes the warning.
Do not depend upon a GCC feature macro being available for use in generating Do not depend upon a GCC feature macro being available for use in generating
the linker mapfile symbol prefix. the linker mapfile symbol prefix.
Improved performance of new do_check_palette_indexes() function (only
update the value when it actually increases, move test for whether
the check is wanted out of the function.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit (subscription required; visit

View File

@ -2342,7 +2342,8 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED #ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
/* Added at libpng-1.5.10 */ /* Added at libpng-1.5.10 */
if (row_info->color_type == PNG_COLOR_TYPE_PALETTE) if (row_info->color_type == PNG_COLOR_TYPE_PALETTE &&
png_ptr->num_palette_max >= 0)
png_do_check_palette_indexes(png_ptr, row_info); png_do_check_palette_indexes(png_ptr, row_info);
#endif #endif

View File

@ -625,8 +625,7 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
void /* PRIVATE */ void /* PRIVATE */
png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info) png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
{ {
if (png_ptr->num_palette < (1 << row_info->bit_depth) && if (png_ptr->num_palette < (1 << row_info->bit_depth))
png_ptr->num_palette_max >= 0)
{ {
/* 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. 'padding' is in *bits* within the last byte, it is
@ -708,7 +707,7 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
{ {
for (; rp > png_ptr->row_buf; rp--) for (; rp > png_ptr->row_buf; rp--)
{ {
if (*rp >= png_ptr->num_palette_max) if (*rp > png_ptr->num_palette_max)
png_ptr->num_palette_max = (int) *rp; png_ptr->num_palette_max = (int) *rp;
} }

View File

@ -813,7 +813,8 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
/* Added at libpng-1.5.10 */ /* Added at libpng-1.5.10 */
#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED #ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
/* Check for out-of-range palette index */ /* Check for out-of-range palette index */
if(row_info.color_type == PNG_COLOR_TYPE_PALETTE) if (row_info.color_type == PNG_COLOR_TYPE_PALETTE &&
png_ptr->num_palette_max >= 0)
png_do_check_palette_indexes(png_ptr, &row_info); png_do_check_palette_indexes(png_ptr, &row_info);
#endif #endif