mirror of
https://git.code.sf.net/p/libpng/code.git
synced 2025-07-10 18:04:09 +02:00
Fixes for !READ_INTERLACE/!READ_PNG interpendencies
The reliance of png_read_png on interlace handling and some minor issues in the test programs where they failed to correctly check for interlace handling were exposed by the ability to write interlaced images even if WRITE_INTERLACING is turned off. This is fixed here. Signed-off-by: John Bowler <jbowler@acm.org>
This commit is contained in:
parent
b69df74b8e
commit
6803b09cb7
@ -36,7 +36,8 @@
|
||||
# include <setjmp.h> /* because png.h did *not* include this */
|
||||
#endif
|
||||
|
||||
#if defined(PNG_INFO_IMAGE_SUPPORTED) && defined(PNG_SEQUENTIAL_READ_SUPPORTED)
|
||||
#if defined(PNG_INFO_IMAGE_SUPPORTED) && defined(PNG_SEQUENTIAL_READ_SUPPORTED)\
|
||||
&& defined(PNG_READ_PNG_SUPPORTED)
|
||||
/* If a transform is valid on both read and write this implies that if the
|
||||
* transform is applied to read it must also be applied on write to produce
|
||||
* meaningful data. This is because these transforms when performed on read
|
||||
@ -1676,7 +1677,7 @@ main(const int argc, const char * const * const argv)
|
||||
return errors != 0;
|
||||
}
|
||||
}
|
||||
#else /* !PNG_INFO_IMAGE_SUPPORTED || !PNG_READ_SUPPORTED */
|
||||
#else /* !INFO_IMAGE || !SEQUENTIAL_READ || !READ_PNG*/
|
||||
int
|
||||
main(void)
|
||||
{
|
||||
|
@ -3574,6 +3574,14 @@ check_interlace_type(int const interlace_type)
|
||||
#define CAN_WRITE_INTERLACE\
|
||||
PNG_LIBPNG_VER >= 10700 || defined PNG_WRITE_INTERLACING_SUPPORTED
|
||||
|
||||
/* Do the same thing for read interlacing; this controls whether read tests do
|
||||
* their own de-interlace or use libpng.
|
||||
*/
|
||||
#ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
# define do_read_interlace 0
|
||||
#else /* no libpng read interlace support */
|
||||
# define do_read_interlace 1
|
||||
#endif
|
||||
/* The following two routines use the PNG interlace support macros from
|
||||
* png.h to interlace or deinterlace rows.
|
||||
*/
|
||||
@ -4827,8 +4835,19 @@ standard_info_part1(standard_display *dp, png_structp pp, png_infop pi)
|
||||
* turning on interlace handling (if do_interlace is not set.)
|
||||
*/
|
||||
dp->npasses = npasses_from_interlace_type(pp, dp->interlace_type);
|
||||
if (!dp->do_interlace && dp->npasses != png_set_interlace_handling(pp))
|
||||
png_error(pp, "validate: file changed interlace type");
|
||||
if (!dp->do_interlace)
|
||||
{
|
||||
# ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
if (dp->npasses != png_set_interlace_handling(pp))
|
||||
png_error(pp, "validate: file changed interlace type");
|
||||
# else /* !READ_INTERLACING */
|
||||
/* This should never happen: the relevant tests (!do_interlace) should
|
||||
* not be run.
|
||||
*/
|
||||
if (dp->npasses > 1)
|
||||
png_error(pp, "validate: no libpng interlace support");
|
||||
# endif /* !READ_INTERLACING */
|
||||
}
|
||||
|
||||
/* Caller calls png_read_update_info or png_start_read_image now, then calls
|
||||
* part2.
|
||||
@ -5323,7 +5342,7 @@ test_standard(png_modifier* const pm, png_byte const colour_type,
|
||||
interlace_type < INTERLACE_LAST; ++interlace_type)
|
||||
{
|
||||
standard_test(&pm->this, FILEID(colour_type, DEPTH(bdlo), 0/*palette*/,
|
||||
interlace_type, 0, 0, 0), 0/*do_interlace*/, pm->use_update_info);
|
||||
interlace_type, 0, 0, 0), do_read_interlace, pm->use_update_info);
|
||||
|
||||
if (fail(pm))
|
||||
return 0;
|
||||
@ -6028,7 +6047,7 @@ transform_display_init(transform_display *dp, png_modifier *pm, png_uint_32 id,
|
||||
memset(dp, 0, sizeof *dp);
|
||||
|
||||
/* Standard fields */
|
||||
standard_display_init(&dp->this, &pm->this, id, 0/*do_interlace*/,
|
||||
standard_display_init(&dp->this, &pm->this, id, do_read_interlace,
|
||||
pm->use_update_info);
|
||||
|
||||
/* Parameter fields */
|
||||
@ -8718,7 +8737,7 @@ gamma_display_init(gamma_display *dp, png_modifier *pm, png_uint_32 id,
|
||||
double background_gamma)
|
||||
{
|
||||
/* Standard fields */
|
||||
standard_display_init(&dp->this, &pm->this, id, 0/*do_interlace*/,
|
||||
standard_display_init(&dp->this, &pm->this, id, do_read_interlace,
|
||||
pm->use_update_info);
|
||||
|
||||
/* Parameter fields */
|
||||
|
@ -4362,7 +4362,11 @@ png_read_process_IDAT(png_structrp png_ptr, png_bytep transformed_row,
|
||||
# if defined(PNG_PROGRESSIVE_READ_SUPPORTED) ||\
|
||||
defined(PNG_READ_INTERLACING_SUPPORTED)
|
||||
if (png_ptr->transform_list != NULL &&
|
||||
(save_row || (png_ptr->do_interlace && pass < 6U)))
|
||||
(save_row
|
||||
# ifdef PNG_READ_INTERLACING_SUPPORTED
|
||||
|| (png_ptr->do_interlace && pass < 6U)
|
||||
# endif /* READ_INTERLACING */
|
||||
))
|
||||
{
|
||||
if (png_ptr->transformed_row == NULL)
|
||||
png_ptr->transformed_row = png_voidcast(png_bytep,
|
||||
|
@ -947,7 +947,7 @@ option WRITE_zTXt enables WRITE_COMPRESSED_TEXT
|
||||
# leave the row_pointers member out of the info structure.
|
||||
|
||||
option INFO_IMAGE disabled
|
||||
option READ_PNG requires SEQUENTIAL_READ READ_TRANSFORMS enables INFO_IMAGE
|
||||
option READ_PNG requires READ_IMAGE READ_TRANSFORMS enables INFO_IMAGE
|
||||
option WRITE_PNG requires WRITE WRITE_TRANSFORMS enables INFO_IMAGE
|
||||
|
||||
# There are four options here, two each for read and write. By default they are
|
||||
|
Loading…
x
Reference in New Issue
Block a user