From 9b780b8add76523e27e786ce406b5bc937560bb3 Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Tue, 24 Aug 2010 08:50:01 -0500 Subject: [PATCH] [devel] Turn on progressive reader in pngvalid.c by default and tidy code. --- ANNOUNCE | 1 + CHANGES | 1 + pngvalid.c | 93 ++++++++++++++++++++++++++++-------------------------- 3 files changed, 51 insertions(+), 44 deletions(-) diff --git a/ANNOUNCE b/ANNOUNCE index 19686a542..e132fed0b 100644 --- a/ANNOUNCE +++ b/ANNOUNCE @@ -375,6 +375,7 @@ Version 1.5.0beta44 [August 11, 2010] Simplified the pngvalid error-handling code now that cexcept.h is in place. Implemented progressive reader in pngvalid.c for standard tests Implemented progressive read in pngvalid.c gamma tests + Turn on progressive reader in pngvalid.c by default and tidy code. Send comments/corrections/commendations to png-mng-implement at lists.sf.net: (subscription required; visit diff --git a/CHANGES b/CHANGES index 1385b9b60..9359a51bb 100644 --- a/CHANGES +++ b/CHANGES @@ -3012,6 +3012,7 @@ Version 1.5.0beta44 [August 11, 2010] Simplified the pngvalid error-handling code now that cexcept.h is in place. Implemented progressive reader in pngvalid.c for standard tests Implemented progressive read in pngvalid.c gamma tests + Turn on progressive reader in pngvalid.c by default and tidy code. Send comments/corrections/commendations to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/pngvalid.c b/pngvalid.c index 35d912528..cbfd6616f 100644 --- a/pngvalid.c +++ b/pngvalid.c @@ -2335,6 +2335,39 @@ progressive_row(png_structp pp, png_bytep new_row, png_uint_32 y, int pass) } } +static void +sequential_row(standard_display *dp, png_structp pp, png_infop pi, + PNG_CONST png_bytep pImage, PNG_CONST png_bytep pDisplay) +{ + PNG_CONST int npasses = dp->npasses; + PNG_CONST png_uint_32 h = dp->h; + PNG_CONST size_t cbRow = dp->cbRow; + int pass; + + for (pass=1; pass <= npasses; ++pass) + { + png_uint_32 y; + png_bytep pRow1 = pImage; + png_bytep pRow2 = pDisplay; + + for (y=0; yprogressive ? "progressive reader" : "sequential reader"); /* Introduce the correct read function. */ if (d.ps->progressive) @@ -2450,32 +2484,16 @@ standard_test(png_store* PNG_CONST psIn, png_byte PNG_CONST colour_typeIn, * values. */ { - PNG_CONST size_t cbImage = d.cbRow * d.h; PNG_CONST png_bytep pImage = d.ps->image; + PNG_CONST png_bytep pDisplay = pImage + d.cbRow * d.h; - { - PNG_CONST int npasses = d.npasses; - PNG_CONST png_uint_32 h = d.h; - PNG_CONST size_t cbRow = d.cbRow; - int pass; - - for (pass=1; pass <= npasses; ++pass) - { - png_uint_32 y; - png_byte *row; - - for (y=0, row=pImage; ythis.progressive = !pm->this.progressive; + standard_test(&pm->this, colour_type, DEPTH(bdlo), interlace_type); + + if (fail(pm)) + return 0; + + pm->this.progressive = !pm->this.progressive; standard_test(&pm->this, colour_type, DEPTH(bdlo), interlace_type); if (fail(pm)) @@ -2730,7 +2756,7 @@ gamma_display_init(gamma_display *dp, png_modifier *pm, png_byte colour_type, static void gamma_info_imp(gamma_display *dp, png_structp pp, png_infop pi) { - /* Reused the standard stuff as appropriate. */ + /* Reuse the standard stuff as appropriate. */ standard_info_part1(&dp->this, pp, pi); /* If requested strip 16 to 8 bits - this is handled automagically below @@ -3084,30 +3110,9 @@ gamma_test(png_modifier *pmIn, PNG_CONST png_byte colour_typeIn, /* Process the 'info' requirements. only one image is generated */ gamma_info_imp(&d, pp, pi); - /* And finally read and validate the image. */ - { - PNG_CONST png_bytep pImage = d.this.ps->image; + sequential_row(&d.this, pp, pi, NULL, d.this.ps->image); - { - PNG_CONST int npasses = d.this.npasses; - PNG_CONST png_uint_32 h = d.this.h; - PNG_CONST size_t cbRow = d.this.cbRow; - int pass; - - for (pass=1; pass <= npasses; ++pass) - { - png_uint_32 y; - png_byte *row; - - for (y=0, row=pImage; yimage); } modifier_reset(d.pm);