[master] Change some instances of PNG_READ_UNKNOWN_CHUNKS_SUPPORTED

to PNG_HANDLE_AS_UNKNOWN to make it possible to build a libpng that can
use the png_set_keep_unknown_chunks() mechanism to ignore unused chunks
without having to save unknown chunks.
This commit is contained in:
Glenn Randers-Pehrson 2009-06-15 20:50:00 -05:00
parent b278e91338
commit bbe589da44
7 changed files with 75 additions and 63 deletions

View File

@ -1,5 +1,5 @@
Libpng 1.2.38beta01 - June 5, 2009
Libpng 1.2.38beta01 - June 12, 2009
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.
@ -69,20 +69,26 @@ version 1.2.37rc01 [May 27, 2009]
No changes.
versions 1.2.37 and 1.0.45 [June 4, 2009]
Reformatted several remaining "else statement;" and "if () statment;" into
Reformatted several remaining "else statement;" and "if () statement;" into
two lines.
Added "#define PNG_NO_WRITE_SWAP" to contrib/pngminim/encoder/pngusr.h
and "define PNG_NO_READ_SWAP" to decoder/pngusr.h and preader/pngusr.h
Added sections about the git repository and our coding style to the
documentation (merged from libpng-1.4.0beta62)
Added a section about using png_get_io_ptr() in configure scripts to detect
the presence of libpng.
Added a section in the documentation about using png_get_io_ptr() in
configure scripts to detect the presence of libpng.
versions 1.2.38 [June 5, 2009]
version 1.2.38beta01 [June 12, 2009]
Revised libpng*.txt and libpng.3 to mention calling png_set_IHDR()
multiple times and to specify the sample order in the tRNS chunk,
because the ISO PNG specification has a typo in the tRNS table.
Changed several PNG_UNKNOWN_CHUNK_SUPPORTED to
PNG_HANDLE_AS_UNKNOWN_SUPPORTED, to make the png_set_keep mechanism
available for ignoring known chunks even when not saving unknown chunks.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
(subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
to subscribe) or to glennrp at users.sourceforge.net

View File

@ -2403,10 +2403,13 @@ versions 1.2.37 and 1.0.45 [June 4, 2009]
Added a section to the libpng documentation about using png_get_io_ptr()
in configure scripts to detect the presence of libpng.
versions 1.2.38 [June 8, 2009]
versions 1.2.38beta01 [June 12, 2009]
Revised libpng*.txt and libpng.3 to mention calling png_set_IHDR()
multiple times and to specify the sample order in the tRNS chunk,
because the ISO PNG specification has a typo in the tRNS table.
Changed several PNG_UNKNOWN_CHUNK_SUPPORTED to
PNG_HANDLE_AS_UNKNOWN_SUPPORTED, to make the png_set_keep mechanism
available for ignoring known chunks even when not saving unknown chunks.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

28
png.h
View File

@ -1,6 +1,6 @@
/* png.h - header file for PNG reference library
*
* libpng version 1.2.38beta01 - June 5, 2009
* libpng version 1.2.38beta01 - June 12, 2009
* Copyright (c) 1998-2009 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.)
@ -8,7 +8,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.2.38beta01 - June 5, 2009: Glenn
* libpng versions 0.97, January 1998, through 1.2.38beta01 - June 12, 2009: Glenn
* See also "Contributing Authors", below.
*
* Note about libpng version numbers:
@ -260,7 +260,7 @@
* If you modify libpng you may insert additional notices immediately following
* this sentence.
*
* libpng versions 1.2.6, August 15, 2004, through 1.2.38beta01, June 5, 2009, are
* libpng versions 1.2.6, August 15, 2004, through 1.2.38beta01, June 12, 2009, are
* Copyright (c) 2004, 2006-2009 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:
@ -372,7 +372,7 @@
* Y2K compliance in libpng:
* =========================
*
* June 5, 2009
* June 12, 2009
*
* Since the PNG Development group is an ad-hoc body, we can't make
* an official declaration.
@ -436,7 +436,7 @@
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.2.38beta01"
#define PNG_HEADER_VERSION_STRING \
" libpng version 1.2.38beta01 - June 5, 2009\n"
" libpng version 1.2.38beta01 - June 12, 2009\n"
#define PNG_LIBPNG_VER_SONUM 0
#define PNG_LIBPNG_VER_DLLNUM 13
@ -456,7 +456,7 @@
#define PNG_LIBPNG_BUILD_RC 3
#define PNG_LIBPNG_BUILD_STABLE 4
#define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7
/* Release-Specific Flags */
#define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with
PNG_LIBPNG_BUILD_STABLE only */
@ -487,12 +487,12 @@
/* Ref MSDN: Private as priority over Special
* VS_FF_PRIVATEBUILD File *was not* built using standard release
* procedures. If this value is given, the StringFileInfo block must
* contain a PrivateBuild string.
* contain a PrivateBuild string.
*
* VS_FF_SPECIALBUILD File *was* built by the original company using
* standard release procedures but is a variation of the standard
* file of the same version number. If this value is given, the
* StringFileInfo block must contain a SpecialBuild string.
* StringFileInfo block must contain a SpecialBuild string.
*/
#if defined(PNG_USER_PRIVATEBUILD)
@ -1399,7 +1399,7 @@ struct png_struct_def
png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
#endif
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
int num_chunk_list;
png_bytep chunk_list;
#endif
@ -2501,7 +2501,7 @@ extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr,
#endif
#endif /* PNG_sCAL_SUPPORTED || PNG_WRITE_sCAL_SUPPORTED */
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
/* provide a list of chunks and how they are to be handled, if the built-in
handling or default unknown chunk handling is not desired. Any chunks not
listed will be handled in the default manner. The IHDR and IEND chunks
@ -2513,6 +2513,10 @@ extern PNG_EXPORT(void,png_set_sCAL_s) PNGARG((png_structp png_ptr,
*/
extern PNG_EXPORT(void, png_set_keep_unknown_chunks) PNGARG((png_structp
png_ptr, int keep, png_bytep chunk_list, int num_chunks));
PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep
chunk_name));
#endif
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
extern PNG_EXPORT(void, png_set_unknown_chunks) PNGARG((png_structp png_ptr,
png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns));
extern PNG_EXPORT(void, png_set_unknown_chunk_location)
@ -2520,10 +2524,6 @@ extern PNG_EXPORT(void, png_set_unknown_chunk_location)
extern PNG_EXPORT(png_uint_32,png_get_unknown_chunks) PNGARG((png_structp
png_ptr, png_infop info_ptr, png_unknown_chunkpp entries));
#endif
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
PNG_EXPORT(int,png_handle_as_unknown) PNGARG((png_structp png_ptr, png_bytep
chunk_name));
#endif
/* Png_free_data() will turn off the "valid" flag for anything it frees.
If you need to turn it off for a chunk that your application has freed,

View File

@ -1,7 +1,7 @@
/* pngconf.h - machine configurable file for libpng
*
* libpng version 1.2.38beta01 - June 5, 2009
* libpng version 1.2.38beta01 - June 12, 2009
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -19,7 +19,7 @@
#define PNG_1_2_X
/*
/*
* PNG_USER_CONFIG has to be defined on the compiler command line. This
* includes the resource compiler for Windows DLL configurations.
*/
@ -39,7 +39,7 @@
/*
* Added at libpng-1.2.8
*
*
* If you create a private DLL you need to define in "pngusr.h" the followings:
* #define PNG_USER_PRIVATEBUILD <Describes by whom and why this version of
* the DLL was built>
@ -50,8 +50,8 @@
* number and must match your private DLL name>
* e.g. // private DLL "libpng13gx.dll"
* #define PNG_USER_DLLFNAME_POSTFIX "gx"
*
* The following macros are also at your disposal if you want to complete the
*
* The following macros are also at your disposal if you want to complete the
* DLL VERSIONINFO structure.
* - PNG_USER_VERSIONINFO_COMMENTS
* - PNG_USER_VERSIONINFO_COMPANYNAME
@ -147,9 +147,9 @@
* 'Cygwin' defines/defaults:
* PNG_BUILD_DLL -- (ignored) building the dll
* (no define) -- (ignored) building an application, linking to the dll
* PNG_STATIC -- (ignored) building the static lib, or building an
* PNG_STATIC -- (ignored) building the static lib, or building an
* application that links to the static lib.
* ALL_STATIC -- (ignored) building various static libs, or building an
* ALL_STATIC -- (ignored) building various static libs, or building an
* application that links to the static libs.
* Thus,
* a cygwin user should define either PNG_BUILD_DLL or PNG_STATIC, and
@ -162,12 +162,12 @@
* PNG_BUILD_DLL
* PNG_STATIC
* (nothing) == PNG_USE_DLL
*
*
* CYGWIN (2002-01-20): The preceding is now obsolete. With the advent
* of auto-import in binutils, we no longer need to worry about
* of auto-import in binutils, we no longer need to worry about
* __declspec(dllexport) / __declspec(dllimport) and friends. Therefore,
* we don't need to worry about PNG_STATIC or ALL_STATIC when it comes
* to __declspec() stuff. However, we DO need to worry about
* to __declspec() stuff. However, we DO need to worry about
* PNG_BUILD_DLL and PNG_STATIC because those change some defaults
* such as CONSOLE_IO and whether GLOBAL_ARRAYS are allowed.
*/
@ -211,8 +211,8 @@
# if !defined(PNG_DLL)
# define PNG_DLL
# endif
# endif
# endif
# endif
# endif
# endif
#endif
@ -487,7 +487,7 @@
* iTXt support was added. iTXt support was turned off by default through
* libpng-1.2.x, to support old apps that malloc the png_text structure
* instead of calling png_set_text() and letting libpng malloc it. It
* was turned on by default in libpng-1.3.0.
* was turned on by default in libpng-1.4.0.
*/
#if defined(PNG_1_0_X) || defined (PNG_1_2_X)
@ -741,7 +741,7 @@
# define PNG_EASY_ACCESS_SUPPORTED
#endif
/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0
/* PNG_ASSEMBLER_CODE was enabled by default in version 1.2.0
* and removed from version 1.2.20. The following will be removed
* from libpng-1.4.0
*/
@ -945,9 +945,6 @@
# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
# define PNG_UNKNOWN_CHUNKS_SUPPORTED
# endif
# ifndef PNG_NO_HANDLE_AS_UNKNOWN
# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
# endif
#endif
#if !defined(PNG_NO_READ_USER_CHUNKS) && \
defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
@ -960,6 +957,11 @@
# undef PNG_NO_HANDLE_AS_UNKNOWN
# endif
#endif
#ifndef PNG_NO_HANDLE_AS_UNKNOWN
# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
# endif
#endif
#ifndef PNG_NO_READ_OPT_PLTE
# define PNG_READ_OPT_PLTE_SUPPORTED /* only affects support of the */
#endif /* optional PLTE chunk in RGB and RGBA images */
@ -1087,10 +1089,10 @@
# ifndef PNG_UNKNOWN_CHUNKS_SUPPORTED
# define PNG_UNKNOWN_CHUNKS_SUPPORTED
# endif
# ifndef PNG_NO_HANDLE_AS_UNKNOWN
# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
# endif
#endif
#ifndef PNG_NO_HANDLE_AS_UNKNOWN
# ifndef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
# define PNG_HANDLE_AS_UNKNOWN_SUPPORTED
# endif
#endif
#if defined(PNG_WRITE_iTXt_SUPPORTED) || defined(PNG_WRITE_tEXt_SUPPORTED) || \
@ -1248,7 +1250,7 @@ typedef char FAR * FAR * FAR * png_charppp;
#if defined(PNG_1_0_X) || defined(PNG_1_2_X)
/* SPC - Is this stuff deprecated? */
/* It'll be removed as of libpng-1.3.0 - GR-P */
/* It'll be removed as of libpng-1.4.0 - GR-P */
/* libpng typedefs for types in zlib. If zlib changes
* or another compression library is used, then change these.
* Eliminates need to change all the source files.
@ -1321,7 +1323,7 @@ typedef z_stream FAR * png_zstreamp;
# define PNGAPI __cdecl
# undef PNG_IMPEXP
# define PNG_IMPEXP
#endif
#endif
/* If you define PNGAPI, e.g., with compiler option "-DPNGAPI=__stdcall",
* you may get warnings regarding the linkage of png_zalloc and png_zfree.

View File

@ -1,7 +1,7 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
* Last changed in libpng 1.2.37 [June 4, 2009]
* Last changed in libpng 1.2.38 [June 12, 2009]
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -1177,10 +1177,6 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
{
if (png_ptr->transformations & PNG_EXPAND_tRNS)
info_ptr->color_type |= PNG_COLOR_MASK_ALPHA;
#if 0 /* Removed from libpng-1.2.27 */
else
info_ptr->color_type |= PNG_COLOR_MASK_COLOR;
#endif
}
if (info_ptr->bit_depth < 8)
info_ptr->bit_depth = 8;
@ -1374,12 +1370,12 @@ png_do_read_transformations(png_structp png_ptr)
#endif
/* From Andreas Dilger e-mail to png-implement, 26 March 1998:
*
*
* In most cases, the "simple transparency" should be done prior to doing
* gray-to-RGB, or you will have to test 3x as many bytes to check if a
* pixel is transparent. You would also need to make sure that the
* transparency information is upgraded to RGB.
*
*
* To summarize, the current flow is:
* - Gray + simple transparency -> compare 1 or 2 gray bytes and composite
* with background "in place" if transparent,
@ -4202,7 +4198,7 @@ png_build_gamma_table(png_structp png_ptr)
png_ptr->gamma_16_table = (png_uint_16pp)png_malloc(png_ptr,
(png_uint_32)(num * png_sizeof(png_uint_16p)));
png_memset(png_ptr->gamma_16_table, 0, num * png_sizeof(png_uint_16p));
png_memset(png_ptr->gamma_16_table, 0, num * png_sizeof(png_uint_16p));
if (png_ptr->transformations & (PNG_16_TO_8 | PNG_BACKGROUND))
{
@ -4264,7 +4260,7 @@ png_build_gamma_table(png_structp png_ptr)
png_ptr->gamma_16_to_1 = (png_uint_16pp)png_malloc(png_ptr,
(png_uint_32)(num * png_sizeof(png_uint_16p )));
png_memset(png_ptr->gamma_16_to_1, 0, num * png_sizeof(png_uint_16p));
png_memset(png_ptr->gamma_16_to_1, 0, num * png_sizeof(png_uint_16p));
for (i = 0; i < num; i++)
{
@ -4290,7 +4286,7 @@ png_build_gamma_table(png_structp png_ptr)
png_ptr->gamma_16_from_1 = (png_uint_16pp)png_malloc(png_ptr,
(png_uint_32)(num * png_sizeof(png_uint_16p)));
png_memset(png_ptr->gamma_16_from_1, 0,
num * png_sizeof(png_uint_16p));
num * png_sizeof(png_uint_16p));
for (i = 0; i < num; i++)
{

View File

@ -1,7 +1,7 @@
/* pngrutil.c - utilities to read a PNG file
*
* Last changed in libpng 1.2.37 [June 4, 2009]
* Last changed in libpng 1.2.38 [June 12, 2009]
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -2251,7 +2251,7 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (!(png_ptr->chunk_name[0] & 0x20))
{
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
#if defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
PNG_HANDLE_CHUNK_ALWAYS
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
@ -2263,8 +2263,11 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED)
if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS) ||
(png_ptr->read_user_chunk_fn != NULL))
if ((png_ptr->flags & PNG_FLAG_KEEP_UNKNOWN_CHUNKS)
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED)
|| (png_ptr->read_user_chunk_fn != NULL)
#endif
)
{
#ifdef PNG_MAX_MALLOC_64K
if (length > (png_uint_32)65535L)
@ -2275,7 +2278,7 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
}
#endif
png_memcpy((png_charp)png_ptr->unknown_chunk.name,
(png_charp)png_ptr->chunk_name,
(png_charp)png_ptr->chunk_name,
png_sizeof(png_ptr->unknown_chunk.name));
png_ptr->unknown_chunk.name[png_sizeof(png_ptr->unknown_chunk.name)-1] = '\0';
png_ptr->unknown_chunk.size = (png_size_t)length;
@ -2298,8 +2301,10 @@ png_handle_unknown(png_structp png_ptr, png_infop info_ptr, png_uint_32 length)
if (ret == 0)
{
if (!(png_ptr->chunk_name[0] & 0x20))
#if defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
if (png_handle_as_unknown(png_ptr, png_ptr->chunk_name) !=
PNG_HANDLE_CHUNK_ALWAYS)
#endif
png_chunk_error(png_ptr, "unknown critical chunk");
png_set_unknown_chunks(png_ptr, info_ptr,
&png_ptr->unknown_chunk, 1);

View File

@ -1,7 +1,7 @@
/* pngset.c - storage of image information into info struct
*
* Last changed in libpng 1.2.37 [June 4, 2009]
* Last changed in libpng 1.2.38 [June 12, 2009]
* For conditions of distribution and use, see copyright notice in png.h
* Copyright (c) 1998-2009 Glenn Randers-Pehrson
* (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger)
@ -1004,7 +1004,7 @@ png_set_sPLT(png_structp png_ptr,
}
#endif /* PNG_sPLT_SUPPORTED */
#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED)
#if defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
void PNGAPI
png_set_unknown_chunks(png_structp png_ptr,
png_infop info_ptr, png_unknown_chunkp unknowns, int num_unknowns)
@ -1035,8 +1035,8 @@ png_set_unknown_chunks(png_structp png_ptr,
png_unknown_chunkp to = np + info_ptr->unknown_chunks_num + i;
png_unknown_chunkp from = unknowns + i;
png_memcpy((png_charp)to->name,
(png_charp)from->name,
png_memcpy((png_charp)to->name,
(png_charp)from->name,
png_sizeof(from->name));
to->name[png_sizeof(to->name)-1] = '\0';
to->size = from->size;