summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--png.c27
-rw-r--r--png.h37
-rw-r--r--pngconf.h3
-rw-r--r--pngcrush.c269
-rw-r--r--pngcrush.h2
-rw-r--r--pnglibconf.h4
-rw-r--r--pngpread.c197
-rw-r--r--pngpriv.h2
-rw-r--r--pngread.c2
-rw-r--r--pngrtran.c2
-rw-r--r--pngrutil.c89
-rw-r--r--pngset.c14
-rw-r--r--pngtrans.c2
-rw-r--r--pngwrite.c37
-rw-r--r--pngwutil.c27
15 files changed, 346 insertions, 368 deletions
diff --git a/png.c b/png.c
index 8d8841fd9..ea5a92e6d 100644
--- a/png.c
+++ b/png.c
@@ -1,7 +1,7 @@
/* png.c - location for general purpose libpng functions
*
- * Last changed in libpng 1.6.12 [June 12, 2014]
+ * Last changed in libpng 1.6.14 [October 23, 2014]
* Copyright (c) 1998-2014 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.)
@@ -14,7 +14,7 @@
#include "pngpriv.h"
/* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_6_13 Your_png_h_is_not_version_1_6_13;
+typedef png_libpng_version_1_6_14 Your_png_h_is_not_version_1_6_14;
/* Tells libpng that we have already handled the first "num_bytes" bytes
* of the PNG file signature. If the PNG data is embedded into another
@@ -773,13 +773,13 @@ png_get_copyright(png_const_structrp png_ptr)
#else
# ifdef __STDC__
return PNG_STRING_NEWLINE \
- "libpng version 1.6.13 - August 21, 2014" PNG_STRING_NEWLINE \
+ "libpng version 1.6.14 - October 23, 2014" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2014 Glenn Randers-Pehrson" PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
"Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc." \
PNG_STRING_NEWLINE;
# else
- return "libpng version 1.6.13 - August 21, 2014\
+ return "libpng version 1.6.14 - October 23, 2014\
Copyright (c) 1998-2014 Glenn Randers-Pehrson\
Copyright (c) 1996-1997 Andreas Dilger\
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.";
@@ -2219,10 +2219,12 @@ png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
#endif
unsigned int i;
+#ifdef PNG_SET_OPTION_SUPPORTED
/* First see if PNG_SKIP_sRGB_CHECK_PROFILE has been set to "on" */
if (((png_ptr->options >> PNG_SKIP_sRGB_CHECK_PROFILE) & 3) ==
PNG_OPTION_ON)
return 0;
+#endif
for (i=0; i < (sizeof png_sRGB_checks) / (sizeof png_sRGB_checks[0]); ++i)
{
@@ -3569,8 +3571,8 @@ png_log16bit(png_uint_32 x)
* each case only the low 16 bits are relevant - the fraction - since the
* integer bits (the top 4) simply determine a shift.
*
- * The worst case is the 16-bit distinction between 65535 and 65534, this
- * requires perhaps spurious accuracty in the decoding of the logarithm to
+ * The worst case is the 16-bit distinction between 65535 and 65534. This
+ * requires perhaps spurious accuracy in the decoding of the logarithm to
* distinguish log2(65535/65534.5) - 10^-5 or 17 bits. There is little chance
* of getting this accuracy in practice.
*
@@ -3658,7 +3660,7 @@ png_exp8bit(png_fixed_point lg2)
/* Get a 32-bit value: */
png_uint_32 x = png_exp(lg2);
- /* Convert the 32-bit value to 0..255 by multiplying by 256-1, note that the
+ /* Convert the 32-bit value to 0..255 by multiplying by 256-1. Note that the
* second, rounding, step can't overflow because of the first, subtraction,
* step.
*/
@@ -3840,7 +3842,7 @@ png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable,
/* 'num' is the number of tables and also the number of low bits of low
* bits of the input 16-bit value used to select a table. Each table is
- * itself index by the high 8 bits of the value.
+ * itself indexed by the high 8 bits of the value.
*/
for (i = 0; i < num; i++)
table[i] = (png_uint_16p)png_malloc(png_ptr,
@@ -3892,7 +3894,7 @@ png_build_16to8_table(png_structrp png_ptr, png_uint_16pp *ptable,
/* Build a single 8-bit table: same as the 16-bit case but much simpler (and
* typically much faster). Note that libpng currently does no sBIT processing
- * (apparently contrary to the spec) so a 256 entry table is always generated.
+ * (apparently contrary to the spec) so a 256-entry table is always generated.
*/
static void
png_build_8bit_table(png_structrp png_ptr, png_bytepp ptable,
@@ -4033,7 +4035,7 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth)
* Where 'iv' is the input color value and 'ov' is the output value -
* pow(iv, gamma).
*
- * Thus the gamma table consists of up to 256 256 entry tables. The table
+ * Thus the gamma table consists of up to 256 256-entry tables. The table
* is selected by the (8-gamma_shift) most significant of the low 8 bits of
* the color value then indexed by the upper 8 bits:
*
@@ -4141,7 +4143,7 @@ png_set_option(png_structrp png_ptr, int option, int onoff)
*
* error: -0.513727 - 0.607759, 308 (0.469978%) of readings inexact
*
- * In all cases the inexact readings are off by one.
+ * In all cases the inexact readings are only off by one.
*/
#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
@@ -4181,8 +4183,7 @@ const png_uint_16 png_sRGB_table[256] =
57105,57646,58190,58737,59287,59840,60396,60955,
61517,62082,62650,63221,63795,64372,64952,65535
};
-
-#endif /* simplified read only */
+#endif /* PNG_SIMPLIFIED_READ_SUPPORTED */
/* The base/delta tables are required for both read and write (but currently
* only the simplified versions.)
diff --git a/png.h b/png.h
index 0071c1686..73ff4c6a0 100644
--- a/png.h
+++ b/png.h
@@ -1,7 +1,7 @@
/* png.h - header file for PNG reference library
*
- * libpng version 1.6.13 - August 21, 2014
+ * libpng version 1.6.14 - October 23, 2014
* Copyright (c) 1998-2014 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.6.13 - August 21, 2014: Glenn
+ * libpng versions 0.97, January 1998, through 1.6.14 - October 23, 2014: Glenn
* See also "Contributing Authors", below.
*
* Note about libpng version numbers:
@@ -203,6 +203,9 @@
* 1.6.13beta01-04 16 10613 16.so.16.13[.0]
* 1.6.13rc01-02 16 10613 16.so.16.13[.0]
* 1.6.13 16 10613 16.so.16.13[.0]
+ * 1.6.14beta01-07 16 10614 16.so.16.14[.0]
+ * 1.6.14rc01-02 16 10614 16.so.16.14[.0]
+ * 1.6.14 16 10614 16.so.16.14[.0]
*
* Henceforth the source version will match the shared-library major
* and minor numbers; the shared-library major version number will be
@@ -234,7 +237,7 @@
*
* This code is released under the libpng license.
*
- * libpng versions 1.2.6, August 15, 2004, through 1.6.13, August 21, 2014, are
+ * libpng versions 1.2.6, August 15, 2004, through 1.6.14, October 23, 2014, are
* Copyright (c) 2004, 2006-2014 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:
@@ -346,13 +349,13 @@
* Y2K compliance in libpng:
* =========================
*
- * August 21, 2014
+ * October 23, 2014
*
* Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration.
*
* This is your unofficial assurance that libpng from version 0.71 and
- * upward through 1.6.13 are Y2K compliant. It is my belief that
+ * upward through 1.6.14 are Y2K compliant. It is my belief that
* earlier versions were also Y2K compliant.
*
* Libpng only has two year fields. One is a 2-byte unsigned integer
@@ -414,9 +417,9 @@
*/
/* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.6.13"
+#define PNG_LIBPNG_VER_STRING "1.6.14"
#define PNG_HEADER_VERSION_STRING \
- " libpng version 1.6.13 - August 21, 2014\n"
+ " libpng version 1.6.14 - October 23, 2014\n"
#define PNG_LIBPNG_VER_SONUM 16
#define PNG_LIBPNG_VER_DLLNUM 16
@@ -424,7 +427,7 @@
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 6
-#define PNG_LIBPNG_VER_RELEASE 13
+#define PNG_LIBPNG_VER_RELEASE 14
/* This should match the numeric part of the final component of
* PNG_LIBPNG_VER_STRING, omitting any leading zero:
@@ -455,7 +458,7 @@
* version 1.0.0 was mis-numbered 100 instead of 10000). From
* version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release
*/
-#define PNG_LIBPNG_VER 10613 /* 1.6.13 */
+#define PNG_LIBPNG_VER 10614 /* 1.6.14 */
/* Library configuration: these options cannot be changed after
* the library has been built.
@@ -560,7 +563,7 @@ extern "C" {
/* This triggers a compiler error in png.c, if png.c and png.h
* do not agree upon the version number.
*/
-typedef char* png_libpng_version_1_6_13;
+typedef char* png_libpng_version_1_6_14;
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
*
@@ -2745,6 +2748,8 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
# endif
#endif
+#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) || \
+ defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
/*******************************************************************************
* SIMPLIFIED API
*******************************************************************************
@@ -2816,7 +2821,7 @@ typedef struct
# define PNG_IMAGE_WARNING 1
# define PNG_IMAGE_ERROR 2
/*
- * The result is a two bit code such that a value more than 1 indicates
+ * The result is a two-bit code such that a value more than 1 indicates
* a failure in the API just called:
*
* 0 - no warning or error
@@ -3197,6 +3202,7 @@ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
/*******************************************************************************
* END OF SIMPLIFIED API
******************************************************************************/
+#endif /* PNG_SIMPLIFIED_{READ|WRITE}_SUPPORTED */
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
PNG_EXPORT(242, void, png_set_check_for_invalid_index,
@@ -3244,19 +3250,18 @@ PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr,
PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,
int onoff));
-#endif
+#endif /* PNG_SET_OPTION_SUPPORTED */
/*******************************************************************************
* END OF HARDWARE AND SOFTWARE OPTIONS
******************************************************************************/
-/* Maintainer: Put new public prototypes here ^, in libpng.3, and project
- * defs, scripts/pnglibconf.h, and scripts/pnglibconf.h.prebuilt
+/* Maintainer: Put new public prototypes here ^, in libpng.3, in project
+ * defs, and in scripts/symbols.def.
*/
/* The last ordinal number (this is the *last* one already used; the next
- * one to use is one more than this.) Maintainer, remember to add an entry to
- * scripts/symbols.def as well.
+ * one to use is one more than this.)
*/
#ifdef PNG_EXPORT_LAST_ORDINAL
PNG_EXPORT_LAST_ORDINAL(244);
diff --git a/pngconf.h b/pngconf.h
index b60e919c9..8541d4bad 100644
--- a/pngconf.h
+++ b/pngconf.h
@@ -1,7 +1,7 @@
/* pngconf.h - machine configurable file for libpng
*
- * libpng version 1.6.13 - August 21, 2014
+ * libpng version 1.6.14 - October 23, 2014
*
* Copyright (c) 1998-2014 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@@ -11,6 +11,7 @@
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*
+ *
* This file has been modified, by Glenn Randers-Pehrson, from the original
* libpng distribution by adding a line reading
* #include "pngcrush.h"
diff --git a/pngcrush.c b/pngcrush.c
index e7f4e0e8d..59c7ebd41 100644
--- a/pngcrush.c
+++ b/pngcrush.c
@@ -308,7 +308,8 @@
Change log:
-Version 1.7.78 (built with libpng-1.6.13 and zlib-1.2.8)
+Version 1.7.78 (built with libpng-1.6.14 and zlib-1.2.8)
+ Made "-s | -silent" option suppress libpng warnings.
Version 1.7.77 (built with libpng-1.6.13 and zlib-1.2.8)
Updated libpng to version 1.6.13.
@@ -1842,6 +1843,9 @@ static /* const */ png_byte chunks_to_ignore[] = {
static void pngcrush_cexcept_error(png_structp png_ptr,
png_const_charp message);
+static void pngcrush_warning(png_structp png_ptr,
+ png_const_charp message);
+
void PNGAPI pngcrush_default_read_data(png_structp png_ptr, png_bytep data,
png_size_t length);
@@ -2195,6 +2199,13 @@ pngcrush_default_write_data(png_structp png_ptr, png_bytep data,
#endif /* USE_FAR_KEYWORD */
#endif /* PNG_STDIO_SUPPORTED */
+static void pngcrush_warning(png_structp png_ptr,
+ png_const_charp warning_msg)
+{
+ if (verbose >= 0)
+ fprintf(stderr, "pngcrush: %s\n", warning_msg);
+ return;
+}
/* cexcept interface */
@@ -2207,7 +2218,7 @@ static void pngcrush_cexcept_error(png_structp png_ptr,
#ifdef PNG_CONSOLE_IO_SUPPORTED
fprintf(stderr, "\nIn %s, correcting %s\n", inname,err_msg);
#else
- png_warning(png_ptr, err_msg);
+ pngcrush_warning(png_ptr, err_msg);
#endif
return;
}
@@ -2222,7 +2233,7 @@ static void pngcrush_cexcept_error(png_structp png_ptr,
# ifdef PNG_CONSOLE_IO_SUPPORTED
fprintf(stderr, "\nIn %s, correcting %s\n", inname,err_msg);
# else
- png_warning(png_ptr, err_msg);
+ pngcrush_warning(png_ptr, err_msg);
# endif
return;
}
@@ -3161,35 +3172,7 @@ int main(int argc, char *argv[])
names++;
/* GRR: start of giant else-if block */
- if (!strncmp(argv[i], "-fast", 5))
- {
- /* try two fast filters */
- methods_specified = 1;
- try_method[16] = 0;
- try_method[53] = 0;
- }
- else if (!strncmp(argv[i], "-huffman", 8))
- {
- /* try all filters with huffman */
- methods_specified = 1;
- for (method = 11; method <= 16; method++)
- {
- try_method[method] = 0;
- }
-#ifdef Z_RLE
- }
- else if (!strncmp(argv[i], "-rle", 4))
- {
- /* try all filters with RLE */
- methods_specified = 1;
- for (method = 125; method <= 136; method++)
- {
- try_method[method] = 0;
- }
-#endif
- }
-
- else if (!strncmp(argv[i], "-already", 8))
+ if (!strncmp(argv[i], "-already", 8))
{
names++;
BUMP_I;
@@ -3200,9 +3183,6 @@ int main(int argc, char *argv[])
else if (!strncmp(argv[i], "-bail", 5))
bail=0;
- else if (!strncmp(argv[i], "-nobail", 7))
- bail=1;
-
else if (!strncmp(argv[i], "-bkgd", 5) ||
!strncmp(argv[i], "-bKGD", 5))
{
@@ -3241,6 +3221,7 @@ int main(int argc, char *argv[])
for (strat = 0; strat < NUM_STRATEGIES; strat++)
brute_force_strategies[strat] = 0;
}
+
else if (!strncmp(argv[i], "-bit_depth", 10))
{
names++;
@@ -3254,14 +3235,12 @@ int main(int argc, char *argv[])
exit(1);
}
}
+
else if (!strncmp(argv[i], "-cc", 3))
{
do_color_count = 1;
}
- else if (!strncmp(argv[i], "-no_cc", 6))
- {
- do_color_count = 0;
- }
+
else if (!strncmp(argv[i], "-c", 3) || !strncmp(argv[i], "-col", 4))
{
names++;
@@ -3269,6 +3248,7 @@ int main(int argc, char *argv[])
force_output_color_type = pngcrush_get_long;
pngcrush_check_long;
}
+
#ifdef PNG_gAMA_SUPPORTED
else if (!strncmp(argv[i], "-dou", 4))
{
@@ -3277,6 +3257,7 @@ int main(int argc, char *argv[])
global_things_have_changed = 1;
}
#endif
+
else if (!strncmp(argv[i], "-d", 3) || !strncmp(argv[i], "-dir", 4))
{
BUMP_I;
@@ -3286,10 +3267,12 @@ int main(int argc, char *argv[])
pngcrush_mode = DIRECTORY_MODE;
directory_name = argv[names++];
}
+
else if (!strncmp(argv[i], "-exit", 5))
{
pngcrush_must_exit = 1;
}
+
else if (!strncmp(argv[i], "-e", 3) || !strncmp(argv[i], "-ext", 4))
{
BUMP_I;
@@ -3299,14 +3282,25 @@ int main(int argc, char *argv[])
pngcrush_mode = EXTENSION_MODE;
extension = argv[names++];
}
+
+ else if (!strncmp(argv[i], "-fast", 5))
+ {
+ /* try two fast filters */
+ methods_specified = 1;
+ try_method[16] = 0;
+ try_method[53] = 0;
+ }
+
else if (!strncmp(argv[i], "-force", 6))
{
global_things_have_changed = 1;
}
+
else if (!strncmp(argv[i], "-fix", 4))
{
salvage++;
}
+
else if (!strncmp(argv[i], "-f", 3) || !strncmp(argv[i], "-fil", 4))
{
int specified_filter;
@@ -3327,36 +3321,6 @@ int main(int argc, char *argv[])
brute_force_filter++;
}
}
- else if (!strncmp(argv[i], "-loco", 5))
- {
-#ifdef PNGCRUSH_LOCO
- do_loco = 1;
-#else
- fprintf
- (STDERR,"Cannot do -loco because libpng was compiled"
- " without MNG features");
-#endif
- }
- else if (!strncmp(argv[i], "-l", 3) || !strncmp(argv[i], "-lev", 4))
- {
- int specified_level;
- BUMP_I;
- specified_level = pngcrush_get_long;
- pngcrush_check_long;
- if (specified_level > 9 || specified_level < 0)
- specified_level = 9;
- names++;
- if (brute_force == 0)
- lv[method] = specified_level;
- else
- {
- if (brute_force_level == 0)
- for (lev = 0; lev < 10; lev++)
- brute_force_levels[lev] = 1;
- brute_force_levels[specified_level] = 0;
- brute_force_level++;
- }
- }
#ifdef PNG_gAMA_SUPPORTED
else if (!strncmp(argv[i], "-g", 3) || !strncmp(argv[i], "-gam", 4))
@@ -3394,8 +3358,8 @@ int main(int argc, char *argv[])
pngcrush_check_long;
}
}
-
#endif /* PNG_gAMA_SUPPORTED */
+
else if (!strncmp(argv[i], "-h", 3) || !strncmp(argv[i], "-hel", 4))
{
++verbose;
@@ -3404,6 +3368,16 @@ int main(int argc, char *argv[])
print_usage(0); /* this exits */
}
+ else if (!strncmp(argv[i], "-huffman", 8))
+ {
+ /* try all filters with huffman */
+ methods_specified = 1;
+ for (method = 11; method <= 16; method++)
+ {
+ try_method[method] = 0;
+ }
+ }
+
#ifdef PNG_iCCP_SUPPORTED
else if (!strncmp(argv[i], "-iccp", 5))
{
@@ -3458,24 +3432,48 @@ int main(int argc, char *argv[])
found_any_chunk=1;
}
- else if (!strncmp(argv[i], "-max", 4))
+ else if (!strncmp(argv[i], "-l", 3) || !strncmp(argv[i], "-lev", 4))
{
- names++;
+ int specified_level;
BUMP_I;
- max_idat_size = (png_uint_32) pngcrush_get_long;
+ specified_level = pngcrush_get_long;
pngcrush_check_long;
- if (max_idat_size == 0 || max_idat_size > PNG_UINT_31_MAX)
- max_idat_size = PNG_ZBUF_SIZE;
+ if (specified_level > 9 || specified_level < 0)
+ specified_level = 9;
+ names++;
+ if (brute_force == 0)
+ lv[method] = specified_level;
+ else
+ {
+ if (brute_force_level == 0)
+ for (lev = 0; lev < 10; lev++)
+ brute_force_levels[lev] = 1;
+ brute_force_levels[specified_level] = 0;
+ brute_force_level++;
+ }
+ }
+
+ else if (!strncmp(argv[i], "-loco", 5))
+ {
#ifdef PNGCRUSH_LOCO
+ do_loco = 1;
+#else
+ fprintf
+ (STDERR,"Cannot do -loco because libpng was compiled"
+ " without MNG features");
+#endif
}
- else if (!strncmp(argv[i], "-mng", 4))
+
+ else if (!strncmp(argv[i], "-max", 4))
{
names++;
BUMP_I;
- mngname = argv[i];
- new_mng++;
-#endif
+ max_idat_size = (png_uint_32) pngcrush_get_long;
+ pngcrush_check_long;
+ if (max_idat_size == 0 || max_idat_size > PNG_UINT_31_MAX)
+ max_idat_size = PNG_ZBUF_SIZE;
}
+
else if (!strncmp(argv[i], "-m", 3) || !strncmp(argv[i], "-met", 4))
{
names++;
@@ -3496,6 +3494,16 @@ int main(int argc, char *argv[])
}
}
+#ifdef PNGCRUSH_LOCO
+ else if (!strncmp(argv[i], "-mng", 4))
+ {
+ names++;
+ BUMP_I;
+ mngname = argv[i];
+ new_mng++;
+ }
+#endif
+
else if (!strncmp(argv[i], "-new", 4))
{
global_things_have_changed = 1; /* -force */
@@ -3504,6 +3512,14 @@ int main(int argc, char *argv[])
make_8_bit = 1; /* -reduce */
}
+ else if (!strncmp(argv[i], "-nobail", 7))
+ bail=1;
+
+ else if (!strncmp(argv[i], "-no_cc", 6))
+ {
+ do_color_count = 0;
+ }
+
else if (!strncmp(argv[i], "-nofilecheck", 5))
{
nofilecheck++;
@@ -3529,10 +3545,12 @@ int main(int argc, char *argv[])
nosave++;
pngcrush_mode = EXTENSION_MODE;
}
+
else if (!strncmp(argv[i], "-oldtimestamp", 5))
{
new_time_stamp=0;
}
+
else if (!strncmp(argv[i], "-old", 4))
{
global_things_have_changed = 0; /* no -force */
@@ -3540,14 +3558,17 @@ int main(int argc, char *argv[])
make_gray = 0; /* no -reduce */
make_8_bit = 0; /* no -reduce */
}
+
else if(!strncmp(argv[i], "-ow",3))
{
overwrite = 1;
}
+
else if (!strncmp(argv[i], "-premultiply", 5))
{
premultiply=2;
}
+
else if (!strncmp(argv[i], "-plte_len", 9))
{
names++;
@@ -3555,6 +3576,7 @@ int main(int argc, char *argv[])
reduce_palette = 1;
}
else if (!strncmp(argv[i], "-pplt", 3))
+
{
names++;
do_pplt++;
@@ -3562,20 +3584,24 @@ int main(int argc, char *argv[])
strcpy(pplt_string, argv[i]);
global_things_have_changed = 1;
}
+
else if (!strncmp(argv[i], "-p", 3) || !strncmp(argv[i], "-pau", 4))
{
pauses++;
}
+
else if (!strncmp(argv[i], "-q", 3) || !strncmp(argv[i], "-qui", 4))
{
verbose = 0;
}
+
else if (!strncmp(argv[i], "-reduce", 7))
{
make_opaque = 1;
make_gray = 1;
make_8_bit = 1;
}
+
#ifdef PNG_gAMA_SUPPORTED
else if (!strncmp(argv[i], "-replace_gamma", 4))
{
@@ -3624,6 +3650,19 @@ int main(int argc, char *argv[])
global_things_have_changed = 1;
}
#endif
+
+#ifdef Z_RLE
+ else if (!strncmp(argv[i], "-rle", 4))
+ {
+ /* try all filters with RLE */
+ methods_specified = 1;
+ for (method = 125; method <= 136; method++)
+ {
+ try_method[method] = 0;
+ }
+ }
+#endif
+
#ifdef PNGCRUSH_MULTIPLE_ROWS
else if (!strncmp(argv[i], "-rows", 5))
{
@@ -3633,6 +3672,7 @@ int main(int argc, char *argv[])
pngcrush_check_long;
}
#endif
+
else if (!strncmp(argv[i], "-r", 3) || !strncmp(argv[i], "-rem", 4))
{
remove_chunks = i;
@@ -3642,10 +3682,12 @@ int main(int argc, char *argv[])
&& (!strncmp(argv[i], "dsig", 4)))
image_is_immutable=0;
}
+
else if (!strncmp(argv[i], "-save", 5))
{
all_chunks_are_safe++;
}
+
else if (!strncmp(argv[i], "-srgb", 5) ||
!strncmp(argv[i], "-sRGB", 5))
{
@@ -3669,6 +3711,7 @@ int main(int argc, char *argv[])
} else
i--;
}
+
else if (!strncmp(argv[i], "-ster", 5) ||
!strncmp(argv[i], "-sTER", 5))
{
@@ -3685,14 +3728,17 @@ int main(int argc, char *argv[])
else
i--;
}
+
else if (!strncmp(argv[i], "-s", 3) || !strncmp(argv[i], "-sil", 4))
{
- verbose = 0;
+ verbose = -1;
}
+
else if(!strncmp(argv[i], "-try10",6))
{
try10 = 1;
}
+
else if (!strncmp(argv[i], "-text", 5)
|| !strncmp(argv[i], "-tEXt", 5) ||
#ifdef PNG_iTXt_SUPPORTED
@@ -3779,6 +3825,7 @@ int main(int argc, char *argv[])
#endif
}
}
+
else if (!strncmp(argv[i], "-time_stamp", 5) || /* legacy */
!strncmp(argv[i], "-newtimestamp", 5))
new_time_stamp=1;
@@ -3801,6 +3848,7 @@ int main(int argc, char *argv[])
}
names += 1 + num_trans_in;
}
+
else if (!strncmp(argv[i], "-trns", 5) ||
!strncmp(argv[i], "-tRNS", 5))
{
@@ -3823,6 +3871,7 @@ int main(int argc, char *argv[])
pngcrush_check_long;
}
#endif /* tRNS */
+
else if (!strncmp(argv[i], "-version", 8))
{
fprintf(STDERR, " pngcrush ");
@@ -3835,10 +3884,12 @@ int main(int argc, char *argv[])
fprintf(STDERR, " for the most recent version.\n");
verbose = 0;
}
+
else if (!strncmp(argv[i], "-v", 3) || !strncmp(argv[i], "-ver", 4))
{
verbose++;
}
+
else if (!strncmp(argv[i], "-w", 3) || !strncmp(argv[i], "-win", 4))
{
BUMP_I;
@@ -3847,6 +3898,7 @@ int main(int argc, char *argv[])
force_compression_window++;
names++;
}
+
else if (!strncmp(argv[i], "-zm", 4) || !strncmp(argv[i], "-zmem", 5))
{
BUMP_I;
@@ -3854,6 +3906,7 @@ int main(int argc, char *argv[])
pngcrush_check_long;
names++;
}
+
else if (!strncmp(argv[i], "-z", 3))
{
int specified_strategy;
@@ -3874,6 +3927,7 @@ int main(int argc, char *argv[])
brute_force_strategy++;
}
}
+
else if (!strncmp(argv[i], "-", 1))
{
if (verbose > 0 && printed_version_info == 0)
@@ -3920,18 +3974,20 @@ int main(int argc, char *argv[])
inname = argv[names];
outname = argv[names + 1];
}
+
else if (overwrite)
{
inname = argv[names];
outname = outname;
}
+
else
{
if ((argc - names == 1 || nosave))
{
inname = argv[names];
}
- if (verbose && !nosave)
+ if (verbose > 0 && !nosave)
{
print_usage(1); /* this exits */
}
@@ -4141,14 +4197,15 @@ int main(int argc, char *argv[])
if (verbose > 0)
mng_ptr = png_create_write_struct_2(PNG_LIBPNG_VER_STRING,
(png_voidp) NULL, (png_error_ptr) pngcrush_cexcept_error,
- (png_error_ptr) NULL, (png_voidp) NULL,
+ (png_error_ptr) pngcrush_warning, (png_error_ptr) NULL,
(png_malloc_ptr) pngcrush_debug_malloc,
(png_free_ptr) pngcrush_debug_free);
else
# endif
mng_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
- (png_voidp) NULL, (png_error_ptr) pngcrush_cexcept_error,
- (png_error_ptr) NULL);
+ (png_voidp) NULL,
+ (png_error_ptr) pngcrush_cexcept_error,
+ (png_error_ptr) pngcrush_warning);
if (mng_ptr == NULL)
fprintf(STDERR, "pngcrush could not create mng_ptr");
@@ -4195,6 +4252,7 @@ int main(int argc, char *argv[])
continue;
}
+
else
idat_length[0] = 1;
@@ -4202,11 +4260,13 @@ int main(int argc, char *argv[])
{
fprintf(STDERR, " File %s has already been crushed.\n", inname);
}
+
if (image_is_immutable)
{
fprintf(STDERR,
" Image %s has a dSIG chunk and is immutable.\n", inname);
}
+
if (!already_crushed && !image_is_immutable)
{
@@ -4237,6 +4297,7 @@ int main(int argc, char *argv[])
force_output_bit_depth);
force_output_bit_depth=0;
}
+
if (force_output_color_type != 8 &&
force_output_color_type != 0 &&
force_output_color_type != 2 &&
@@ -4507,6 +4568,7 @@ int main(int argc, char *argv[])
if (trial > 2 && trial < 5 && idat_length[trial - 1]
< idat_length[best_of_three])
best_of_three = trial - 1;
+
if (try_method[trial])
{
P2("skipping \"late\" trial %d\n", trial);
@@ -4620,14 +4682,15 @@ int main(int argc, char *argv[])
if (verbose > 0)
read_ptr = png_create_read_struct_2(PNG_LIBPNG_VER_STRING,
(png_voidp) NULL, (png_error_ptr) pngcrush_cexcept_error,
- (png_error_ptr) NULL, (png_voidp) NULL,
+ (png_error_ptr) pngcrush_warning,
+ (png_voidp) NULL,
(png_malloc_ptr) pngcrush_debug_malloc,
(png_free_ptr) pngcrush_debug_free);
else
#endif /* PNG_USER_MEM_SUPPORTED */
read_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,
(png_voidp) NULL, (png_error_ptr) pngcrush_cexcept_error,
- (png_error_ptr) NULL);
+ (png_error_ptr) pngcrush_warning);
if (read_ptr == NULL)
Throw "pngcrush could not create read_ptr";
@@ -4653,6 +4716,15 @@ int main(int argc, char *argv[])
}
#endif /* PNG_SET_USER_LIMITS_SUPPORTED */
+#if defined(PNG_MAXIMUM_INFLATE_WINDOW) && defined(PNG_OPTION_ON)
+ if (salvage)
+ {
+ png_set_option(read_ptr, PNG_MAXIMUM_INFLATE_WINDOW,
+ PNG_OPTION_ON);
+ printf(" Setting MAXIMUM_INFLATE_WINDOW\n");
+ }
+#endif
+
#if 0
/* Use a smaller decompression buffer for speed */
png_set_compression_buffer_size(read_ptr,
@@ -4706,16 +4778,20 @@ int main(int argc, char *argv[])
}
P1("Allocating read_info, write_info, end_info structures\n");
read_info_ptr = png_create_info_struct(read_ptr);
+
if (read_info_ptr == NULL)
Throw "pngcrush could not create read_info_ptr";
+
end_info_ptr = png_create_info_struct(read_ptr);
if (end_info_ptr == NULL)
Throw "pngcrush could not create end_info_ptr";
+
if (nosave == 0)
{
write_info_ptr = png_create_info_struct(write_ptr);
if (write_info_ptr == NULL)
Throw "pngcrush could not create write_info_ptr";
+
write_end_info_ptr = png_create_info_struct(write_ptr);
if (write_end_info_ptr == NULL)
Throw
@@ -4792,6 +4868,7 @@ int main(int argc, char *argv[])
PNG_HANDLE_CHUNK_ALWAYS,
(png_bytep) "fdAT", 1);
}
+
if (found_any_chunk == 1)
png_set_keep_unknown_chunks(write_ptr,
PNG_HANDLE_CHUNK_ALWAYS,
@@ -4814,6 +4891,7 @@ int main(int argc, char *argv[])
(png_bytep) "fdAT", 1);
}
}
+
else {
#if !defined(PNG_cHRM_SUPPORTED) || !defined(PNG_hIST_SUPPORTED) || \
!defined(PNG_iCCP_SUPPORTED) || !defined(PNG_sCAL_SUPPORTED) || \
@@ -4944,6 +5022,7 @@ int main(int argc, char *argv[])
png_skip_chunk(read_ptr);
input_format = 1;
}
+
else
#endif
if (png_sig_cmp(png_signature, 0, 8))
@@ -4991,6 +5070,7 @@ int main(int argc, char *argv[])
if (output_color_type == 6)
output_color_type = 2;
}
+
else
P1(" make_opaque=%d\n",make_opaque);
@@ -5009,7 +5089,7 @@ int main(int argc, char *argv[])
if (output_color_type == 2)
output_color_type = 0;
}
- P1(" make_gray=%d\n",make_gray);
+ P1(" make_gray=%d\n",make_gray);
if (make_8_bit == 1)
{
@@ -5020,7 +5100,7 @@ int main(int argc, char *argv[])
*/
P1(" Reduce 16-bit image losslessly to 8-bit\n");
}
- P1(" make_8_bit=%d\n",make_8_bit);
+ P1(" make_8_bit=%d\n",make_8_bit);
if (make_opaque != 1 && blacken == 2)
{
@@ -6243,7 +6323,7 @@ int main(int argc, char *argv[])
{ 138, 77, 78, 71, 13, 10, 26, 10 };
/* write the MNG 8-byte signature */
if (outname[strlen(outname) - 3] == 'p')
- png_warning(read_ptr,
+ pngcrush_warning(read_ptr,
" Writing a MNG file with a .png extension");
pngcrush_default_write_data(write_ptr,
&mng_signature[0],
@@ -6277,7 +6357,7 @@ int main(int argc, char *argv[])
if (found_CgBI)
{
- png_warning(read_ptr,
+ pngcrush_warning(read_ptr,
"Cannot read Xcode CgBI PNG");
}
P1( "\nWriting info struct\n");
@@ -7247,7 +7327,7 @@ png_uint_32 pngcrush_measure_idat(png_structp png_ptr)
for (b=0; b<40; b++)
buff[b]='\0';
pngcrush_default_read_data(read_ptr, buff, length);
- if (verbose) {
+ if (verbose > 0) {
printf(" width=%lu\n",(unsigned long)(buff[3]+(buff[2]<<8)
+(buff[1]<<16)+(buff[0]<<24)));
printf(" height=%lu\n",(unsigned long)(buff[7]+(buff[6]<<8)
@@ -8026,7 +8106,7 @@ struct options_help pngcrush_options[] = {
{0, " -plte_len n (obsolete; any \"n\" enables palette reduction)"},
{2, ""},
- {0, " -q (quiet)"},
+ {0, " -q (quiet) suppresses console output except for warnings"},
{2, ""},
{0, " -reduce (do lossless color-type or bit-depth reduction)"},
@@ -8081,6 +8161,9 @@ struct options_help pngcrush_options[] = {
{2, ""},
#endif
+ {0, " -s (silent) suppresses console output including warnings"},
+ {2, ""},
+
{0, " -save (keep all copy-unsafe PNG chunks)"},
{2, ""},
{2, " Save otherwise unknown ancillary chunks that would"},
@@ -8195,7 +8278,7 @@ void print_usage(int retval)
{
int j, jmax;
- if (verbose)
+ if (verbose > 0)
{
jmax = sizeof(pngcrush_legal) / sizeof(char *);
for (j = 0; j < jmax; ++j)
diff --git a/pngcrush.h b/pngcrush.h
index 55894f11f..d11455cf5 100644
--- a/pngcrush.h
+++ b/pngcrush.h
@@ -10,6 +10,7 @@
#ifndef PNGCRUSH_H
#define PNGCRUSH_H
+
/* Do not build stuff we will not use */
#undef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
#undef PNG_CONVERT_tIME_SUPPORTED
@@ -25,6 +26,7 @@
#if PNG_LIBPNG_VER >= 10600
# undef PNG_READ_GAMMA_SUPPORTED
#endif
+#define PNG_ERROR_TEXT_SUPPORTED
#define PNG_READ_STRIP_16_TO_8_SUPPORTED
#undef PNG_READ_SWAP_ALPHA_SUPPORTED
#undef PNG_READ_SWAP_SUPPORTED
diff --git a/pnglibconf.h b/pnglibconf.h
index 4c8605a8a..2c45d90ae 100644
--- a/pnglibconf.h
+++ b/pnglibconf.h
@@ -1,8 +1,8 @@
-/* libpng 1.6.13 STANDARD API DEFINITION */
+/* libpng 1.6.14 STANDARD API DEFINITION */
/* pnglibconf.h - library build configuration */
-/* Libpng version 1.6.13 - August 21, 2014 */
+/* Libpng version 1.6.14 - October 23, 2014 */
/* Copyright (c) 1998-2014 Glenn Randers-Pehrson */
diff --git a/pngpread.c b/pngpread.c
index a4d073b94..bcd9261df 100644
--- a/pngpread.c
+++ b/pngpread.c
@@ -1,7 +1,7 @@
/* pngpread.c - read a png file in push mode
*
- * Last changed in libpng 1.6.11 [June 5, 2014]
+ * Last changed in libpng 1.6.14 [October 23, 2014]
* Copyright (c) 1998-2014 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.)
@@ -26,6 +26,13 @@
#define PNG_READ_iTXt_MODE 7
#define PNG_ERROR_MODE 8
+#define PNG_PUSH_SAVE_BUFFER_IF_FULL \
+if (png_ptr->push_length + 4 > png_ptr->buffer_size) \
+ { png_push_save_buffer(png_ptr); return; }
+#define PNG_PUSH_SAVE_BUFFER_IF_LT(N) \
+if (png_ptr->buffer_size < N) \
+ { png_push_save_buffer(png_ptr); return; }
+
void PNGAPI
png_process_data(png_structrp png_ptr, png_inforp info_ptr,
png_bytep buffer, png_size_t buffer_size)
@@ -46,7 +53,7 @@ png_process_data_pause(png_structrp png_ptr, int save)
{
if (png_ptr != NULL)
{
- /* It's easiest for the caller if we do the save, then the caller doesn't
+ /* It's easiest for the caller if we do the save; then the caller doesn't
* have to supply the same data again:
*/
if (save != 0)
@@ -189,10 +196,10 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
int keep; /* unknown handling method */
#endif
- /* First we make sure we have enough data for the 4 byte chunk name
- * and the 4 byte chunk length before proceeding with decoding the
+ /* First we make sure we have enough data for the 4-byte chunk name
+ * and the 4-byte chunk length before proceeding with decoding the
* chunk data. To fully decode each of these chunks, we also make
- * sure we have enough data in the buffer for the 4 byte CRC at the
+ * sure we have enough data in the buffer for the 4-byte CRC at the
* end of every chunk (except IDAT, which is handled separately).
*/
if (!(png_ptr->mode & PNG_HAVE_CHUNK_HEADER))
@@ -200,12 +207,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
png_byte chunk_length[4];
png_byte chunk_tag[4];
- if (png_ptr->buffer_size < 8)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_LT(8)
png_push_fill_buffer(png_ptr, chunk_length, 4);
png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
png_reset_crc(png_ptr);
@@ -249,23 +251,13 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
if (png_ptr->push_length != 13)
png_error(png_ptr, "Invalid IHDR length");
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length);
}
else if (chunk_name == png_IEND)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length);
png_ptr->process_mode = PNG_READ_DONE_MODE;
@@ -275,12 +267,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length, keep);
if (chunk_name == png_PLTE)
@@ -290,11 +277,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
else if (chunk_name == png_PLTE)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -313,12 +296,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_gAMA_SUPPORTED
else if (png_ptr->chunk_name == png_gAMA)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -326,12 +304,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_sBIT_SUPPORTED
else if (png_ptr->chunk_name == png_sBIT)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -339,12 +312,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_cHRM_SUPPORTED
else if (png_ptr->chunk_name == png_cHRM)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -352,12 +320,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_sRGB_SUPPORTED
else if (chunk_name == png_sRGB)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -365,12 +328,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_iCCP_SUPPORTED
else if (png_ptr->chunk_name == png_iCCP)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -378,12 +336,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_sPLT_SUPPORTED
else if (chunk_name == png_sPLT)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -391,12 +344,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_tRNS_SUPPORTED
else if (chunk_name == png_tRNS)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -404,12 +352,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_bKGD_SUPPORTED
else if (chunk_name == png_bKGD)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -417,12 +360,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_hIST_SUPPORTED
else if (chunk_name == png_hIST)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -430,12 +368,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_pHYs_SUPPORTED
else if (chunk_name == png_pHYs)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -443,12 +376,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_oFFs_SUPPORTED
else if (chunk_name == png_oFFs)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length);
}
#endif
@@ -456,12 +384,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_pCAL_SUPPORTED
else if (chunk_name == png_pCAL)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -469,12 +392,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_sCAL_SUPPORTED
else if (chunk_name == png_sCAL)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -482,12 +400,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_tIME_SUPPORTED
else if (chunk_name == png_tIME)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -495,12 +408,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_tEXt_SUPPORTED
else if (chunk_name == png_tEXt)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -508,12 +416,7 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_zTXt_SUPPORTED
else if (chunk_name == png_zTXt)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length);
}
@@ -521,23 +424,14 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_iTXt_SUPPORTED
else if (chunk_name == png_iTXt)
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
}
#endif
else
{
- if (png_ptr->push_length + 4 > png_ptr->buffer_size)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
+ PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length,
PNG_HANDLE_CHUNK_AS_DEFAULT);
}
@@ -602,12 +496,7 @@ png_push_crc_finish(png_structrp png_ptr)
}
if (!png_ptr->skip_length)
{
- if (png_ptr->buffer_size < 4)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_LT(4)
png_crc_finish(png_ptr, 0);
png_ptr->process_mode = PNG_READ_CHUNK_MODE;
}
@@ -732,12 +621,7 @@ png_push_read_IDAT(png_structrp png_ptr)
png_byte chunk_tag[4];
/* TODO: this code can be commoned up with the same code in push_read */
- if (png_ptr->buffer_size < 8)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_LT(8)
png_push_fill_buffer(png_ptr, chunk_length, 4);
png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
png_reset_crc(png_ptr);
@@ -812,12 +696,7 @@ png_push_read_IDAT(png_structrp png_ptr)
}
if (!png_ptr->idat_size)
{
- if (png_ptr->buffer_size < 4)
- {
- png_push_save_buffer(png_ptr);
- return;
- }
-
+ PNG_PUSH_SAVE_BUFFER_IF_LT(4)
png_crc_finish(png_ptr, 0);
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
png_ptr->mode |= PNG_AFTER_IDAT;
diff --git a/pngpriv.h b/pngpriv.h
index 71a5ab456..aa63cfa47 100644
--- a/pngpriv.h
+++ b/pngpriv.h
@@ -1090,7 +1090,7 @@ PNG_INTERNAL_FUNCTION(void,png_write_tEXt,(png_structrp png_ptr,
#ifdef PNG_WRITE_zTXt_SUPPORTED
PNG_INTERNAL_FUNCTION(void,png_write_zTXt,(png_structrp png_ptr, png_const_charp
- key, png_const_charp text, png_size_t text_len, int compression),PNG_EMPTY);
+ key, png_const_charp text, int compression),PNG_EMPTY);
#endif
#ifdef PNG_WRITE_iTXt_SUPPORTED
diff --git a/pngread.c b/pngread.c
index 845ff7b15..53b9c3b9b 100644
--- a/pngread.c
+++ b/pngread.c
@@ -396,6 +396,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
row_info.pixel_depth = png_ptr->pixel_depth;
row_info.rowbytes = PNG_ROWBYTES(row_info.pixel_depth, row_info.width);
+#ifdef PNG_WARNINGS_SUPPORTED
if (png_ptr->row_number == 0 && png_ptr->pass == 0)
{
/* Check for transforms that have been set but were defined out */
@@ -435,6 +436,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
png_warning(png_ptr, "PNG_READ_SWAP_SUPPORTED is not defined");
#endif
}
+#endif /* PNG_WARNINGS_SUPPORTED */
#ifdef PNG_READ_INTERLACING_SUPPORTED
/* If interlaced and we do not need a new row, combine row and return.
diff --git a/pngrtran.c b/pngrtran.c
index d8ab70513..91e647161 100644
--- a/pngrtran.c
+++ b/pngrtran.c
@@ -959,7 +959,7 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
if (!png_rtran_ok(png_ptr, 1))
return;
- switch(error_action)
+ switch (error_action)
{
case PNG_ERROR_ACTION_NONE:
png_ptr->transformations |= PNG_RGB_TO_GRAY;
diff --git a/pngrutil.c b/pngrutil.c
index 3f415bf7d..a48907aeb 100644
--- a/pngrutil.c
+++ b/pngrutil.c
@@ -1,7 +1,7 @@
/* pngrutil.c - utilities to read a PNG file
*
- * Last changed in libpng 1.6.11 [June 5, 2014]
+ * Last changed in libpng 1.6.14 [October 23, 2014]
* Copyright (c) 1998-2014 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.)
@@ -341,12 +341,12 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
* are minimal.
*/
(void)png_safecat(msg, (sizeof msg), 4, " using zstream");
-# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
- png_chunk_warning(png_ptr, msg);
- png_ptr->zowner = 0;
-# else
- png_chunk_error(png_ptr, msg);
-# endif
+#if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
+ png_chunk_warning(png_ptr, msg);
+ png_ptr->zowner = 0;
+#else
+ png_chunk_error(png_ptr, msg);
+#endif
}
/* Implementation note: unlike 'png_deflate_claim' this internal function
@@ -364,22 +364,21 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
*/
{
int ret; /* zlib return code */
-# if PNG_ZLIB_VERNUM >= 0x1240
+#if PNG_ZLIB_VERNUM >= 0x1240
-# if defined(PNG_SET_OPTION_SUPPORTED) && \
- defined(PNG_MAXIMUM_INFLATE_WINDOW)
- int window_bits;
+# if defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_MAXIMUM_INFLATE_WINDOW)
+ int window_bits;
- if (((png_ptr->options >> PNG_MAXIMUM_INFLATE_WINDOW) & 3) ==
- PNG_OPTION_ON)
- window_bits = 15;
+ if (((png_ptr->options >> PNG_MAXIMUM_INFLATE_WINDOW) & 3) ==
+ PNG_OPTION_ON)
+ window_bits = 15;
- else
- window_bits = 0;
-# else
-# define window_bits 0
-# endif
-# endif
+ else
+ window_bits = 0;
+# else
+# define window_bits 0
+# endif
+#endif
/* Set this for safety, just in case the previous owner left pointers to
* memory allocations.
@@ -391,20 +390,20 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
if (png_ptr->flags & PNG_FLAG_ZSTREAM_INITIALIZED)
{
-# if PNG_ZLIB_VERNUM < 0x1240
- ret = inflateReset(&png_ptr->zstream);
-# else
- ret = inflateReset2(&png_ptr->zstream, window_bits);
-# endif
+#if PNG_ZLIB_VERNUM < 0x1240
+ ret = inflateReset(&png_ptr->zstream);
+#else
+ ret = inflateReset2(&png_ptr->zstream, window_bits);
+#endif
}
else
{
-# if PNG_ZLIB_VERNUM < 0x1240
- ret = inflateInit(&png_ptr->zstream);
-# else
- ret = inflateInit2(&png_ptr->zstream, window_bits);
-# endif
+#if PNG_ZLIB_VERNUM < 0x1240
+ ret = inflateInit(&png_ptr->zstream);
+#else
+ ret = inflateInit2(&png_ptr->zstream, window_bits);
+#endif
if (ret == Z_OK)
png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED;
@@ -419,9 +418,9 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
return ret;
}
-# ifdef window_bits
-# undef window_bits
-# endif
+#ifdef window_bits
+# undef window_bits
+#endif
}
#ifdef PNG_READ_COMPRESSED_TEXT_SUPPORTED
@@ -518,7 +517,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 */
@@ -576,14 +575,14 @@ png_decompress_chunk(png_structrp png_ptr,
*/
png_alloc_size_t limit = PNG_SIZE_MAX;
-# ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
- if (png_ptr->user_chunk_malloc_max > 0 &&
- png_ptr->user_chunk_malloc_max < limit)
- limit = png_ptr->user_chunk_malloc_max;
-# elif PNG_USER_CHUNK_MALLOC_MAX > 0
- if (PNG_USER_CHUNK_MALLOC_MAX < limit)
- limit = PNG_USER_CHUNK_MALLOC_MAX;
-# endif
+# ifdef PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED
+ if (png_ptr->user_chunk_malloc_max > 0 &&
+ png_ptr->user_chunk_malloc_max < limit)
+ limit = png_ptr->user_chunk_malloc_max;
+# elif PNG_USER_CHUNK_MALLOC_MAX > 0
+ if (PNG_USER_CHUNK_MALLOC_MAX < limit)
+ limit = PNG_USER_CHUNK_MALLOC_MAX;
+# endif
if (limit >= prefix_size + (terminate != 0))
{
@@ -1011,7 +1010,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
@@ -2672,7 +2671,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
@@ -3331,7 +3330,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];
diff --git a/pngset.c b/pngset.c
index cde4c6dad..8eb5f6e30 100644
--- a/pngset.c
+++ b/pngset.c
@@ -726,7 +726,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
else
max_text = INT_MAX;
- /* Now allocate a new array and copy the old members in, this does all
+ /* Now allocate a new array and copy the old members in; this does all
* the overflow checks.
*/
new_text = png_voidcast(png_textp,png_realloc_array(png_ptr,
@@ -1020,8 +1020,8 @@ png_set_sPLT(png_const_structrp png_ptr,
np->depth = entries->depth;
- /* In the even of out-of-memory just return - there's no point keeping on
- * trying to add sPLT chunks.
+ /* In the event of out-of-memory just return - there's no point keeping
+ * on trying to add sPLT chunks.
*/
length = strlen(entries->name) + 1;
np->name = png_voidcast(png_charp, png_malloc_base(png_ptr, length));
@@ -1032,8 +1032,8 @@ png_set_sPLT(png_const_structrp png_ptr,
memcpy(np->name, entries->name, length);
/* IMPORTANT: we have memory now that won't get freed if something else
- * goes wrong, this code must free it. png_malloc_array produces no
- * warnings, use a png_chunk_report (below) if there is an error.
+ * goes wrong; this code must free it. png_malloc_array produces no
+ * warnings; use a png_chunk_report (below) if there is an error.
*/
np->entries = png_voidcast(png_sPLT_entryp, png_malloc_array(png_ptr,
entries->nentries, sizeof (png_sPLT_entry)));
@@ -1072,7 +1072,7 @@ check_location(png_const_structrp png_ptr, int location)
location &= (PNG_HAVE_IHDR|PNG_HAVE_PLTE|PNG_AFTER_IDAT);
/* New in 1.6.0; copy the location and check it. This is an API
- * change, previously the app had to use the
+ * change; previously the app had to use the
* png_set_unknown_chunk_location API below for each chunk.
*/
if (location == 0 && !(png_ptr->mode & PNG_IS_READ_STRUCT))
@@ -1578,7 +1578,7 @@ png_set_benign_errors(png_structrp png_ptr, int allowed)
* It is possible for an indexed (color-type==3) PNG file to contain
* pixels with invalid (out-of-range) indexes if the PLTE chunk has
* fewer entries than the image's bit-depth would allow. We recover
- * from this gracefully by filling any incomplete palette with zeroes
+ * from this gracefully by filling any incomplete palette with zeros
* (opaque black). By default, when this occurs libpng will issue
* a benign error. This API can be used to override that behavior.
*/
diff --git a/pngtrans.c b/pngtrans.c
index 9b6c3d0cd..631e3c15e 100644
--- a/pngtrans.c
+++ b/pngtrans.c
@@ -828,7 +828,7 @@ png_get_user_transform_ptr(png_const_structrp png_ptr)
png_uint_32 PNGAPI
png_get_current_row_number(png_const_structrp png_ptr)
{
- /* See the comments in png.h - this is the sub-image row when reading and
+ /* See the comments in png.h - this is the sub-image row when reading an
* interlaced image.
*/
if (png_ptr != NULL)
diff --git a/pngwrite.c b/pngwrite.c
index f03aeb2ce..6a831f62c 100644
--- a/pngwrite.c
+++ b/pngwrite.c
@@ -1,7 +1,7 @@
/* pngwrite.c - general routines to write a PNG file
*
- * Last changed in libpng 1.6.11 [June 5, 2014]
+ * Last changed in libpng 1.6.14 [October 23, 2014]
* Copyright (c) 1998-2014 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.)
@@ -292,11 +292,14 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
info_ptr->text[i].lang,
info_ptr->text[i].lang_key,
info_ptr->text[i].text);
+ /* Mark this chunk as written */
+ if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)
+ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
+ else
+ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
#else
- png_warning(png_ptr, "Unable to write international text");
+ png_warning(png_ptr, "Unable to write international text");
#endif
- /* Mark this chunk as written */
- info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
}
/* If we want a compressed text chunk */
@@ -305,13 +308,12 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
#ifdef PNG_WRITE_zTXt_SUPPORTED
/* Write compressed chunk */
png_write_zTXt(png_ptr, info_ptr->text[i].key,
- info_ptr->text[i].text, 0,
- info_ptr->text[i].compression);
+ info_ptr->text[i].text, info_ptr->text[i].compression);
+ /* Mark this chunk as written */
+ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
#else
png_warning(png_ptr, "Unable to write compressed text");
#endif
- /* Mark this chunk as written */
- info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
}
else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)
@@ -387,11 +389,14 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
info_ptr->text[i].lang,
info_ptr->text[i].lang_key,
info_ptr->text[i].text);
+ /* Mark this chunk as written */
+ if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)
+ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
+ else
+ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
#else
png_warning(png_ptr, "Unable to write international text");
#endif
- /* Mark this chunk as written */
- info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
}
else if (info_ptr->text[i].compression >= PNG_TEXT_COMPRESSION_zTXt)
@@ -399,13 +404,12 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_WRITE_zTXt_SUPPORTED
/* Write compressed chunk */
png_write_zTXt(png_ptr, info_ptr->text[i].key,
- info_ptr->text[i].text, 0,
- info_ptr->text[i].compression);
+ info_ptr->text[i].text, info_ptr->text[i].compression);
+ /* Mark this chunk as written */
+ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
#else
png_warning(png_ptr, "Unable to write compressed text");
#endif
- /* Mark this chunk as written */
- info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_zTXt_WR;
}
else if (info_ptr->text[i].compression == PNG_TEXT_COMPRESSION_NONE)
@@ -414,12 +418,11 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
/* Write uncompressed chunk */
png_write_tEXt(png_ptr, info_ptr->text[i].key,
info_ptr->text[i].text, 0);
+ /* Mark this chunk as written */
+ info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
#else
png_warning(png_ptr, "Unable to write uncompressed text");
#endif
-
- /* Mark this chunk as written */
- info_ptr->text[i].compression = PNG_TEXT_COMPRESSION_NONE_WR;
}
}
#endif
diff --git a/pngwutil.c b/pngwutil.c
index 8a0b7f2ec..45b6b1e35 100644
--- a/pngwutil.c
+++ b/pngwutil.c
@@ -1,7 +1,7 @@
/* pngwutil.c - utilities to write a PNG file
*
- * Last changed in libpng 1.6.11 [June 5, 2014]
+ * Last changed in libpng 1.6.14 [October 23, 2014]
* Copyright (c) 1998-2014 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.)
@@ -136,7 +136,7 @@ png_write_chunk_data(png_structrp png_ptr, png_const_bytep data,
png_write_data(png_ptr, data, length);
/* Update the CRC after writing the data,
- * in case that the user I/O routine alters it.
+ * in case the user I/O routine alters it.
*/
png_calculate_crc(png_ptr, data, length);
}
@@ -181,7 +181,7 @@ png_write_complete_chunk(png_structrp png_ptr, png_uint_32 chunk_name,
/* On 64 bit architectures 'length' may not fit in a png_uint_32. */
if (length > PNG_UINT_31_MAX)
- png_error(png_ptr, "length exceeds PNG maxima");
+ png_error(png_ptr, "length exceeds PNG maximum");
png_write_chunk_header(png_ptr, chunk_name, (png_uint_32)length);
png_write_chunk_data(png_ptr, data, length);
@@ -204,7 +204,7 @@ png_write_chunk(png_structrp png_ptr, png_const_bytep chunk_string,
static png_alloc_size_t
png_image_size(png_structrp png_ptr)
{
- /* Only return sizes up to the maximum of a png_uint_32, do this by limiting
+ /* Only return sizes up to the maximum of a png_uint_32; do this by limiting
* the width and height used to 15 bits.
*/
png_uint_32 h = png_ptr->height;
@@ -297,6 +297,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
{
if (png_ptr->zowner != 0)
{
+# if defined(PNG_WARNINGS_SUPPORTED) || defined(PNG_ERROR_TEXT_SUPPORTED)
char msg[64];
PNG_STRING_FROM_CHUNK(msg, owner);
@@ -308,6 +309,7 @@ png_deflate_claim(png_structrp png_ptr, png_uint_32 owner,
* are minimal.
*/
(void)png_safecat(msg, (sizeof msg), 10, " using zstream");
+# endif
# if PNG_LIBPNG_BUILD_BASE_TYPE >= PNG_LIBPNG_BUILD_RC
png_warning(png_ptr, msg);
@@ -492,7 +494,7 @@ png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name,
int ret;
/* To find the length of the output it is necessary to first compress the
- * input, the result is buffered rather than using the two-pass algorithm
+ * input. The result is buffered rather than using the two-pass algorithm
* that is used on the inflate side; deflate is assumed to be slower and a
* PNG writer is assumed to have more memory available than a PNG reader.
*
@@ -589,7 +591,7 @@ png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name,
}
while (ret == Z_OK);
- /* There may be some space left in the last output buffer, this needs to
+ /* There may be some space left in the last output buffer. This needs to
* be subtracted from output_len.
*/
output_len -= png_ptr->zstream.avail_out;
@@ -612,7 +614,7 @@ png_text_compress(png_structrp png_ptr, png_uint_32 chunk_name,
/* Reset zlib for another zTXt/iTXt or image data */
png_ptr->zowner = 0;
- /* The only success case is Z_STREAM_END, input_len must be 0, if not this
+ /* The only success case is Z_STREAM_END, input_len must be 0; if not this
* is an internal error.
*/
if (ret == Z_STREAM_END && input_len == 0)
@@ -728,6 +730,7 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
if (key_len == 0)
return 0;
+#ifdef PNG_WARNINGS_SUPPORTED
/* Try to only output one warning per keyword: */
if (*key) /* keyword too long */
png_warning(png_ptr, "keyword truncated");
@@ -741,6 +744,7 @@ png_check_keyword(png_structrp png_ptr, png_const_charp key, png_bytep new_key)
png_formatted_warning(png_ptr, p, "keyword \"@1\": bad character '0x@2'");
}
+#endif /* PNG_WARNINGS_SUPPORTED */
return key_len;
}
@@ -998,7 +1002,7 @@ png_write_PLTE(png_structrp png_ptr, png_const_colorp palette,
* Z_FINISH: this is the end of the input, do a Z_FINISH and clean up
*
* The routine manages the acquire and release of the png_ptr->zstream by
- * checking and (at the end) clearing png_ptr->zowner, it does some sanity
+ * checking and (at the end) clearing png_ptr->zowner; it does some sanity
* checks on the 'mode' flags while doing this.
*/
void /* PRIVATE */
@@ -1058,7 +1062,7 @@ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input,
input_len += png_ptr->zstream.avail_in;
png_ptr->zstream.avail_in = 0;
- /* OUTPUT: write complete IDAT chunks when avail_out drops to zero, note
+ /* OUTPUT: write complete IDAT chunks when avail_out drops to zero. Note
* that these two zstream fields are preserved across the calls, therefore
* there is no need to set these up on entry to the loop.
*/
@@ -1090,7 +1094,7 @@ png_compress_IDAT(png_structrp png_ptr, png_const_bytep input,
continue;
}
- /* The order of these checks doesn't matter much; it just effect which
+ /* The order of these checks doesn't matter much; it just affects which
* possible error might be detected if multiple things go wrong at once.
*/
if (ret == Z_OK) /* most likely return code! */
@@ -1621,14 +1625,13 @@ png_write_tEXt(png_structrp png_ptr, png_const_charp key, png_const_charp text,
/* Write a compressed text chunk */
void /* PRIVATE */
png_write_zTXt(png_structrp png_ptr, png_const_charp key, png_const_charp text,
- png_size_t text_len, int compression)
+ int compression)
{
png_uint_32 key_len;
png_byte new_key[81];
compression_state comp;
png_debug(1, "in png_write_zTXt");
- PNG_UNUSED(text_len) /* Always use strlen */
if (compression == PNG_TEXT_COMPRESSION_NONE)
{