[libpng17] Fixed test programs for interlace options. Made pngvalid.c and

pngtest.c work correctly when READ_INTERLACING and/or WRITE_INTERLACING
are switched off.
This commit is contained in:
John Bowler 2013-12-29 10:33:58 -06:00 committed by Glenn Randers-Pehrson
parent eb2af04bd3
commit 114fa16ab3
5 changed files with 112 additions and 52 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.7.0beta26 - December 28, 2013
Libpng 1.7.0beta26 - December 29, 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.
@ -468,12 +468,15 @@ Version 1.7.0beta25 [December 26, 2013]
Merged files with version 1.6.8 that have not changed since then.
Rebuilt configure scripts with automake-1.14.1 and autoconf-2.69
Version 1.7.0beta26 [December 28, 2013]
Version 1.7.0beta26 [December 29, 2013]
Added libpng 1.5 checks to pngvalid.c
Merged with 1.5 and 1.6 changes to create a single pngvalid.c
Added dSIG to chunk list in png.h
Removed #error macro from contrib/tools/pngfix.c (Thomas Klausner).
Merged pngrio.c, pngtrans.c, and pngwio.c with libpng-1.6.9
Fixed test programs for interlace options. Made pngvalid.c and
pngtest.c work correctly when READ_INTERLACING and/or WRITE_INTERLACING
are switched off.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

View File

@ -4757,12 +4757,15 @@ Version 1.7.0beta25 [December 26, 2013]
Merged files with version 1.6.8 that have not changed since then.
Rebuilt configure scripts with automake-1.14.1 and autoconf-2.69
Version 1.7.0beta26 [December 28, 2013]
Version 1.7.0beta26 [December 29, 2013]
Added libpng 1.5 checks to pngvalid.c
Merged with 1.5 and 1.6 changes to create a single pngvalid.c
Added dSIG to chunk list in png.h
Removed #error macro from contrib/tools/pngfix.c (Thomas Klausner).
Merged pngrio.c, pngtrans.c, and pngwio.c with libpng-1.6.9
Fixed test programs for interlace options. Made pngvalid.c and
pngtest.c work correctly when READ_INTERLACING and/or WRITE_INTERLACING
are switched off.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

View File

@ -1,8 +1,8 @@
/* pngvalid.c - validate libpng by constructing then reading png files.
*
* Last changed in libpng 1.6.9 [(PENDING RELEASE)]
* Copyright (c) 2012 Glenn Randers-Pehrson
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Copyright (c) 2013 Glenn Randers-Pehrson
* Written by John Cunningham Bowler
*
* This code is released under the libpng license.
@ -49,6 +49,15 @@
# include <zlib.h> /* For crc32 */
#endif
/* 1.6.1 added support for the configure test harness, which uses 77 to indicate
* a skipped test, in earlier versions we need to succeed on a skipped test, so:
*/
#if PNG_LIBPNG_VER < 10601
# define SKIP 0
#else
# define SKIP 77
#endif
/* pngvalid requires write support and one of the fixed or floating point APIs.
*/
#if defined(PNG_WRITE_SUPPORTED) &&\
@ -3401,10 +3410,28 @@ transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX],
#define DEPTH(bd) ((png_byte)(1U << (bd)))
/* This is just a helper for compiling on minimal systems with no write
* interlacing support.
* interlacing support. If there is no write interlacing we can't generate test
* cases with interlace:
*/
#ifndef PNG_WRITE_INTERLACING_SUPPORTED
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
# define INTERLACE_LAST PNG_INTERLACE_LAST
# define check_interlace_type(type) ((void)(type))
#else
# define INTERLACE_LAST (PNG_INTERLACE_NONE+1)
# define png_set_interlace_handling(a) (1)
static void
check_interlace_type(int PNG_CONST interlace_type)
{
if (interlace_type != PNG_INTERLACE_NONE)
{
/* This is an internal error - --interlace tests should be skipped, not
* attempted.
*/
fprintf(stderr, "pngvalid: no interlace support\n");
exit(99);
}
}
#endif
/* Make a standardized image given a an image colour type, bit depth and
@ -3420,6 +3447,8 @@ make_transform_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
{
context(ps, fault);
check_interlace_type(interlace_type);
Try
{
png_infop pi;
@ -3560,12 +3589,8 @@ make_transform_images(png_store *ps)
{
int interlace_type;
# ifdef PNG_WRITE_INTERLACING_SUPPORTED
for (interlace_type = PNG_INTERLACE_NONE;
interlace_type < PNG_INTERLACE_LAST; ++interlace_type)
# else
interlace_type = PNG_INTERLACE_NONE;
# endif
for (interlace_type = PNG_INTERLACE_NONE;
interlace_type < INTERLACE_LAST; ++interlace_type)
{
char name[FILE_NAME_SIZE];
@ -3655,6 +3680,12 @@ make_size_image(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type,
{
context(ps, fault);
/* At present libpng does not support the write of an interlaced image unless
* PNG_WRITE_INTERLACING_SUPPORTED, even with do_interlace so the code here
* does the pixel interlace itself, so:
*/
check_interlace_type(interlace_type);
Try
{
png_infop pi;
@ -3864,13 +3895,6 @@ make_size(png_store* PNG_CONST ps, png_byte PNG_CONST colour_type, int bdlo,
# ifdef PNG_WRITE_INTERLACING_SUPPORTED
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
@ -3964,6 +3988,8 @@ make_error(png_store* volatile psIn, png_byte PNG_CONST colour_type,
context(ps, fault);
check_interlace_type(interlace_type);
Try
{
png_structp pp;
@ -4066,12 +4092,8 @@ make_errors(png_modifier* PNG_CONST pm, png_byte PNG_CONST colour_type,
{
int interlace_type;
# ifdef PNG_WRITE_INTERLACING_SUPPORTED
for (interlace_type = PNG_INTERLACE_NONE;
interlace_type < PNG_INTERLACE_LAST; ++interlace_type)
# else
interlace_type = PNG_INTERLACE_NONE;
# endif
for (interlace_type = PNG_INTERLACE_NONE;
interlace_type < INTERLACE_LAST; ++interlace_type)
{
unsigned int test;
char name[FILE_NAME_SIZE];
@ -4269,6 +4291,7 @@ standard_display_init(standard_display *dp, png_store* ps, png_uint_32 id,
dp->red_sBIT = dp->blue_sBIT = dp->green_sBIT = dp->alpha_sBIT =
dp->bit_depth;
dp->interlace_type = INTERLACE_FROM_ID(id);
check_interlace_type(dp->interlace_type);
dp->id = id;
/* All the rest are filled in after the read_info: */
dp->w = 0;
@ -4887,7 +4910,7 @@ standard_text_validate(standard_display *dp, png_const_structp pp,
{
standard_check_text(pp, tp, "image name", dp->ps->current->name);
/* This exists because prior to 1.6 the progressive reader left the
/* This exists because prior to 1.5.18 the progressive reader left the
* png_struct z_stream unreset at the end of the image, so subsequent
* attempts to use it simply returns Z_STREAM_END.
*/
@ -4996,7 +5019,7 @@ standard_end(png_structp ppIn, png_infop pi)
* interlaced images.
*/
standard_text_validate(dp, pp, pi,
PNG_LIBPNG_VER >= 10600/*check_end: see comments above*/);
PNG_LIBPNG_VER >= 10518/*check_end: see comments above*/);
standard_image_validate(dp, pp, 0, -1);
}
@ -5098,7 +5121,7 @@ test_standard(png_modifier* PNG_CONST pm, png_byte PNG_CONST colour_type,
int interlace_type;
for (interlace_type = PNG_INTERLACE_NONE;
interlace_type < PNG_INTERLACE_LAST; ++interlace_type)
interlace_type < INTERLACE_LAST; ++interlace_type)
{
standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/,
interlace_type, 0, 0, 0), 0/*do_interlace*/, pm->use_update_info);
@ -5173,6 +5196,7 @@ test_size(png_modifier* PNG_CONST pm, png_byte PNG_CONST colour_type,
if (fail(pm))
return 0;
# ifdef PNG_WRITE_INTERLACING_SUPPORTED
standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/,
PNG_INTERLACE_ADAM7, w, h, 0), 0/*do_interlace*/,
pm->use_update_info);
@ -5186,6 +5210,7 @@ test_size(png_modifier* PNG_CONST pm, png_byte PNG_CONST colour_type,
if (fail(pm))
return 0;
# endif
/* Now validate the interlaced read side - do_interlace true,
* in the progressive case this does actually make a difference
@ -5198,12 +5223,14 @@ test_size(png_modifier* PNG_CONST pm, png_byte PNG_CONST colour_type,
if (fail(pm))
return 0;
# ifdef PNG_WRITE_INTERLACING_SUPPORTED
standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/,
PNG_INTERLACE_ADAM7, w, h, 0), 1/*do_interlace*/,
pm->use_update_info);
if (fail(pm))
return 0;
# endif
}
}
@ -10222,7 +10249,14 @@ int main(int argc, char **argv)
++pm.use_update_info; /* Can call multiple times */
else if (strcmp(*argv, "--interlace") == 0)
pm.interlace_type = PNG_INTERLACE_ADAM7;
{
# ifdef PNG_WRITE_INTERLACING_SUPPORTED
pm.interlace_type = PNG_INTERLACE_ADAM7;
# else
fprintf(stderr, "pngvalid: no write interlace support\n");
return SKIP;
# endif
}
else if (strcmp(*argv, "--use-input-precision") == 0)
pm.use_input_precision = 1U;
@ -10521,11 +10555,6 @@ 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
return SKIP;
}
#endif

View File

@ -1,7 +1,7 @@
/* pngtest.c - a simple test program to test libpng
*
* Last changed in libpng 1.7.0 [(PENDING RELEASE)]
* Last changed in libpng 1.6.9 [(PENDING RELEASE)]
* Copyright (c) 1998-2013 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
* (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.)
@ -45,6 +45,11 @@
/* Known chunks that exist in pngtest.png must be supported or pngtest will fail
* simply as a result of re-ordering them. This may be fixed in 1.7
*
* pngtest allocates a single row buffer for each row and overwrites it,
* therefore if the write side doesn't support the writing of interlaced images
* nothing can be done for an interlaced image (and the code below will fail
* horribly trying to write extra data after writing garbage).
*/
#if defined PNG_READ_SUPPORTED && /* else nothing can be done */\
defined PNG_READ_bKGD_SUPPORTED &&\
@ -58,9 +63,15 @@
defined PNG_READ_sRGB_SUPPORTED &&\
defined PNG_READ_tEXt_SUPPORTED &&\
defined PNG_READ_tIME_SUPPORTED &&\
defined PNG_READ_zTXt_SUPPORTED
defined PNG_READ_zTXt_SUPPORTED &&\
defined PNG_WRITE_INTERLACING_SUPPORTED
#ifdef PNG_ZLIB_HEADER
# include PNG_ZLIB_HEADER /* defined by pnglibconf.h from 1.7 */
#else
# include "zlib.h"
#endif
#include PNG_ZLIB_HEADER /* defined by pnglibconf.h */
/* Copied from pngpriv.h but only used in error messages below. */
#ifndef PNG_ZBUF_SIZE
# define PNG_ZBUF_SIZE 8192
@ -826,6 +837,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
png_structp write_ptr;
png_infop write_info_ptr;
png_infop write_end_info_ptr;
int interlace_preserved = 1;
#else
png_structp write_ptr = NULL;
png_infop write_info_ptr = NULL;
@ -834,7 +846,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
png_bytep row_buf;
png_uint_32 y;
png_uint_32 width, height;
int num_pass, pass;
int num_pass = 1, pass;
int bit_depth, color_type;
row_buf = NULL;
@ -1040,10 +1052,26 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
&color_type, &interlace_type, &compression_type, &filter_type))
{
png_set_IHDR(write_ptr, write_info_ptr, width, height, bit_depth,
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
color_type, interlace_type, compression_type, filter_type);
#else
color_type, PNG_INTERLACE_NONE, compression_type, filter_type);
#ifndef PNG_READ_INTERLACING_SUPPORTED
/* num_pass will not be set below, set it here if the image is
* interlaced: what happens is that write interlacing is *not* turned
* on an the partial interlaced rows are written directly.
*/
switch (interlace_type)
{
case PNG_INTERLACE_NONE:
num_pass = 1;
break;
case PNG_INTERLACE_ADAM7:
num_pass = 7;
break;
default:
png_error(read_ptr, "invalid interlace type");
/*NOT REACHED*/
}
#endif
}
}
@ -1336,14 +1364,10 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
#endif /* SINGLE_ROWBUF_ALLOC */
pngtest_debug("Writing row data");
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
defined(PNG_WRITE_INTERLACING_SUPPORTED)
#ifdef PNG_READ_INTERLACING_SUPPORTED
num_pass = png_set_interlace_handling(read_ptr);
# ifdef PNG_WRITE_SUPPORTED
png_set_interlace_handling(write_ptr);
# endif
#else
num_pass = 1;
if (png_set_interlace_handling(write_ptr) != num_pass)
png_error(write_ptr, "png_set_interlace_handling: inconsistent num_pass");
#endif
#ifdef PNGTEST_TIMING
@ -1575,6 +1599,7 @@ test_one_file(PNG_CONST char *inname, PNG_CONST char *outname)
}
#ifdef PNG_WRITE_SUPPORTED /* else nothing was written */
if (interlace_preserved) /* else the files will be changed */
{
for (;;)
{
@ -1961,7 +1986,7 @@ main(void)
fprintf(STDERR,
" test ignored because libpng was not built with read support\n");
/* And skip this test */
return 77;
return PNG_LIBPNG_VER < 10600 ? 0 : 77;
}
#endif

View File

@ -1,2 +1,2 @@
#!/bin/sh
exec ./pngvalid --standard --interlace
exec ./pngvalid --standard --progressive-read