[libpng16] test: Fix "make check" in all branches beyond 'libpng16'

This corrects the checks to that libpng 10800 does not turn on the
enhanced transform checks in either pngvalid or pngstest.  The correct
fix is to change the 10700 code for comments which explain what aspect
or aspects of the transforms are broken (ideally) or at least state that
the transforms are broken.

This is a cherry-pick of commit aec888ab80f5d2241b3515b60f0f9337108fb624
from branch 'libpng18'.

Reviewed-by: Cosmin Truta <ctruta@gmail.com>
Signed-off-by: John Bowler <jbowler@acm.org>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
This commit is contained in:
John Bowler 2024-09-15 10:43:41 -07:00 committed by Cosmin Truta
parent 529e69e76a
commit b8a0a5401f
2 changed files with 27 additions and 27 deletions

View File

@ -3500,7 +3500,7 @@ main(int argc, char **argv)
int retval = 0; int retval = 0;
int c; int c;
#if PNG_LIBPNG_VER >= 10700 #if PNG_LIBPNG_VER == 10700
/* This error should not exist in 1.7 or later: */ /* This error should not exist in 1.7 or later: */
opts |= GBG_ERROR; opts |= GBG_ERROR;
#endif #endif

View File

@ -2574,7 +2574,7 @@ modifier_init(png_modifier *pm)
* in the rgb_to_gray check, replacing it with an exact copy of the libpng 1.5 * in the rgb_to_gray check, replacing it with an exact copy of the libpng 1.5
* algorithm. * algorithm.
*/ */
#define DIGITIZE PNG_LIBPNG_VER < 10700 #define DIGITIZE PNG_LIBPNG_VER != 10700
/* If pm->calculations_use_input_precision is set then operations will happen /* If pm->calculations_use_input_precision is set then operations will happen
* with the precision of the input, not the precision of the output depth. * with the precision of the input, not the precision of the output depth.
@ -3986,7 +3986,7 @@ transform_row(png_const_structp pp, png_byte buffer[TRANSFORM_ROWMAX],
# define check_interlace_type(type) ((void)(type)) # define check_interlace_type(type) ((void)(type))
# define set_write_interlace_handling(pp,type) png_set_interlace_handling(pp) # define set_write_interlace_handling(pp,type) png_set_interlace_handling(pp)
# define do_own_interlace 0 # define do_own_interlace 0
#elif PNG_LIBPNG_VER < 10700 #elif PNG_LIBPNG_VER != 10700
# define set_write_interlace_handling(pp,type) (1) # define set_write_interlace_handling(pp,type) (1)
static void static void
check_interlace_type(int const interlace_type) check_interlace_type(int const interlace_type)
@ -4014,7 +4014,7 @@ check_interlace_type(int const interlace_type)
# define do_own_interlace 1 # define do_own_interlace 1
#endif /* WRITE_INTERLACING tests */ #endif /* WRITE_INTERLACING tests */
#if PNG_LIBPNG_VER >= 10700 || defined PNG_WRITE_INTERLACING_SUPPORTED #if PNG_LIBPNG_VER == 10700 || defined PNG_WRITE_INTERLACING_SUPPORTED
# define CAN_WRITE_INTERLACE 1 # define CAN_WRITE_INTERLACE 1
#else #else
# define CAN_WRITE_INTERLACE 0 # define CAN_WRITE_INTERLACE 0
@ -4633,10 +4633,10 @@ static const struct
{ {
/* no warnings makes these errors undetectable prior to 1.7.0 */ /* no warnings makes these errors undetectable prior to 1.7.0 */
{ sBIT0_error_fn, "sBIT(0): failed to detect error", { sBIT0_error_fn, "sBIT(0): failed to detect error",
PNG_LIBPNG_VER < 10700 }, PNG_LIBPNG_VER != 10700 },
{ sBIT_error_fn, "sBIT(too big): failed to detect error", { sBIT_error_fn, "sBIT(too big): failed to detect error",
PNG_LIBPNG_VER < 10700 }, PNG_LIBPNG_VER != 10700 },
}; };
static void static void
@ -6236,7 +6236,7 @@ image_pixel_add_alpha(image_pixel *this, const standard_display *display,
{ {
if (this->colour_type == PNG_COLOR_TYPE_GRAY) if (this->colour_type == PNG_COLOR_TYPE_GRAY)
{ {
# if PNG_LIBPNG_VER < 10700 # if PNG_LIBPNG_VER != 10700
if (!for_background && this->bit_depth < 8) if (!for_background && this->bit_depth < 8)
this->bit_depth = this->sample_depth = 8; this->bit_depth = this->sample_depth = 8;
# endif # endif
@ -6246,7 +6246,7 @@ image_pixel_add_alpha(image_pixel *this, const standard_display *display,
/* After 1.7 the expansion of bit depth only happens if there is a /* After 1.7 the expansion of bit depth only happens if there is a
* tRNS chunk to expand at this point. * tRNS chunk to expand at this point.
*/ */
# if PNG_LIBPNG_VER >= 10700 # if PNG_LIBPNG_VER == 10700
if (!for_background && this->bit_depth < 8) if (!for_background && this->bit_depth < 8)
this->bit_depth = this->sample_depth = 8; this->bit_depth = this->sample_depth = 8;
# endif # endif
@ -7127,7 +7127,7 @@ image_transform_png_set_tRNS_to_alpha_mod(const image_transform *this,
image_pixel *that, png_const_structp pp, image_pixel *that, png_const_structp pp,
const transform_display *display) const transform_display *display)
{ {
#if PNG_LIBPNG_VER < 10700 #if PNG_LIBPNG_VER != 10700
/* LIBPNG BUG: this always forces palette images to RGB. */ /* LIBPNG BUG: this always forces palette images to RGB. */
if (that->colour_type == PNG_COLOR_TYPE_PALETTE) if (that->colour_type == PNG_COLOR_TYPE_PALETTE)
image_pixel_convert_PLTE(that); image_pixel_convert_PLTE(that);
@ -7137,13 +7137,13 @@ image_transform_png_set_tRNS_to_alpha_mod(const image_transform *this,
* convert to an alpha channel. * convert to an alpha channel.
*/ */
if (that->have_tRNS) if (that->have_tRNS)
# if PNG_LIBPNG_VER >= 10700 # if PNG_LIBPNG_VER == 10700
if (that->colour_type != PNG_COLOR_TYPE_PALETTE && if (that->colour_type != PNG_COLOR_TYPE_PALETTE &&
(that->colour_type & PNG_COLOR_MASK_ALPHA) == 0) (that->colour_type & PNG_COLOR_MASK_ALPHA) == 0)
# endif # endif
image_pixel_add_alpha(that, &display->this, 0/*!for background*/); image_pixel_add_alpha(that, &display->this, 0/*!for background*/);
#if PNG_LIBPNG_VER < 10700 #if PNG_LIBPNG_VER != 10700
/* LIBPNG BUG: otherwise libpng still expands to 8 bits! */ /* LIBPNG BUG: otherwise libpng still expands to 8 bits! */
else else
{ {
@ -7172,7 +7172,7 @@ image_transform_png_set_tRNS_to_alpha_add(image_transform *this,
* any action on a palette image. * any action on a palette image.
*/ */
return return
# if PNG_LIBPNG_VER >= 10700 # if PNG_LIBPNG_VER == 10700
colour_type != PNG_COLOR_TYPE_PALETTE && colour_type != PNG_COLOR_TYPE_PALETTE &&
# endif # endif
(colour_type & PNG_COLOR_MASK_ALPHA) == 0; (colour_type & PNG_COLOR_MASK_ALPHA) == 0;
@ -7313,7 +7313,7 @@ image_transform_png_set_expand_gray_1_2_4_to_8_mod(
const image_transform *this, image_pixel *that, png_const_structp pp, const image_transform *this, image_pixel *that, png_const_structp pp,
const transform_display *display) const transform_display *display)
{ {
#if PNG_LIBPNG_VER < 10700 #if PNG_LIBPNG_VER != 10700
image_transform_png_set_expand_mod(this, that, pp, display); image_transform_png_set_expand_mod(this, that, pp, display);
#else #else
/* Only expand grayscale of bit depth less than 8: */ /* Only expand grayscale of bit depth less than 8: */
@ -7329,7 +7329,7 @@ static int
image_transform_png_set_expand_gray_1_2_4_to_8_add(image_transform *this, image_transform_png_set_expand_gray_1_2_4_to_8_add(image_transform *this,
const image_transform **that, png_byte colour_type, png_byte bit_depth) const image_transform **that, png_byte colour_type, png_byte bit_depth)
{ {
#if PNG_LIBPNG_VER < 10700 #if PNG_LIBPNG_VER != 10700
return image_transform_png_set_expand_add(this, that, colour_type, return image_transform_png_set_expand_add(this, that, colour_type,
bit_depth); bit_depth);
#else #else
@ -7359,7 +7359,7 @@ image_transform_png_set_expand_16_set(const image_transform *this,
png_set_expand_16(pp); png_set_expand_16(pp);
/* NOTE: prior to 1.7 libpng does SET_EXPAND as well, so tRNS is expanded. */ /* NOTE: prior to 1.7 libpng does SET_EXPAND as well, so tRNS is expanded. */
# if PNG_LIBPNG_VER < 10700 # if PNG_LIBPNG_VER != 10700
if (that->this.has_tRNS) if (that->this.has_tRNS)
that->this.is_transparent = 1; that->this.is_transparent = 1;
# endif # endif
@ -7412,7 +7412,7 @@ image_transform_png_set_scale_16_set(const image_transform *this,
transform_display *that, png_structp pp, png_infop pi) transform_display *that, png_structp pp, png_infop pi)
{ {
png_set_scale_16(pp); png_set_scale_16(pp);
# if PNG_LIBPNG_VER < 10700 # if PNG_LIBPNG_VER != 10700
/* libpng will limit the gamma table size: */ /* libpng will limit the gamma table size: */
that->max_gamma_8 = PNG_MAX_GAMMA_8; that->max_gamma_8 = PNG_MAX_GAMMA_8;
# endif # endif
@ -7460,7 +7460,7 @@ image_transform_png_set_strip_16_set(const image_transform *this,
transform_display *that, png_structp pp, png_infop pi) transform_display *that, png_structp pp, png_infop pi)
{ {
png_set_strip_16(pp); png_set_strip_16(pp);
# if PNG_LIBPNG_VER < 10700 # if PNG_LIBPNG_VER != 10700
/* libpng will limit the gamma table size: */ /* libpng will limit the gamma table size: */
that->max_gamma_8 = PNG_MAX_GAMMA_8; that->max_gamma_8 = PNG_MAX_GAMMA_8;
# endif # endif
@ -7647,7 +7647,7 @@ image_transform_png_set_rgb_to_gray_ini(const image_transform *this,
else else
{ {
/* The default (built in) coefficients, as above: */ /* The default (built in) coefficients, as above: */
# if PNG_LIBPNG_VER < 10700 # if PNG_LIBPNG_VER != 10700
data.red_coefficient = 6968 / 32768.; data.red_coefficient = 6968 / 32768.;
data.green_coefficient = 23434 / 32768.; data.green_coefficient = 23434 / 32768.;
data.blue_coefficient = 2366 / 32768.; data.blue_coefficient = 2366 / 32768.;
@ -7730,7 +7730,7 @@ image_transform_png_set_rgb_to_gray_ini(const image_transform *this,
* conversion adds another +/-2 in the 16-bit case and * conversion adds another +/-2 in the 16-bit case and
* +/-(1<<(15-PNG_MAX_GAMMA_8)) in the 8-bit case. * +/-(1<<(15-PNG_MAX_GAMMA_8)) in the 8-bit case.
*/ */
# if PNG_LIBPNG_VER < 10700 # if PNG_LIBPNG_VER != 10700
if (that->this.bit_depth < 16) if (that->this.bit_depth < 16)
that->max_gamma_8 = PNG_MAX_GAMMA_8; that->max_gamma_8 = PNG_MAX_GAMMA_8;
# endif # endif
@ -7907,7 +7907,7 @@ image_transform_png_set_rgb_to_gray_mod(const image_transform *this,
{ {
double gray, err; double gray, err;
# if PNG_LIBPNG_VER < 10700 # if PNG_LIBPNG_VER != 10700
if (that->colour_type == PNG_COLOR_TYPE_PALETTE) if (that->colour_type == PNG_COLOR_TYPE_PALETTE)
image_pixel_convert_PLTE(that); image_pixel_convert_PLTE(that);
# endif # endif
@ -8094,7 +8094,7 @@ image_transform_png_set_rgb_to_gray_mod(const image_transform *this,
double b = that->bluef; double b = that->bluef;
double be = that->bluee; double be = that->bluee;
# if PNG_LIBPNG_VER < 10700 # if PNG_LIBPNG_VER != 10700
/* The true gray case involves no math in earlier versions (not /* The true gray case involves no math in earlier versions (not
* true, there was some if gamma correction was happening too.) * true, there was some if gamma correction was happening too.)
*/ */
@ -9873,7 +9873,7 @@ gamma_component_validate(const char *name, const validate_info *vi,
* lost. This can result in up to a +/-1 error in the presence of * lost. This can result in up to a +/-1 error in the presence of
* an sbit less than the bit depth. * an sbit less than the bit depth.
*/ */
# if PNG_LIBPNG_VER < 10700 # if PNG_LIBPNG_VER != 10700
# define SBIT_ERROR .5 # define SBIT_ERROR .5
# else # else
# define SBIT_ERROR 1. # define SBIT_ERROR 1.
@ -10733,7 +10733,7 @@ static void perform_gamma_scale16_tests(png_modifier *pm)
# ifndef PNG_MAX_GAMMA_8 # ifndef PNG_MAX_GAMMA_8
# define PNG_MAX_GAMMA_8 11 # define PNG_MAX_GAMMA_8 11
# endif # endif
# if defined PNG_MAX_GAMMA_8 || PNG_LIBPNG_VER < 10700 # if defined PNG_MAX_GAMMA_8 || PNG_LIBPNG_VER != 10700
# define SBIT_16_TO_8 PNG_MAX_GAMMA_8 # define SBIT_16_TO_8 PNG_MAX_GAMMA_8
# else # else
# define SBIT_16_TO_8 16 # define SBIT_16_TO_8 16
@ -11736,7 +11736,7 @@ int main(int argc, char **argv)
* code that 16-bit arithmetic is used for 8-bit samples when it would make a * code that 16-bit arithmetic is used for 8-bit samples when it would make a
* difference. * difference.
*/ */
pm.assume_16_bit_calculations = PNG_LIBPNG_VER >= 10700; pm.assume_16_bit_calculations = PNG_LIBPNG_VER == 10700;
/* Currently 16 bit expansion happens at the end of the pipeline, so the /* Currently 16 bit expansion happens at the end of the pipeline, so the
* calculations are done in the input bit depth not the output. * calculations are done in the input bit depth not the output.
@ -11760,13 +11760,13 @@ int main(int argc, char **argv)
pm.test_lbg_gamma_threshold = 1; pm.test_lbg_gamma_threshold = 1;
pm.test_lbg_gamma_transform = PNG_LIBPNG_VER >= 10600; pm.test_lbg_gamma_transform = PNG_LIBPNG_VER >= 10600;
pm.test_lbg_gamma_sbit = 1; pm.test_lbg_gamma_sbit = 1;
pm.test_lbg_gamma_composition = PNG_LIBPNG_VER >= 10700; pm.test_lbg_gamma_composition = PNG_LIBPNG_VER == 10700;
/* And the test encodings */ /* And the test encodings */
pm.encodings = test_encodings; pm.encodings = test_encodings;
pm.nencodings = ARRAY_SIZE(test_encodings); pm.nencodings = ARRAY_SIZE(test_encodings);
# if PNG_LIBPNG_VER < 10700 # if PNG_LIBPNG_VER != 10700
pm.sbitlow = 8U; /* because libpng doesn't do sBIT below 8! */ pm.sbitlow = 8U; /* because libpng doesn't do sBIT below 8! */
# else # else
pm.sbitlow = 1U; pm.sbitlow = 1U;
@ -11796,7 +11796,7 @@ int main(int argc, char **argv)
pm.maxout16 = .499; /* Error in *encoded* value */ pm.maxout16 = .499; /* Error in *encoded* value */
pm.maxabs16 = .00005;/* 1/20000 */ pm.maxabs16 = .00005;/* 1/20000 */
pm.maxcalc16 =1./65535;/* +/-1 in 16 bits for compose errors */ pm.maxcalc16 =1./65535;/* +/-1 in 16 bits for compose errors */
# if PNG_LIBPNG_VER < 10700 # if PNG_LIBPNG_VER != 10700
pm.maxcalcG = 1./((1<<PNG_MAX_GAMMA_8)-1); pm.maxcalcG = 1./((1<<PNG_MAX_GAMMA_8)-1);
# else # else
pm.maxcalcG = 1./((1<<16)-1); pm.maxcalcG = 1./((1<<16)-1);