mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Filter selection, palette index checks
Palette index checking: checking on read was erroneously skipped. pngcp can now turn off the palette index checking or fix the errors (mainly to allow comparison with libpng 1.6, which defaulted to ignoring it). The API now documents how the 'enabled' parameter works. On read the check is on by default (it was apparently off in libpng 1.6) however now if explicitly turned on the warning message is stopped, this provides better interaction with get_palette_max at the cost of a small API change (may need to be reviewed.) Palette size errors: invalid entries in the palette are now set to #beaded to make the errors more obvious and allow easy detection in memory. Read transform pipeline caching: changes to fix the palette index check (which are erroneously cached), the pipeline can now contain multiple caches. E.g. caching of packing of palette indices can be combined with caching of palette RGB transforms. Read code now checks for callbacks to read 0 data (and faults them). Fixed the reading of PNGs with multiple 0 length IDATs that failed as a result plus the handling of zero length unknown. (Which occurs, validly; the spurious warning has been removed). filter selection: the 1.6 and earlier sum of absolute differences algorithm has been reintroduced with an option to disfavor some filters over others where the sums are close (not yet exposed). The selection code also logs the last known occurence of each possible byte code across multiple lines. This allows detection of PNG images with lower bit depth than the format implies and, therefore, allows the filtering to be turned off in those cases as well. The default write zlib settings are still lower than libpng16. The selection algorithm is being refined (the overall results are worse than not doing any filtering). Signed-off-by: John Bowler <jbowler@acm.org>
This commit is contained in:
16
pngstruct.h
16
pngstruct.h
@@ -393,13 +393,15 @@ struct png_struct_def
|
||||
unsigned int num_trans :9; /* number of transparency values */
|
||||
unsigned int transparent_palette :1; /* if they are all 0 or 255 */
|
||||
#endif /* READ_tRNS */
|
||||
#ifdef PNG_GET_PALETTE_MAX_SUPPORTED
|
||||
unsigned int palette_index_max :9; /* maximum palette index found in IDAT */
|
||||
#endif /* GET_PALETTE_MAX */
|
||||
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
unsigned int palette_index_check_disabled :1; /* defaults to 0, 'enabled' */
|
||||
unsigned int palette_index_check_issued :1; /* error message output */
|
||||
#endif /* CHECK_FOR_INVALID_INDEX */
|
||||
#ifdef PNG_PALETTE_MAX_SUPPORTED
|
||||
unsigned int palette_index_max :8; /* maximum palette index in IDAT */
|
||||
unsigned int palette_index_check :2; /* one of the following: */
|
||||
# define PNG_PALETTE_CHECK_DEFAULT 0U
|
||||
# define PNG_PALETTE_CHECK_OFF 1U
|
||||
# define PNG_PALETTE_CHECK_ON 2U
|
||||
unsigned int palette_index_have_max :1; /* max is being set */
|
||||
unsigned int palette_index_check_issued :1; /* error message output */
|
||||
#endif /* PALETTE_MAX */
|
||||
#ifdef PNG_READ_tRNS_SUPPORTED
|
||||
png_color_16 trans_color; /* transparent color for non-paletted files */
|
||||
#endif /* READ_tRNS */
|
||||
|
||||
Reference in New Issue
Block a user