[devel] Added PNG_WRITE_OPTIMIZE_CMF_SUPPORTED macro to make zlib "CMF"

optimization configureable.
This commit is contained in:
Glenn Randers-Pehrson 2011-05-05 16:55:20 -05:00
parent 4753906826
commit c559bb58ed
5 changed files with 18 additions and 3 deletions

View File

@ -87,6 +87,8 @@ Version 1.5.3beta05 [May 5, 2011]
requiring the host OS to implement snprintf. As a side effect the
dependency of the tIME-supporting RFC1132 code on stdio is removed and
PNG_NO_WARNINGS does actually work now.
Added PNG_WRITE_OPTIMIZE_CMF_SUPPORTED macro to make the zlib "CMF" byte
optimization configureable.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net:
(subscription required; visit

View File

@ -3346,6 +3346,8 @@ Version 1.5.3beta05 [May 5, 2011]
requiring the host OS to implement snprintf. As a side effect the
dependency of the tIME-supporting RFC1132 code on stdio is removed and
PNG_NO_WARNINGS does actually work now.
Added PNG_WRITE_OPTIMIZE_CMF_SUPPORTED macro to make the zlib "CMF" byte
optimization configureable.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

View File

@ -447,6 +447,7 @@ png_write_compressed_data_out(png_structp png_ptr, compression_state *comp)
return;
}
#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
if (comp->input_len >= 2 && comp->input_len < 16384)
{
unsigned int z_cmf; /* zlib compression method and flags */
@ -464,12 +465,12 @@ png_write_compressed_data_out(png_structp png_ptr, compression_state *comp)
{
unsigned int z_cinfo;
unsigned int half_z_window_size;
png_size_t uncompressed_idat_size = comp->input_len;
png_size_t uncompressed_text_size = comp->input_len;
z_cinfo = z_cmf >> 4;
half_z_window_size = 1 << (z_cinfo + 7);
while (uncompressed_idat_size <= half_z_window_size &&
while (uncompressed_text_size <= half_z_window_size &&
half_z_window_size >= 256)
{
z_cinfo--;
@ -506,6 +507,7 @@ png_write_compressed_data_out(png_structp png_ptr, compression_state *comp)
png_error(png_ptr,
"Invalid zlib compression method or flags in non-IDAT chunk");
}
#endif /* PNG_WRITE_OPTIMIZE_CMF_SUPPORTED */
/* Write saved output buffers, if any */
for (i = 0; i < comp->num_output_ptr; i++)
@ -838,7 +840,9 @@ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
if (!(png_ptr->mode & PNG_HAVE_IDAT) &&
png_ptr->compression_type == PNG_COMPRESSION_TYPE_BASE)
{
#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
unsigned int z_cmf; /* zlib compression method and flags */
#endif /* PNG_WRITE_OPTIMIZE_CMF_SUPPORTED */
#ifdef PNG_WRITE_COMPRESSED_TEXT_SUPPORTED
int ret;
@ -880,6 +884,7 @@ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
*/
png_ptr->zstream.data_type = Z_BINARY;
#ifdef PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
/* Optimize the CMF field in the zlib stream. This hack of the zlib
* stream is compliant to the stream specification.
*/
@ -941,6 +946,7 @@ png_write_IDAT(png_structp png_ptr, png_bytep data, png_size_t length)
else
png_error(png_ptr,
"Invalid zlib compression method or flags in IDAT");
#endif /* PNG_WRITE_OPTIMIZE_CMF_SUPPORTED */
}
png_write_chunk(png_ptr, png_IDAT, data, length);

View File

@ -6,7 +6,7 @@
#
com pnglibconf.h - library build configuration
com
com libpng version 1.5.0 - January 6, 2011
com libpng version 1.5.3 - (PENDING RELEASE)
com
com Copyright (c) 1998-2011 Glenn Randers-Pehrson
com
@ -550,6 +550,9 @@ option SAVE_INT_32 requires WRITE
# png_save_int_32 is required by the ancillary chunks oFFs and pCAL
# added at libpng-1.5.3
option WRITE_OPTIMIZE_CMF requires WRITE
option READ_iCCP enables READ_COMPRESSED_TEXT
option READ_iTXt enables READ_COMPRESSED_TEXT
option READ_zTXt enables READ_COMPRESSED_TEXT
@ -563,6 +566,7 @@ option WRITE_iTXt enables WRITE_COMPRESSED_TEXT
option WRITE_zTXt enables WRITE_COMPRESSED_TEXT
option WRITE_COMPRESSED_TEXT enables WRITE_TEXT
# Turn this off to disable png_read_png() and png_write_png() and
# leave the row_pointers member out of the info structure.

View File

@ -156,6 +156,7 @@
#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION
#define PNG_WRITE_iTXt_SUPPORTED
#define PNG_WRITE_oFFs_SUPPORTED
#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED
#define PNG_WRITE_PACK_SUPPORTED
#define PNG_WRITE_PACKSWAP_SUPPORTED
#define PNG_WRITE_pCAL_SUPPORTED