From 2799bf9a4f334f2202c074fb1e492d72ca97ae78 Mon Sep 17 00:00:00 2001 From: Glenn Randers-Pehrson Date: Sat, 27 Sep 2014 18:49:42 -0500 Subject: [PATCH] [libpng17] Merge recent changes to the manual and pngrutil.c from libpng-1.6.14beta04. --- INSTALL | 34 ++++++++++++++++++++--------- libpng-manual.txt | 47 +++++++++++++++++++++++++++------------- libpng.3 | 55 +++++++++++++++++++++++++++++++---------------- pngrutil.c | 28 ++++++++++++------------ 4 files changed, 106 insertions(+), 58 deletions(-) diff --git a/INSTALL b/INSTALL index 49e932919..1b66d89ac 100644 --- a/INSTALL +++ b/INSTALL @@ -28,7 +28,9 @@ On Unix/Linux and similar systems, you can simply type make check make install -and ignore the rest of this document. +and ignore the rest of this document. "/path" is the path to the directory +where you want to install the libpng "lib", "include", and "bin" +subdirectories. II. Rebuilding the configure scripts @@ -64,8 +66,8 @@ Or you can use one of the "projects" in the "projects" directory. Before installing libpng, you must first install zlib, if it is not already on your system. zlib can usually be found -wherever you got libpng. zlib can be placed in another directory, -at the same level as libpng. +wherever you got libpng; otherwise go to http://zlib.net. You can place +zlib in in the same directory as libpng or in another directory. If your system already has a preinstalled zlib you will still need to have access to the zlib.h and zconf.h include files that @@ -93,6 +95,10 @@ If you want to use "cmake" (see www.cmake.org), type make make install +As when using the simple configure method described above, "/path" points to +the installation directory where you want to put the libpng "lib", "include", +and "bin" subdirectories. + V. Directory structure You can rename the directories that you downloaded (they @@ -322,11 +328,12 @@ unmodified, default, libpng API and thus would probably fail to link. These mechanisms still work in the configure build and in any makefile build that builds pnglibconf.h, although the feature selection macros have changed somewhat as described above. In 1.5.0, however, pngusr.h is -processed only once, when the exported header file pnglibconf.h is built. -pngconf.h no longer includes pngusr.h, therefore pngusr.h is ignored after the -build of pnglibconf.h and it is never included in an application build. +processed only once, at the time the exported header file pnglibconf.h is +built. pngconf.h no longer includes pngusr.h; therefore, pngusr.h is ignored +after the build of pnglibconf.h and it is never included in an application +build. -The rarely used alternative of adding a list of feature macros to the +The formerly used alternative of adding a list of feature macros to the CPPFLAGS setting in the build also still works; however, the macros will be copied to pnglibconf.h and this may produce macro redefinition warnings when the individual C files are compiled. @@ -342,12 +349,19 @@ functioning awk called 'nawk'. Configuration options are now documented in scripts/pnglibconf.dfa. This file also includes dependency information that ensures a configuration is -consistent; that is, if a feature is switched off dependent features are -also removed. As a recommended alternative to using feature macros in +consistent; that is, if a feature is switched off, dependent features are +also switched off. As a recommended alternative to using feature macros in pngusr.h a system builder may also define equivalent options in pngusr.dfa (or, indeed, any file) and add that to the configuration by setting DFA_XTRA to the file name. The makefiles in contrib/pngminim illustrate -how to do this, and a case where pngusr.h is still required. +how to do this, and also illustrate a case where pngusr.h is still required. + +After you have built libpng, the definitions that were recorded in +pnglibconf.h are available to your application (pnglibconf.h is included +in png.h and gets installed alongside png.h and pngconf.h in your +$PREFIX/include directory). Do not edit pnglibconf.h after you have built +libpng, because than the settings would not accurately reflect the settings +that were used to build libpng. XV. Configuring libpng for multiprocessing diff --git a/libpng-manual.txt b/libpng-manual.txt index ee7b533c1..f8d6d6899 100644 --- a/libpng-manual.txt +++ b/libpng-manual.txt @@ -1,6 +1,6 @@ libpng-manual.txt - A description on how to use and modify libpng - libpng version 1.7.0beta36 - August 6, 2014 + libpng version 1.7.0beta36 - September 27, 2014 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2014 Glenn Randers-Pehrson @@ -11,7 +11,7 @@ libpng-manual.txt - A description on how to use and modify libpng Based on: - libpng versions 0.97, January 1998, through 1.7.0beta36 - August 6, 2014 + libpng versions 0.97, January 1998, through 1.7.0beta36 - September 27, 2014 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2014 Glenn Randers-Pehrson @@ -5036,11 +5036,27 @@ Error detection in some chunks has improved; in particular the iCCP chunk reader now does pretty complete validation of the basic format. Some bad profiles that were previously accepted are now accepted with a warning or rejected, depending upon the png_set_benign_errors() setting, in particular the -very old broken Microsoft/HP 3144-byte sRGB profile. The PNG spec requirement -that only grayscale profiles may appear in images with color type 0 or 4 and -that even if the image only contains gray pixels, only RGB profiles may appear -in images with color type 2, 3, or 6, is now enforced. The sRGB chunk -is allowed to appear in images with any color type. +very old broken Microsoft/HP 3144-byte sRGB profile. Starting with +libpng-1.6.11, recognizing and checking sRGB profiles can be avoided by +means of + + #if defined(PNG_SKIP_sRGB_CHECK_PROFILE) && \ + defined(PNG_SET_OPTION_SUPPORTED) + png_set_option(png_ptr, PNG_SKIP_sRGB_CHECK_PROFILE, + PNG_OPTION_ON); + #endif + +It's not a good idea to do this if you are using the "simplified API", +which needs to be able to recognize an sRGB profile conveyed via the iCCP +chunk. + +The PNG spec requirement that only grayscale profiles may appear in images +with color type 0 or 4 and that even if the image only contains gray pixels, +only RGB profiles may appear in images with color type 2, 3, or 6, is now +enforced. The sRGB chunk is allowed to appear in images with any color type +and is interpreted by libpng to convey a one-tracer-curve gray profile or a +three-tracer-curve RGB profile as appropriate. + Prior to libpng-1.6.0 a warning would be issued if the iTXt chunk contained an empty language field or an empty translated keyword. Both of these @@ -5239,12 +5255,15 @@ We mark all non-exported functions with "/* PRIVATE */"": } The prototypes for non-exported functions (except for those in -pngtest) appear in -pngpriv.h -above the comment that says +pngtest) appear in pngpriv.h above the comment that says /* Maintainer: Put new private prototypes here ^ */ +To avoid polluting the global namespace, the names of all exported +functions and variables begin with "png_", and all publicly visible C +preprocessor macros begin with "PNG". We request that applications that +use libpng *not* begin any of their own symbols with either of these strings. + We put a space after the "sizeof" operator and we omit the optional parentheses around its argument when the argument is an expression, not a type name, and we always enclose the @@ -5256,10 +5275,8 @@ sizeof operator, with its argument, in parentheses: Prior to libpng-1.6.0 we used a "png_sizeof()" macro, formatted as though it were a function. -To avoid polluting the global namespace, the names of all exported -functions and variables begin with "png_", and all publicly visible C -preprocessor macros begin with "PNG". We request that applications that -use libpng *not* begin any of their own symbols with either of these strings. +Control keywords if, for, while, and switch are always followed by a space +to distinguish them from function calls, which have no trailing space. We put a space after each comma and after each semicolon in "for" statements, and we put spaces before and after each @@ -5292,7 +5309,7 @@ Other rules can be inferred by inspecting the libpng source. XVII. Y2K Compliance in libpng -August 6, 2014 +September 27, 2014 Since the PNG Development group is an ad-hoc body, we can't make an official declaration. diff --git a/libpng.3 b/libpng.3 index c5df67b52..1d38c46c4 100644 --- a/libpng.3 +++ b/libpng.3 @@ -1,4 +1,4 @@ -.TH LIBPNG 3 "August 6, 2014" +.TH LIBPNG 3 "September 27, 2014" .SH NAME libpng \- Portable Network Graphics (PNG) Reference Library 1.7.0beta36 .SH SYNOPSIS @@ -494,7 +494,7 @@ Following is a copy of the libpng-manual.txt file that accompanies libpng. .SH LIBPNG.TXT libpng-manual.txt - A description on how to use and modify libpng - libpng version 1.7.0beta36 - August 6, 2014 + libpng version 1.7.0beta36 - September 27, 2014 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2014 Glenn Randers-Pehrson @@ -505,7 +505,7 @@ libpng-manual.txt - A description on how to use and modify libpng Based on: - libpng versions 0.97, January 1998, through 1.7.0beta36 - August 6, 2014 + libpng versions 0.97, January 1998, through 1.7.0beta36 - September 27, 2014 Updated and distributed by Glenn Randers-Pehrson Copyright (c) 1998-2014 Glenn Randers-Pehrson @@ -5530,11 +5530,27 @@ Error detection in some chunks has improved; in particular the iCCP chunk reader now does pretty complete validation of the basic format. Some bad profiles that were previously accepted are now accepted with a warning or rejected, depending upon the png_set_benign_errors() setting, in particular the -very old broken Microsoft/HP 3144-byte sRGB profile. The PNG spec requirement -that only grayscale profiles may appear in images with color type 0 or 4 and -that even if the image only contains gray pixels, only RGB profiles may appear -in images with color type 2, 3, or 6, is now enforced. The sRGB chunk -is allowed to appear in images with any color type. +very old broken Microsoft/HP 3144-byte sRGB profile. Starting with +libpng-1.6.11, recognizing and checking sRGB profiles can be avoided by +means of + + #if defined(PNG_SKIP_sRGB_CHECK_PROFILE) && \ + defined(PNG_SET_OPTION_SUPPORTED) + png_set_option(png_ptr, PNG_SKIP_sRGB_CHECK_PROFILE, + PNG_OPTION_ON); + #endif + +It's not a good idea to do this if you are using the "simplified API", +which needs to be able to recognize an sRGB profile conveyed via the iCCP +chunk. + +The PNG spec requirement that only grayscale profiles may appear in images +with color type 0 or 4 and that even if the image only contains gray pixels, +only RGB profiles may appear in images with color type 2, 3, or 6, is now +enforced. The sRGB chunk is allowed to appear in images with any color type +and is interpreted by libpng to convey a one-tracer-curve gray profile or a +three-tracer-curve RGB profile as appropriate. + Prior to libpng-1.6.0 a warning would be issued if the iTXt chunk contained an empty language field or an empty translated keyword. Both of these @@ -5733,12 +5749,15 @@ We mark all non-exported functions with "/* PRIVATE */"": } The prototypes for non-exported functions (except for those in -pngtest) appear in -pngpriv.h -above the comment that says +pngtest) appear in pngpriv.h above the comment that says /* Maintainer: Put new private prototypes here ^ */ +To avoid polluting the global namespace, the names of all exported +functions and variables begin with "png_", and all publicly visible C +preprocessor macros begin with "PNG". We request that applications that +use libpng *not* begin any of their own symbols with either of these strings. + We put a space after the "sizeof" operator and we omit the optional parentheses around its argument when the argument is an expression, not a type name, and we always enclose the @@ -5750,10 +5769,8 @@ sizeof operator, with its argument, in parentheses: Prior to libpng-1.6.0 we used a "png_sizeof()" macro, formatted as though it were a function. -To avoid polluting the global namespace, the names of all exported -functions and variables begin with "png_", and all publicly visible C -preprocessor macros begin with "PNG". We request that applications that -use libpng *not* begin any of their own symbols with either of these strings. +Control keywords if, for, while, and switch are always followed by a space +to distinguish them from function calls, which have no trailing space. We put a space after each comma and after each semicolon in "for" statements, and we put spaces before and after each @@ -5786,7 +5803,7 @@ Other rules can be inferred by inspecting the libpng source. .SH XVII. Y2K Compliance in libpng -August 6, 2014 +September 27, 2014 Since the PNG Development group is an ad-hoc body, we can't make an official declaration. @@ -6056,7 +6073,7 @@ possible without all of you. Thanks to Frank J. T. Wojcik for helping with the documentation. -Libpng version 1.7.0beta36 - August 6, 2014: +Libpng version 1.7.0beta36 - September 27, 2014: Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc. Currently maintained by Glenn Randers-Pehrson (glennrp at users.sourceforge.net). @@ -6079,7 +6096,7 @@ this sentence. This code is released under the libpng license. -libpng versions 1.2.6, August 15, 2004, through 1.7.0beta36, August 6, 2014, are +libpng versions 1.2.6, August 15, 2004, through 1.7.0beta36, September 27, 2014, are Copyright (c) 2004,2006-2007 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 @@ -6178,7 +6195,7 @@ certification mark of the Open Source Initiative. Glenn Randers-Pehrson glennrp at users.sourceforge.net -August 6, 2014 +September 27, 2014 .\" end of man page diff --git a/pngrutil.c b/pngrutil.c index 2a9fc896b..3f1148275 100644 --- a/pngrutil.c +++ b/pngrutil.c @@ -501,7 +501,7 @@ png_inflate(png_structrp png_ptr, png_uint_32 owner, int finish, * end of the output buffer. */ ret = inflate(&png_ptr->zstream, avail_out > 0 ? Z_NO_FLUSH : - (finish ? Z_FINISH : Z_SYNC_FLUSH)); + (finish ? Z_FINISH : Z_SYNC_FLUSH)); } while (ret == Z_OK); /* For safety kill the local buffer pointer now */ @@ -996,7 +996,7 @@ png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) */ #ifdef PNG_READ_tRNS_SUPPORTED if (png_ptr->num_trans > 0 || - (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS) != 0)) + (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS) != 0)) { /* Cancel this because otherwise it would be used if the transforms * require it. Don't cancel the 'valid' flag because this would prevent @@ -1304,9 +1304,9 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) * chunk is just ignored, so does not invalidate the color space. An * alternative is to set the 'invalid' flags at the start of this routine * and only clear them in they were not set before and all the tests pass. - * The minimum 'deflate' stream is assumed to be just the 2 byte header and 4 - * byte checksum. The keyword must be one character and there is a - * terminator (0) byte and the compression method. + * The minimum 'deflate' stream is assumed to be just the 2 byte header and + * 4 byte checksum. The keyword must be at least one character and there is + * a terminator (0) byte and the compression method. */ if (length < 9) { @@ -1581,7 +1581,7 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) if (--png_ptr->user_chunk_cache_max == 1) { /* Warn the first time */ - png_chunk_benign_error(png_ptr, "chunk cache full"); + png_chunk_benign_error(png_ptr, "no space in chunk cache"); png_crc_finish(png_ptr, length); return; } @@ -2371,7 +2371,7 @@ png_handle_tEXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) if (--png_ptr->user_chunk_cache_max == 1) { png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "chunk cache full"); + png_chunk_benign_error(png_ptr, "no space in chunk cache"); return; } } @@ -2450,7 +2450,7 @@ png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) if (--png_ptr->user_chunk_cache_max == 1) { png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "chunk cache full"); + png_chunk_benign_error(png_ptr, "no space in chunk cache"); return; } } @@ -2559,7 +2559,7 @@ png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) if (--png_ptr->user_chunk_cache_max == 1) { png_crc_finish(png_ptr, length); - png_chunk_benign_error(png_ptr, "chunk cache full"); + png_chunk_benign_error(png_ptr, "no space in chunk cache"); return; } } @@ -2628,7 +2628,7 @@ png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) /* prefix_length should now be at the trailing '\0' of the translated * keyword, but it may already be over the end. None of this arithmetic * can overflow because chunks are at most 2^31 bytes long, but on 16-bit - * systems the available allocaton may overflow. + * systems the available allocation may overflow. */ ++prefix_length; @@ -2660,7 +2660,7 @@ png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length) buffer[uncompressed_length+prefix_length] = 0; - if (compressed != 0) + if (compressed == 0) text.compression = PNG_ITXT_COMPRESSION_NONE; else @@ -2884,7 +2884,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr, { case 2: png_ptr->user_chunk_cache_max = 1; - png_chunk_benign_error(png_ptr, "chunk cache full"); + png_chunk_benign_error(png_ptr, "no space in chunk cache"); /* FALL THROUGH */ case 1: /* NOTE: prior to 1.6.0 this case resulted in an unknown critical @@ -3165,7 +3165,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) #endif /* !PNG_USE_COMPILE_TIME_MASKS */ /* Use the appropriate mask to copy the required bits. In some cases - * the byte mask will be 0 or 0xff, optimize these cases. row_width is + * the byte mask will be 0 or 0xff; optimize these cases. row_width is * the number of pixels, but the code copies bytes, so it is necessary * to special case the end. */ @@ -3304,7 +3304,7 @@ png_combine_row(png_const_structrp png_ptr, png_bytep dp, int display) /* This can only be the RGB case, so each copy is exactly one * pixel and it is not necessary to check for a partial copy. */ - for(;;) + for (;;) { dp[0] = sp[0], dp[1] = sp[1], dp[2] = sp[2];