diff options
author | Glenn Randers-Pehrson <glennrp at users.sourceforge.net> | 2011-04-06 07:07:42 -0500 |
---|---|---|
committer | Glenn Randers-Pehrson <glennrp at users.sourceforge.net> | 2011-04-06 07:07:42 -0500 |
commit | 28534bd47a511fdfe8a544ddee09eba70debdbf3 (patch) | |
tree | 3b526d10b5082621e4319754cc5a86ec0f485f82 | |
parent | 2053a268734203f7773ff99a321f7c8dfbe5583c (diff) | |
download | libpng-28534bd47a511fdfe8a544ddee09eba70debdbf3.tar.gz |
[master] Improved the optimization of the zlib CMF byte
(see libpng-1.2.6beta03).
-rw-r--r-- | ANNOUNCE | 8 | ||||
-rw-r--r-- | CHANGES | 6 | ||||
-rw-r--r-- | pngwutil.c | 15 |
3 files changed, 26 insertions, 3 deletions
@@ -1,5 +1,5 @@ -Libpng 1.4.6rc02 - April 3, 2011 +Libpng 1.4.6rc02 - April 6, 2011 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. @@ -67,7 +67,11 @@ version 1.4.6beta07 [March 22, 2011] Fixed a bug (present since libpng-1.0.7) that makes png_handle_sPLT() fail to compile when PNG_NO_POINTER_INDEXING is defined (Chubanov Kirill) -version 1.4.6rc01 [April 3, 2011] +version 1.4.6rc01 [March 31, 2011] + No changes. + +version 1.4.6rc02 [April 6, 2011] + Improved the optimization of the zlib CMF byte (see libpng-1.2.6beta03). Send comments/corrections/commendations to glennrp at users.sourceforge.net or to png-mng-implement at lists.sf.net (subscription required; visit @@ -2779,7 +2779,11 @@ version 1.4.6beta07 [March 22, 2011] Fixed a bug (present since libpng-1.0.7) that makes png_handle_sPLT() fail to compile when PNG_NO_POINTER_INDEXING is defined (Chubanov Kirill) -version 1.4.6rc01 [April 3, 2011] +version 1.4.6rc01 [March 31, 2011] + No changes. + +version 1.4.6rc02 [April 6, 2011] + Improved the optimization of the zlib CMF byte (see libpng-1.2.6beta03). Send comments/corrections/commendations to glennrp at users.sourceforge.net or to png-mng-implement at lists.sf.net (subscription required; visit diff --git a/pngwutil.c b/pngwutil.c index 8f7c7c24d..b73c6a9d9 100644 --- a/pngwutil.c +++ b/pngwutil.c @@ -682,9 +682,24 @@ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length) if (length >= 2 && png_ptr->height < 16384 && png_ptr->width < 16384) { + /* Compute the maximum possible length of the datastream */ + + /* Number of pixels, plus for each row a filter byte and possible + * and possibly a padding byte, so increase the maximum + * size to account for these. + */ png_uint_32 uncompressed_idat_size = png_ptr->height * ((png_ptr->width * png_ptr->channels * png_ptr->bit_depth + 15) >> 3); + + /* If it's interlaced, each block of 8 rows is sent as up to + * 14 rows, i.e., 6 additional rows, each with a filter byte + * and possibly a padding byte + */ + if (png_ptr->interlaced) + uncompressed_idat_size += ((png_ptr->height + 7)/8) * + (png_ptr->bit_depth < 8 ? 12 : 6); + unsigned int z_cinfo = z_cmf >> 4; unsigned int half_z_window_size = 1 << (z_cinfo + 7); while (uncompressed_idat_size <= half_z_window_size && |