pow and sbit fixes backported to pngvalid from 1.7

Signed-off-by: John Bowler <jbowler@acm.org>
This commit is contained in:
John Bowler 2015-10-03 11:14:43 -07:00
parent 18f0bd1d63
commit 2163c930b0

View File

@ -1949,7 +1949,7 @@ typedef struct png_modifier
unsigned int repeat :1; /* Repeat this transform test. */ unsigned int repeat :1; /* Repeat this transform test. */
unsigned int test_uses_encoding :1; unsigned int test_uses_encoding :1;
/* Lowest sbit to test (libpng fails for sbit < 8) */ /* Lowest sbit to test (pre-1.7 libpng fails for sbit < 8) */
png_byte sbitlow; png_byte sbitlow;
/* Error control - these are the limits on errors accepted by the gamma tests /* Error control - these are the limits on errors accepted by the gamma tests
@ -2036,7 +2036,7 @@ typedef struct png_modifier
unsigned int test_gamma_expand16 :1; unsigned int test_gamma_expand16 :1;
unsigned int test_exhaustive :1; unsigned int test_exhaustive :1;
/* Whether or not to run the low-bit-depth grayscale tests. This fail on /* Whether or not to run the low-bit-depth grayscale tests. This fails on
* gamma images in some cases because of gross inaccuracies in the grayscale * gamma images in some cases because of gross inaccuracies in the grayscale
* gamma handling for low bit depth. * gamma handling for low bit depth.
*/ */
@ -7158,7 +7158,7 @@ image_transform_png_set_rgb_to_gray_ini(const image_transform *this,
* conversion adds another +/-2 in the 16-bit case and * conversion adds another +/-2 in the 16-bit case and
* +/-(1<<(15-PNG_MAX_GAMMA_8)) in the 8-bit case. * +/-(1<<(15-PNG_MAX_GAMMA_8)) in the 8-bit case.
*/ */
that->pm->limit += pow( that->pm->limit += (pow)(
# if PNG_MAX_GAMMA_8 < 14 # if PNG_MAX_GAMMA_8 < 14
(that->this.bit_depth == 16 ? 8. : (that->this.bit_depth == 16 ? 8. :
6. + (1<<(15-PNG_MAX_GAMMA_8))) 6. + (1<<(15-PNG_MAX_GAMMA_8)))
@ -7182,7 +7182,7 @@ image_transform_png_set_rgb_to_gray_ini(const image_transform *this,
* affects the limit used for checking for internal calculation errors, * affects the limit used for checking for internal calculation errors,
* not the actual limit imposed by pngvalid on the output errors. * not the actual limit imposed by pngvalid on the output errors.
*/ */
that->pm->limit += pow( that->pm->limit += (pow)(
# if DIGITIZE # if DIGITIZE
1.3 1.3
# else # else
@ -11127,7 +11127,11 @@ int main(int argc, char **argv)
pm.encodings = test_encodings; pm.encodings = test_encodings;
pm.nencodings = ARRAY_SIZE(test_encodings); pm.nencodings = ARRAY_SIZE(test_encodings);
pm.sbitlow = 8U; /* because libpng doesn't do sBIT below 8! */ # if PNG_LIBPNG_VER < 10700
pm.sbitlow = 8U; /* because libpng doesn't do sBIT below 8! */
# else
pm.sbitlow = 1U;
# endif
/* The following allows results to pass if they correspond to anything in the /* The following allows results to pass if they correspond to anything in the
* transformed range [input-.5,input+.5]; this is is required because of the * transformed range [input-.5,input+.5]; this is is required because of the