From fcd7c13ffd227faf718062737d08c786ac730883 Mon Sep 17 00:00:00 2001 From: John Bowler Date: Wed, 22 Jun 2011 23:13:01 -0500 Subject: [PATCH] [devel] Fix pngvalid.c with ACCURATE_SCALE and update scripts/pnglibconf.h.prebuilt --- ANNOUNCE | 19 +++++---- CHANGES | 4 ++ pngvalid.c | 79 ++++++++++++++++++----------------- scripts/pnglibconf.h.prebuilt | 16 ++++--- 4 files changed, 62 insertions(+), 56 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 53bcd2912..d1db8fba4 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,5 +1,5 @@ -Libpng 1.5.4beta07 - June 19, 2011 +Libpng 1.5.4beta08 - June 23, 2011 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. @@ -9,20 +9,20 @@ Files available for download: Source files with LF line endings (for Unix/Linux) and with a "configure" script - 1.5.4beta07.tar.xz (LZMA-compressed, recommended) - 1.5.4beta07.tar.gz - 1.5.4beta07.tar.bz2 + 1.5.4beta08.tar.xz (LZMA-compressed, recommended) + 1.5.4beta08.tar.gz + 1.5.4beta08.tar.bz2 Source files with CRLF line endings (for Windows), without the "configure" script - lp154b07.7z (LZMA-compressed, recommended) - lp154b07.zip + lp154b08.7z (LZMA-compressed, recommended) + lp154b08.zip Other information: - 1.5.4beta07-README.txt - 1.5.4beta07-LICENSE.txt + 1.5.4beta08-README.txt + 1.5.4beta08-LICENSE.txt Changes since the last public release (1.5.2): @@ -236,6 +236,9 @@ Version 1.5.4beta07 [June 19, 2011] maintains some state so that positive, negative and zero values are identified. sCAL uses these to be strictly spec conformant. +Version 1.5.4beta08 [June 23, 2011] + Fixed pngvalid if ACCURATE_SCALE is defined. + Updated scripts/pnglibconf.h.prebuilt. Send comments/corrections/commendations to png-mng-implement at lists.sf.net: (subscription required; visit diff --git a/CHANGES b/CHANGES index 59ecc888b..3b9576949 100644 --- a/CHANGES +++ b/CHANGES @@ -3499,6 +3499,10 @@ Version 1.5.4beta07 [June 19, 2011] maintains some state so that positive, negative and zero values are identified. sCAL uses these to be strictly spec conformant. +Version 1.5.4beta08 [June 23, 2011] + Fixed pngvalid if ACCURATE_SCALE is defined. + Updated scripts/pnglibconf.h.prebuilt. + Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement diff --git a/pngvalid.c b/pngvalid.c index 7c9706e43..8be71f87d 100644 --- a/pngvalid.c +++ b/pngvalid.c @@ -6732,47 +6732,48 @@ gamma_component_validate(PNG_CONST char *name, PNG_CONST validate_info *vi, * This is only done for older libpng versions when the 'inaccurate' * (chop) method of scaling was used. */ -# if !PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED && \ - PNG_LIBPNG_VER < 10504 - /* This may be required for other components in the future, but - * at present the presence of gamma correction effectively - * prevents the errors in the component scaling (I don't quite - * understand why, but since it's better this way I care not to - * ask, JB 20110419.) - */ - if (pass == 0 && alpha < 0 && vi->scale16 && vi->sbit > 8 && - vi->sbit + vi->isbit_shift == 16) - { - tmp = ((id >> 8) - .5)/255; - - if (tmp > 0) +# ifndef PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED +# if PNG_LIBPNG_VER < 10504 + /* This may be required for other components in the future, + * but at present the presence of gamma correction effectively + * prevents the errors in the component scaling (I don't quite + * understand why, but since it's better this way I care not + * to ask, JB 20110419.) + */ + if (pass == 0 && alpha < 0 && vi->scale16 && vi->sbit > 8 && + vi->sbit + vi->isbit_shift == 16) { - is_lo = ceil(outmax * tmp - vi->maxout_total); - if (is_lo < 0) is_lo = 0; + tmp = ((id >> 8) - .5)/255; + + if (tmp > 0) + { + is_lo = ceil(outmax * tmp - vi->maxout_total); + if (is_lo < 0) is_lo = 0; + } + + else + is_lo = 0; + + tmp = ((id >> 8) + .5)/255; + + if (tmp < 1) + { + is_hi = floor(outmax * tmp + vi->maxout_total); + if (is_hi > outmax) is_hi = outmax; + } + + else + is_hi = outmax; + + if (!(od < is_lo || od > is_hi)) + { + if (encoded_error < vi->outlog) + return i; + + pass = "within 8 bit limits:\n"; + } } - - else - is_lo = 0; - - tmp = ((id >> 8) + .5)/255; - - if (tmp < 1) - { - is_hi = floor(outmax * tmp + vi->maxout_total); - if (is_hi > outmax) is_hi = outmax; - } - - else - is_hi = outmax; - - if (!(od < is_lo || od > is_hi)) - { - if (encoded_error < vi->outlog) - return i; - - pass = "within 8 bit limits:\n"; - } - } +# endif # endif } else /* !use_input_precision */ diff --git a/scripts/pnglibconf.h.prebuilt b/scripts/pnglibconf.h.prebuilt index f377b0119..827d17e54 100644 --- a/scripts/pnglibconf.h.prebuilt +++ b/scripts/pnglibconf.h.prebuilt @@ -3,7 +3,7 @@ /* pnglibconf.h - library build configuration */ -/* libpng version 1.5.0 - last changed on February 11, 2011 */ +/* libpng version 1.5.4 - last changed on June 22, 2011 */ /* Copyright (c) 1998-2011 Glenn Randers-Pehrson */ @@ -49,6 +49,7 @@ #define PNG_CONSOLE_IO_SUPPORTED #define PNG_CONVERT_tIME_SUPPORTED #define PNG_EASY_ACCESS_SUPPORTED +/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/ #define PNG_ERROR_TEXT_SUPPORTED #define PNG_FIXED_POINT_SUPPORTED #define PNG_FLOATING_ARITHMETIC_SUPPORTED @@ -68,17 +69,14 @@ #define PNG_POINTER_INDEXING_SUPPORTED #define PNG_PROGRESSIVE_READ_SUPPORTED #define PNG_READ_16BIT_SUPPORTED -#define PNG_READ_16_TO_8_ACCURATE_SCALE_SUPPORTED -#define PNG_READ_16_TO_8_SUPPORTED #define PNG_READ_ALPHA_MODE_SUPPORTED #define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED #define PNG_READ_BACKGROUND_SUPPORTED #define PNG_READ_BGR_SUPPORTED #define PNG_READ_bKGD_SUPPORTED #define PNG_READ_cHRM_SUPPORTED -#define PNG_READ_SCALE_16_TO_8_SUPPORTED -#define PNG_READ_STRIP_16_TO_8_SUPPORTED #define PNG_READ_COMPOSITE_NODIV_SUPPORTED +#define PNG_READ_COMPRESSED_TEXT_SUPPORTED #define PNG_READ_EXPAND_16_SUPPORTED #define PNG_READ_EXPAND_SUPPORTED #define PNG_READ_FILLER_SUPPORTED @@ -101,10 +99,12 @@ #define PNG_READ_QUANTIZE_SUPPORTED #define PNG_READ_RGB_TO_GRAY_SUPPORTED #define PNG_READ_sBIT_SUPPORTED +#define PNG_READ_SCALE_16_TO_8_SUPPORTED #define PNG_READ_sCAL_SUPPORTED #define PNG_READ_SHIFT_SUPPORTED #define PNG_READ_sPLT_SUPPORTED #define PNG_READ_sRGB_SUPPORTED +#define PNG_READ_STRIP_16_TO_8_SUPPORTED #define PNG_READ_STRIP_ALPHA_SUPPORTED #define PNG_READ_SUPPORTED #define PNG_READ_SWAP_ALPHA_SUPPORTED @@ -118,7 +118,6 @@ #define PNG_READ_USER_CHUNKS_SUPPORTED #define PNG_READ_USER_TRANSFORM_SUPPORTED #define PNG_READ_zTXt_SUPPORTED -#define PNG_READ_COMPRESSED_TEXT_SUPPORTED #define PNG_SAVE_INT_32_SUPPORTED #define PNG_sBIT_SUPPORTED #define PNG_sCAL_SUPPORTED @@ -147,6 +146,8 @@ #define PNG_WRITE_BGR_SUPPORTED #define PNG_WRITE_bKGD_SUPPORTED #define PNG_WRITE_cHRM_SUPPORTED +#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED +#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED #define PNG_WRITE_FILLER_SUPPORTED #define PNG_WRITE_FILTER_SUPPORTED #define PNG_WRITE_FLUSH_SUPPORTED @@ -157,7 +158,6 @@ #define PNG_WRITE_INT_FUNCTIONS_SUPPORTED #define PNG_WRITE_INVERT_ALPHA_SUPPORTED #define PNG_WRITE_INVERT_SUPPORTED -#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED #define PNG_WRITE_iTXt_SUPPORTED #define PNG_WRITE_oFFs_SUPPORTED #define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED @@ -183,7 +183,5 @@ #define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED #define PNG_WRITE_zTXt_SUPPORTED #define PNG_zTXt_SUPPORTED -#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED -/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/ /* end of options */ #endif /* PNGLCONF_H */