From 4daae301744199a01f2c506a239b8d20576e6b37 Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Thu, 6 Oct 2011 21:37:47 -0500 Subject: [PATCH] [libpng15] #ifdef out png_progressive_combine_row() when interlacing is not supported. --- example.c | 9 ++++++++- png.h | 12 +++++++----- pngpread.c | 21 ++++++++++++++++----- pngvalid.c | 15 ++++++++++++++- 4 files changed, 45 insertions(+), 12 deletions(-) diff --git a/example.c b/example.c index c0d27f487..fc91f4a87 100644 --- a/example.c +++ b/example.c @@ -2,7 +2,7 @@ #if 0 /* in case someone actually tries to compile this */ /* example.c - an example of using libpng - * Last changed in libpng 1.5.4 [July 7, 2011] + * Last changed in libpng 1.5.6 [(PENDING RELEASE)] * This file has been placed in the public domain by the authors. * Maintained 1998-2011 Glenn Randers-Pehrson * Maintained 1996, 1997 Andreas Dilger) @@ -341,11 +341,16 @@ void read_png(FILE *fp, unsigned int sig_read) /* File is already open */ /* Add filler (or alpha) byte (before/after each RGB triplet) */ png_set_filler(png_ptr, 0xff, PNG_FILLER_AFTER); +#ifdef PNG_READ_INTERLACING_SUPPORTED /* Turn on interlace handling. REQUIRED if you are not using * png_read_image(). To see how to handle interlacing passes, * see the png_read_row() method below: */ number_passes = png_set_interlace_handling(png_ptr); +#else + number_passes = 1; +#endif /* PNG_READ_INTERLACING_SUPPORTED */ + /* Optional call to gamma correct and add the background to the palette * and update info structure. REQUIRED if you are expecting libpng to @@ -527,6 +532,7 @@ row_callback(png_structp png_ptr, png_bytep new_row, */ png_bytep old_row = ((png_bytep *)our_data)[row_num]; +#ifdef PNG_READ_INTERLACING_SUPPORTED /* If both rows are allocated then copy the new row * data to the corresponding row data. */ @@ -555,6 +561,7 @@ row_callback(png_structp png_ptr, png_bytep new_row, * to pass the current row as new_row, and the function will combine * the old row and the new row. */ +#endif /* PNG_READ_INTERLACING_SUPPORTED */ } end_callback(png_structp png_ptr, png_infop info) diff --git a/png.h b/png.h index c01967338..111a788b5 100644 --- a/png.h +++ b/png.h @@ -1,7 +1,7 @@ /* png.h - header file for PNG reference library * - * libpng version 1.5.6beta05 - October 5, 2011 + * libpng version 1.5.6beta05 - October 7, 2011 * Copyright (c) 1998-2011 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.) @@ -11,7 +11,7 @@ * Authors and maintainers: * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger - * libpng versions 0.97, January 1998, through 1.5.6beta05 - October 5, 2011: Glenn + * libpng versions 0.97, January 1998, through 1.5.6beta05 - October 7, 2011: Glenn * See also "Contributing Authors", below. * * Note about libpng version numbers: @@ -192,7 +192,7 @@ * * This code is released under the libpng license. * - * libpng versions 1.2.6, August 15, 2004, through 1.5.6beta05, October 5, 2011, are + * libpng versions 1.2.6, August 15, 2004, through 1.5.6beta05, October 7, 2011, are * Copyright (c) 2004, 2006-2011 Glenn Randers-Pehrson, and are * distributed according to the same disclaimer and license as libpng-1.2.5 * with the following individual added to the list of Contributing Authors: @@ -304,7 +304,7 @@ * Y2K compliance in libpng: * ========================= * - * October 5, 2011 + * October 7, 2011 * * Since the PNG Development group is an ad-hoc body, we can't make * an official declaration. @@ -367,7 +367,7 @@ /* Version information for png.h - this should match the version in png.c */ #define PNG_LIBPNG_VER_STRING "1.5.6beta05" #define PNG_HEADER_VERSION_STRING \ - " libpng version 1.5.6beta05 - October 5, 2011\n" + " libpng version 1.5.6beta05 - October 7, 2011\n" #define PNG_LIBPNG_VER_SONUM 15 #define PNG_LIBPNG_VER_DLLNUM 15 @@ -1831,6 +1831,7 @@ PNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structp, int save)); */ PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structp)); +#ifdef PNG_READ_INTERLACING_SUPPORTED /* Function that combines rows. 'new_row' is a flag that should come from * the callback and be non-NULL if anything needs to be done; the library * stores its own version of the new data internally and ignores the passed @@ -1838,6 +1839,7 @@ PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structp)); */ PNG_EXPORT(93, void, png_progressive_combine_row, (png_structp png_ptr, png_bytep old_row, png_const_bytep new_row)); +#endif /* PNG_READ_INTERLACING_SUPPORTED */ #endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ PNG_EXPORTA(94, png_voidp, png_malloc, diff --git a/pngpread.c b/pngpread.c index 3c666dcbe..225fbdad6 100644 --- a/pngpread.c +++ b/pngpread.c @@ -239,8 +239,16 @@ png_push_read_chunk(png_structp png_ptr, png_infop info_ptr) chunk_name = png_ptr->chunk_name; if (chunk_name == png_IDAT) + { + /* This is here above the if/else case statement below because if the + * unknown handling marks 'IDAT' as unknown then the IDAT handling case is + * completely skipped. + * + * TODO: there must be a better way of doing this. + */ if (png_ptr->mode & PNG_AFTER_IDAT) png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT; + } if (chunk_name == png_IHDR) { @@ -1795,19 +1803,22 @@ png_push_have_row(png_structp png_ptr, png_bytep row) (int)png_ptr->pass); } +#ifdef PNG_READ_INTERLACING_SUPPORTED void PNGAPI png_progressive_combine_row (png_structp png_ptr, png_bytep old_row, png_const_bytep new_row) { - static PNG_CONST png_byte FARDATA png_pass_dsp_mask[7] = - {0xff, 0x0f, 0xff, 0x33, 0xff, 0x55, 0xff}; - if (png_ptr == NULL) return; - if (new_row != NULL) /* new_row must == png_ptr->row_buf here. */ - png_combine_row(png_ptr, old_row, png_pass_dsp_mask[png_ptr->pass]); + /* new_row is a flag here - if it is NULL then the app callback was called + * from an empty row (see the calls to png_struct::row_fn below), otherwise + * it must be png_ptr->row_buf+1 + */ + if (new_row != NULL) + png_combine_row(png_ptr, old_row, 1/*display*/); } +#endif /* PNG_READ_INTERLACING_SUPPORTED */ void PNGAPI png_set_progressive_read_fn(png_structp png_ptr, png_voidp progressive_ptr, diff --git a/pngvalid.c b/pngvalid.c index ef915c567..fe798c8d3 100644 --- a/pngvalid.c +++ b/pngvalid.c @@ -4330,6 +4330,7 @@ progressive_row(png_structp pp, png_bytep new_row, png_uint_32 y, int pass) row = store_image_row(dp->ps, pp, 0, y); +#ifdef PNG_READ_INTERLACING_SUPPORTED /* Combine the new row into the old: */ if (dp->do_interlace) { @@ -4344,6 +4345,7 @@ progressive_row(png_structp pp, png_bytep new_row, png_uint_32 y, int pass) PNG_ROW_IN_INTERLACE_PASS(y, pass) && PNG_PASS_COLS(dp->w, pass) > 0) png_error(pp, "missing row in progressive de-interlacing"); +#endif /* PNG_READ_INTERLACING_SUPPORTED */ } static void @@ -4549,6 +4551,8 @@ standard_test(png_store* PNG_CONST psIn, png_uint_32 PNG_CONST id, */ if (!d.speed) standard_image_validate(&d, pp, 0, 1); + else + d.ps->validated = 1; } } @@ -5488,7 +5492,10 @@ transform_end(png_structp pp, png_infop pi) transform_display *dp = voidcast(transform_display*, png_get_progressive_ptr(pp)); - transform_image_validate(dp, pp, pi); + if (!dp->this.speed) + transform_image_validate(dp, pp, pi); + else + dp->this.ps->validated = 1; } /* A single test run. */ @@ -5561,6 +5568,8 @@ transform_test(png_modifier *pmIn, PNG_CONST png_uint_32 idIn, if (!d.this.speed) transform_image_validate(&d, pp, pi); + else + d.this.ps->validated = 1; } modifier_reset(d.pm); @@ -8080,6 +8089,8 @@ gamma_end(png_structp pp, png_infop pi) if (!dp->this.speed) gamma_image_validate(dp, pp, pi); + else + dp->this.ps->validated = 1; } /* A single test run checking a gamma transformation. @@ -8161,6 +8172,8 @@ gamma_test(png_modifier *pmIn, PNG_CONST png_byte colour_typeIn, if (!d.this.speed) gamma_image_validate(&d, pp, pi); + else + d.this.ps->validated = 1; } modifier_reset(d.pm);