From 9e9977e153a16140a75bd27b9635166669e15bac Mon Sep 17 00:00:00 2001 From: John Bowler Date: Thu, 17 Oct 2013 08:23:13 -0500 Subject: [PATCH] [libpng16] Revised pngvalid to generate size images with as many filters as it can manage, limited by the number of rows. --- ANNOUNCE | 6 ++++-- CHANGES | 4 +++- Makefile.am | 5 +++++ contrib/libtests/pngvalid.c | 24 +++++++++++++++++++++++- 4 files changed, 35 insertions(+), 4 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 0dcb5dea7..194f875ab 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -1,5 +1,5 @@ -Libpng 1.6.7beta03 - October 14, 2013 +Libpng 1.6.7beta03 - October 17, 2013 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. @@ -72,10 +72,12 @@ Version 1.6.7beta02 [October 12, 2013] Make autogen.sh work with automake 1.13 as well as 1.14. Do this by always removing the 1.14 'compile' script but never checking for it. -Version 1.6.7beta03 [October 14, 2013] +Version 1.6.7beta03 [October 17, 2013] Added ARMv8 support (James Yu ). Added file arm/filter_neon_intrinsics.c; enable with configuration flag PNG_ARM_NEON_INTRINSICS. + Revised pngvalid to generate size images with as many filters as it can + manage, limited by the number of rows. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/CHANGES b/CHANGES index e7e344495..a6e5efbdf 100644 --- a/CHANGES +++ b/CHANGES @@ -4686,10 +4686,12 @@ Version 1.6.7beta02 [October 12, 2013] Make autogen.sh work with automake 1.13 as well as 1.14. Do this by always removing the 1.14 'compile' script but never checking for it. -Version 1.6.7beta03 [October 14, 2013] +Version 1.6.7beta03 [October 17, 2013] Added ARMv8 support (James Yu ). Added file arm/filter_neon_intrinsics.c; enable with configuration flag PNG_ARM_NEON_INTRINSICS. + Revised pngvalid to generate size images with as many filters as it can + manage, limited by the number of rows. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/Makefile.am b/Makefile.am index 05e534feb..5ac0423e1 100644 --- a/Makefile.am +++ b/Makefile.am @@ -324,3 +324,8 @@ uninstall-hook: rm -f '$(DESTDIR)$(libdir)/libpng.sl' rm -f '$(DESTDIR)$(libdir)/libpng.dylib' rm -f '$(DESTDIR)$(libdir)/libpng.dll.a' + +# The following addition ensures that 'make all' always builds the test programs +# too. It used to, but some change either in libpng or configure stopped this +# working. +all-am: $(check_PROGRAMS) diff --git a/contrib/libtests/pngvalid.c b/contrib/libtests/pngvalid.c index 460fdd4c2..55ec5af4f 100644 --- a/contrib/libtests/pngvalid.c +++ b/contrib/libtests/pngvalid.c @@ -2945,6 +2945,12 @@ sbit_modification_init(sbit_modification *me, png_modifier *pm, png_byte sbit) * height of 16 rows. The width and height are stored in the FILEID and, being * non-zero, indicate a size file. * + * Because the PNG filter code is typically the largest CPU consumer within + * libpng itself there is a tendency to attempt to optimize it. This results in + * special case code which needs to be validated. To cause this to happen the + * 'size' images are made to use each possible filter, in so far as this is + * possible for smaller images. + * * For palette image (colour type 3) multiple transform images are stored with * the same bit depth to allow testing of more colour combinations - * particularly important for testing the gamma code because libpng uses a @@ -3660,6 +3666,7 @@ make_size_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type, int npasses = npasses_from_interlace_type(pp, interlace_type); png_uint_32 y; int pass; + int nfilter = PNG_FILTER_VALUE_LAST; png_byte image[16][SIZE_ROWMAX]; /* To help consistent error detection make the parts of this buffer @@ -3713,7 +3720,22 @@ make_size_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type, continue; } - /* Only get to here if the row has some pixels in it. */ + /* Only get to here if the row has some pixels in it, set the + * filters to 'all' for the very first row and thereafter to a + * single filter. It isn't well documented, but png_set_filter + * does accept a filter number (per the spec) as well as a bit + * mask. + * + * The apparent wackiness of decrementing nfilter rather than + * incrementing is so that Paeth gets used in all images bigger + * than 1 row - it's the tricky one. + */ + png_set_filter(pp, 0/*method*/, + nfilter >= PNG_FILTER_VALUE_LAST ? PNG_ALL_FILTERS : nfilter); + + if (nfilter-- == 0) + nfilter = PNG_FILTER_VALUE_LAST-1; + png_write_row(pp, row); } }