[libpng16] Added PNG_IMAGE_FLAG_FAST for the benefit of applications that
store intermediate files, or intermediate in-memory data, while processing
image data with the simplified API. The option makes the files larger
but faster to write and read. pngstest now uses this by default; this
can be disabled with the --slow option.
diff --git a/ANNOUNCE b/ANNOUNCE
index b47da11..f630823 100644
--- a/ANNOUNCE
+++ b/ANNOUNCE
@@ -1,5 +1,5 @@
-Libpng 1.6.0beta15 - February 29, 2012
+Libpng 1.6.0beta15 - March 2, 2012
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.
@@ -234,12 +234,17 @@
Added information about the new limits in the manual.
Updated Makefile.in
-Version 1.6.0beta15 [February 29, 2012]
+Version 1.6.0beta15 [March 2, 2012]
Removed unused "current_text" members of png_struct and the png_free()
of png_ptr->current_text from pngread.c
Rewrote pngstest.c for substantial speed improvement.
Fixed transparent pixel and 16-bit rgb tests in pngstest and removed a
spurious check in pngwrite.c
+ Added PNG_IMAGE_FLAG_FAST for the benefit of applications that store
+ intermediate files, or intermediate in-memory data, while processing
+ image data with the simplified API. The option makes the files larger
+ but faster to write and read. pngstest now uses this by default; this
+ can be disabled with the --slow option.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
diff --git a/CHANGES b/CHANGES
index 6cc1292..6f668ef 100644
--- a/CHANGES
+++ b/CHANGES
@@ -3986,12 +3986,17 @@
Added information about the new limits in the manual.
Updated Makefile.in
-Version 1.6.0beta15 [February 29, 2012]
+Version 1.6.0beta15 [March 2, 2012]
Removed unused "current_text" members of png_struct and the png_free()
of png_ptr->current_text from pngread.c
Rewrote pngstest.c for substantial speed improvement.
Fixed transparent pixel and 16-bit rgb tests in pngstest and removed a
spurious check in pngwrite.c
+ Added PNG_IMAGE_FLAG_FAST for the benefit of applications that store
+ intermediate files, or intermediate in-memory data, while processing
+ image data with the simplified API. The option makes the files larger
+ but faster to write and read. pngstest now uses this by default; this
+ can be disabled with the --slow option.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
diff --git a/contrib/libtests/pngstest.c b/contrib/libtests/pngstest.c
index 19b632e..0fff6cc 100644
--- a/contrib/libtests/pngstest.c
+++ b/contrib/libtests/pngstest.c
@@ -304,6 +304,7 @@
#define KEEP_TMPFILES 16 /* else delete temporary files */
#define KEEP_GOING 32
#define ACCUMULATE 64
+#define FAST_WRITE 128
static void
print_opts(png_uint_32 opts)
@@ -1932,7 +1933,7 @@
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
}, { /* input: sRGB-rgb */
- { 0, 0, 17, 0 }, { 0, 0, 17, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
+ { 0, 0, 19, 0 }, { 0, 0, 19, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 863, 0 }, { 0, 0, 863, 0 }, { 0, 0, 811, 0 }, { 0, 0, 811, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
@@ -2010,7 +2011,7 @@
}, { /* input: sRGB-gray+alpha */
{ 0, 6, 3, 0 }, { 0, 53, 3, 0 }, { 0, 6, 3, 0 }, { 0, 53, 3, 0 }
}, { /* input: sRGB-rgb */
- { 0, 0, 17, 0 }, { 0, 0, 17, 0 }, { 0, 0, 14, 0 }, { 0, 0, 14, 0 }
+ { 0, 0, 19, 0 }, { 0, 0, 19, 0 }, { 0, 0, 15, 0 }, { 0, 0, 15, 0 }
}, { /* input: sRGB-rgb+alpha */
{ 0, 8, 10, 0 }, { 0, 13, 10, 0 }, { 0, 12, 8, 0 }, { 0, 53, 8, 0 }
}, { /* input: linear-gray */
@@ -3083,6 +3084,9 @@
static int
write_one_file(Image *output, Image *image, int convert_to_8bit)
{
+ if (image->opts & FAST_WRITE)
+ image->image.flags |= PNG_IMAGE_FLAG_FAST;
+
if (image->opts & USE_STDIO)
{
FILE *f = tmpfile();
@@ -3303,7 +3307,7 @@
int
main(int argc, char **argv)
{
- png_uint_32 opts = 0;
+ png_uint_32 opts = FAST_WRITE;
format_list formats;
const char *touch = NULL;
int log_pass = 0;
@@ -3347,6 +3351,10 @@
opts &= ~KEEP_TMPFILES;
else if (strcmp(arg, "--keep-going") == 0)
opts |= KEEP_GOING;
+ else if (strcmp(arg, "--fast") == 0)
+ opts |= FAST_WRITE;
+ else if (strcmp(arg, "--slow") == 0)
+ opts &= ~FAST_WRITE;
else if (strcmp(arg, "--accumulate") == 0)
opts |= ACCUMULATE;
else if (strcmp(arg, "--redundant") == 0)
diff --git a/png.h b/png.h
index c4cda1a..6e82264 100644
--- a/png.h
+++ b/png.h
@@ -1,7 +1,7 @@
/* png.h - header file for PNG reference library
*
- * libpng version 1.6.0beta15 - February 27, 2012
+ * libpng version 1.6.0beta15 - March 2, 2012
* Copyright (c) 1998-2012 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.0beta15 - February 27, 2012: Glenn
+ * libpng versions 0.97, January 1998, through 1.6.0beta15 - March 2, 2012: Glenn
* See also "Contributing Authors", below.
*
* Note about libpng version numbers:
@@ -198,7 +198,7 @@
*
* This code is released under the libpng license.
*
- * libpng versions 1.2.6, August 15, 2004, through 1.6.0beta15, February 27, 2012, are
+ * libpng versions 1.2.6, August 15, 2004, through 1.6.0beta15, March 2, 2012, are
* Copyright (c) 2004, 2006-2012 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:
@@ -310,7 +310,7 @@
* Y2K compliance in libpng:
* =========================
*
- * February 27, 2012
+ * March 2, 2012
*
* Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration.
@@ -376,7 +376,7 @@
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.6.0beta15"
#define PNG_HEADER_VERSION_STRING \
- " libpng version 1.6.0beta15 - February 27, 2012\n"
+ " libpng version 1.6.0beta15 - March 2, 2012\n"
#define PNG_LIBPNG_VER_SONUM 16
#define PNG_LIBPNG_VER_DLLNUM 16
@@ -2943,6 +2943,17 @@
* correspond to the red, green and blue end-points defined by sRGB.
*/
+#define PNG_IMAGE_FLAG_FAST 0x02
+ /* On write emphasise speed over compression; the resultant PNG file will be
+ * larger but will be produced significantly faster, particular for large
+ * images. Do not use this option for images which will be distributed, only
+ * used it when producing intermediate files that will be read back in
+ * repeatedly. For a typical 24-bit image the option will double the read
+ * speed at the cost of increasing the image size by 25%, however for many
+ * more compressible images the PNG file can be 10 times larger with only a
+ * slight speed gain.
+ */
+
#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
/* READ APIs
* ---------
diff --git a/pngwrite.c b/pngwrite.c
index ed741d0..8281b64 100644
--- a/pngwrite.c
+++ b/pngwrite.c
@@ -731,6 +731,15 @@
}
#endif
+#if 0 /* To do: implement png_do_check_palette_indexes() */
+ /* Check for out-of-range palette index */
+ if (png_ptr->num_palette < (1 << png_ptr->bit_depth))
+ png_do_check_palette_indexes(&row_info, png_ptr->row_buf + 1,
+ png_ptr->num_palette_max);
+ if (png_ptr->num_palette_max > num_palette + 1)
+ png_warning(png_ptr, "Palette index exceeded num_palette");
+#endif
+
/* Find a filter if necessary, filter the row and write it out. */
png_write_find_filter(png_ptr, &row_info);
@@ -2109,6 +2118,18 @@
display->row_bytes = row_bytes;
}
+ /* Apply 'fast' options if the flag is set. */
+ if ((image->flags & PNG_IMAGE_FLAG_FAST) != 0)
+ {
+ png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, PNG_NO_FILTERS);
+ /* NOTE: determined by experiment using pngstest, this reflects some
+ * balance between the time to write the image once and the time to read
+ * it about 50 times. The speed-up in pngstest was about 10-20% of the
+ * total (user) time on a heavily loaded system.
+ */
+ png_set_compression_level(png_ptr, 3);
+ }
+
/* Check for the cases that currently require a pre-transform on the row
* before it is written. This only applies when the input is 16-bit and
* either there is an alpha channel or it is converted to 8-bit.