[libpng16] Allow fine grain control of unknown chunk APIs. This change allows

png_set_keep_unknown_chunks() to be turned off if not required and causes
both read and write to behave appropriately (on read this is only possible
if the user callback is used to handle unknown chunks).  The change
also removes the support for storing unknown chunks in the info_struct
if the only unknown handling enabled is via the callback, allowing libpng
to be configured with callback reading and none of the unnecessary code.
This commit is contained in:
John Bowler
2012-08-16 16:12:13 -05:00
committed by Glenn Randers-Pehrson
parent 025d415838
commit 4a6c6df6c7
7 changed files with 74 additions and 20 deletions

View File

@@ -35,6 +35,10 @@ write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr,
++up)
if (up->location & where)
{
/* If per-chunk unknown chunk handling is enabled use it, otherwise
* just write the chunks the application has set.
*/
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
int keep = png_handle_as_unknown(png_ptr, up->name);
/* NOTE: this code is radically different from the read side in the
@@ -54,6 +58,7 @@ write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr,
keep == PNG_HANDLE_CHUNK_ALWAYS ||
(keep == PNG_HANDLE_CHUNK_AS_DEFAULT &&
png_ptr->unknown_default == PNG_HANDLE_CHUNK_ALWAYS)))
#endif
{
/* TODO: review, what is wrong with a zero length unknown chunk? */
if (up->size == 0)
@@ -872,7 +877,7 @@ png_write_destroy(png_structrp png_ptr)
png_free(png_ptr, png_ptr->inv_filter_costs);
#endif
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
png_free(png_ptr, png_ptr->chunk_list);
#endif