From e98229ceb0d2d177b1213f0e7ace81a6ba8afa35 Mon Sep 17 00:00:00 2001 From: John Bowler Date: Fri, 27 Dec 2013 08:04:49 -0600 Subject: [PATCH] [libpng17] Merged with 1.5 and 1.6 changes to create a single pngvalid.c --- ANNOUNCE | 1 + CHANGES | 1 + contrib/libtests/pngvalid.c | 37 ++++++++++++++++++++++++++++++++++--- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 255db002b..97342e8df 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -470,6 +470,7 @@ Version 1.7.0beta25 [December 26, 2013] Version 1.7.0beta26 [December 27, 2013] Added libpng 1.5 checks to pngvalid.c + Merged with 1.5 and 1.6 changes to create a single pngvalid.c Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CHANGES b/CHANGES index 6eed715c3..38226f689 100644 --- a/CHANGES +++ b/CHANGES @@ -4759,6 +4759,7 @@ Version 1.7.0beta25 [December 26, 2013] Version 1.7.0beta26 [December 27, 2013] Added libpng 1.5 checks to pngvalid.c + Merged with 1.5 and 1.6 changes to create a single pngvalid.c Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/contrib/libtests/pngvalid.c b/contrib/libtests/pngvalid.c index b39c01cf3..44c06d663 100644 --- a/contrib/libtests/pngvalid.c +++ b/contrib/libtests/pngvalid.c @@ -1,7 +1,7 @@ /* pngvalid.c - validate libpng by constructing then reading png files. * - * Last changed in libpng 1.6.0 [(PENDING RELEASE)] + * Last changed in libpng 1.6.9 [(PENDING RELEASE)] * Copyright (c) 2012 Glenn Randers-Pehrson * Written by John Cunningham Bowler * @@ -39,10 +39,14 @@ */ #ifdef PNG_FREESTANDING_TESTS # include -# include /* For crc32 */ #else # include "../../png.h" +#endif + +#ifdef PNG_ZLIB_HEADER # include PNG_ZLIB_HEADER +#else +# include /* For crc32 */ #endif /* pngvalid requires write support and one of the fixed or floating point APIs. @@ -3861,8 +3865,15 @@ make_size(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type, int bdlo, make_size_image(ps, colour_type, DEPTH(bdlo), PNG_INTERLACE_ADAM7, width, height, 0); # endif +# if defined(PNG_WRITE_INTERLACING_SUPPORTED) || PNG_LIBPNG_VER > 10518 + /* This fails in 1.5.8 with a zlib stream error writing the rows of + * the internally generated interlaced images, but only when the + * read code is disabled: to be investigated. Probably an erroneous + * #define out of the zlib deflate reset. + */ make_size_image(ps, colour_type, DEPTH(bdlo), PNG_INTERLACE_ADAM7, width, height, 1); +# endif } } } @@ -6758,8 +6769,23 @@ image_transform_png_set_rgb_to_gray_ini(PNG_CONST image_transform *this, /* Rounding to 8 bits in the linear space causes massive errors which * will trigger the error check in transform_range_check. Fix that * here by taking the gamma encoding into account. + * + * When DIGITIZE is set because a pre-1.7 version of libpng is being + * tested allow a bigger slack. + * + * NOTE: this magic number was determined by experiment to be 1.1 (when + * using fixed point arithmetic). There's no great merit to the value + * below, however it only affects the limit used for checking for + * internal calculation errors, not the actual limit imposed by + * pngvalid on the output errors. */ - that->pm->limit += pow(1./255, data.gamma); + that->pm->limit += pow( +# if DIGITIZE + 1.1 +# else + 1. +# endif + /255, data.gamma); } } @@ -10495,6 +10521,11 @@ int main(void) fprintf(stderr, "pngvalid: no low level write support in libpng, all tests skipped\n"); /* So the test is skipped: */ +#if PNG_LIBPNG_VER < 10601 + /* Test harness support was only added in libpng 1.6.1: */ + return 0; +#else return 77; +#endif } #endif