Skip to content

Commit b8a0a54

Browse files
jbowlerctruta
authored andcommitted
[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 aec888a from branch 'libpng18'. Reviewed-by: Cosmin Truta <[email protected]> Signed-off-by: John Bowler <[email protected]> Signed-off-by: Cosmin Truta <[email protected]>
1 parent 529e69e commit b8a0a54

File tree

2 files changed

+27
-27
lines changed

2 files changed

+27
-27
lines changed

contrib/libtests/pngstest.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -3500,7 +3500,7 @@ main(int argc, char **argv)
35003500
int retval = 0;
35013501
int c;
35023502

3503-
#if PNG_LIBPNG_VER >= 10700
3503+
#if PNG_LIBPNG_VER == 10700
35043504
/* This error should not exist in 1.7 or later: */
35053505
opts |= GBG_ERROR;
35063506
#endif

contrib/libtests/pngvalid.c

+26-26
Original file line numberDiff line numberDiff line change
@@ -2574,7 +2574,7 @@ modifier_init(png_modifier *pm)
25742574
* in the rgb_to_gray check, replacing it with an exact copy of the libpng 1.5
25752575
* algorithm.
25762576
*/
2577-
#define DIGITIZE PNG_LIBPNG_VER < 10700
2577+
#define DIGITIZE PNG_LIBPNG_VER != 10700
25782578

25792579
/* If pm->calculations_use_input_precision is set then operations will happen
25802580
* 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],
39863986
# define check_interlace_type(type) ((void)(type))
39873987
# define set_write_interlace_handling(pp,type) png_set_interlace_handling(pp)
39883988
# define do_own_interlace 0
3989-
#elif PNG_LIBPNG_VER < 10700
3989+
#elif PNG_LIBPNG_VER != 10700
39903990
# define set_write_interlace_handling(pp,type) (1)
39913991
static void
39923992
check_interlace_type(int const interlace_type)
@@ -4014,7 +4014,7 @@ check_interlace_type(int const interlace_type)
40144014
# define do_own_interlace 1
40154015
#endif /* WRITE_INTERLACING tests */
40164016

4017-
#if PNG_LIBPNG_VER >= 10700 || defined PNG_WRITE_INTERLACING_SUPPORTED
4017+
#if PNG_LIBPNG_VER == 10700 || defined PNG_WRITE_INTERLACING_SUPPORTED
40184018
# define CAN_WRITE_INTERLACE 1
40194019
#else
40204020
# define CAN_WRITE_INTERLACE 0
@@ -4633,10 +4633,10 @@ static const struct
46334633
{
46344634
/* no warnings makes these errors undetectable prior to 1.7.0 */
46354635
{ sBIT0_error_fn, "sBIT(0): failed to detect error",
4636-
PNG_LIBPNG_VER < 10700 },
4636+
PNG_LIBPNG_VER != 10700 },
46374637

46384638
{ sBIT_error_fn, "sBIT(too big): failed to detect error",
4639-
PNG_LIBPNG_VER < 10700 },
4639+
PNG_LIBPNG_VER != 10700 },
46404640
};
46414641

46424642
static void
@@ -6236,7 +6236,7 @@ image_pixel_add_alpha(image_pixel *this, const standard_display *display,
62366236
{
62376237
if (this->colour_type == PNG_COLOR_TYPE_GRAY)
62386238
{
6239-
# if PNG_LIBPNG_VER < 10700
6239+
# if PNG_LIBPNG_VER != 10700
62406240
if (!for_background && this->bit_depth < 8)
62416241
this->bit_depth = this->sample_depth = 8;
62426242
# endif
@@ -6246,7 +6246,7 @@ image_pixel_add_alpha(image_pixel *this, const standard_display *display,
62466246
/* After 1.7 the expansion of bit depth only happens if there is a
62476247
* tRNS chunk to expand at this point.
62486248
*/
6249-
# if PNG_LIBPNG_VER >= 10700
6249+
# if PNG_LIBPNG_VER == 10700
62506250
if (!for_background && this->bit_depth < 8)
62516251
this->bit_depth = this->sample_depth = 8;
62526252
# endif
@@ -7127,7 +7127,7 @@ image_transform_png_set_tRNS_to_alpha_mod(const image_transform *this,
71277127
image_pixel *that, png_const_structp pp,
71287128
const transform_display *display)
71297129
{
7130-
#if PNG_LIBPNG_VER < 10700
7130+
#if PNG_LIBPNG_VER != 10700
71317131
/* LIBPNG BUG: this always forces palette images to RGB. */
71327132
if (that->colour_type == PNG_COLOR_TYPE_PALETTE)
71337133
image_pixel_convert_PLTE(that);
@@ -7137,13 +7137,13 @@ image_transform_png_set_tRNS_to_alpha_mod(const image_transform *this,
71377137
* convert to an alpha channel.
71387138
*/
71397139
if (that->have_tRNS)
7140-
# if PNG_LIBPNG_VER >= 10700
7140+
# if PNG_LIBPNG_VER == 10700
71417141
if (that->colour_type != PNG_COLOR_TYPE_PALETTE &&
71427142
(that->colour_type & PNG_COLOR_MASK_ALPHA) == 0)
71437143
# endif
71447144
image_pixel_add_alpha(that, &display->this, 0/*!for background*/);
71457145

7146-
#if PNG_LIBPNG_VER < 10700
7146+
#if PNG_LIBPNG_VER != 10700
71477147
/* LIBPNG BUG: otherwise libpng still expands to 8 bits! */
71487148
else
71497149
{
@@ -7172,7 +7172,7 @@ image_transform_png_set_tRNS_to_alpha_add(image_transform *this,
71727172
* any action on a palette image.
71737173
*/
71747174
return
7175-
# if PNG_LIBPNG_VER >= 10700
7175+
# if PNG_LIBPNG_VER == 10700
71767176
colour_type != PNG_COLOR_TYPE_PALETTE &&
71777177
# endif
71787178
(colour_type & PNG_COLOR_MASK_ALPHA) == 0;
@@ -7313,7 +7313,7 @@ image_transform_png_set_expand_gray_1_2_4_to_8_mod(
73137313
const image_transform *this, image_pixel *that, png_const_structp pp,
73147314
const transform_display *display)
73157315
{
7316-
#if PNG_LIBPNG_VER < 10700
7316+
#if PNG_LIBPNG_VER != 10700
73177317
image_transform_png_set_expand_mod(this, that, pp, display);
73187318
#else
73197319
/* Only expand grayscale of bit depth less than 8: */
@@ -7329,7 +7329,7 @@ static int
73297329
image_transform_png_set_expand_gray_1_2_4_to_8_add(image_transform *this,
73307330
const image_transform **that, png_byte colour_type, png_byte bit_depth)
73317331
{
7332-
#if PNG_LIBPNG_VER < 10700
7332+
#if PNG_LIBPNG_VER != 10700
73337333
return image_transform_png_set_expand_add(this, that, colour_type,
73347334
bit_depth);
73357335
#else
@@ -7359,7 +7359,7 @@ image_transform_png_set_expand_16_set(const image_transform *this,
73597359
png_set_expand_16(pp);
73607360

73617361
/* NOTE: prior to 1.7 libpng does SET_EXPAND as well, so tRNS is expanded. */
7362-
# if PNG_LIBPNG_VER < 10700
7362+
# if PNG_LIBPNG_VER != 10700
73637363
if (that->this.has_tRNS)
73647364
that->this.is_transparent = 1;
73657365
# endif
@@ -7412,7 +7412,7 @@ image_transform_png_set_scale_16_set(const image_transform *this,
74127412
transform_display *that, png_structp pp, png_infop pi)
74137413
{
74147414
png_set_scale_16(pp);
7415-
# if PNG_LIBPNG_VER < 10700
7415+
# if PNG_LIBPNG_VER != 10700
74167416
/* libpng will limit the gamma table size: */
74177417
that->max_gamma_8 = PNG_MAX_GAMMA_8;
74187418
# endif
@@ -7460,7 +7460,7 @@ image_transform_png_set_strip_16_set(const image_transform *this,
74607460
transform_display *that, png_structp pp, png_infop pi)
74617461
{
74627462
png_set_strip_16(pp);
7463-
# if PNG_LIBPNG_VER < 10700
7463+
# if PNG_LIBPNG_VER != 10700
74647464
/* libpng will limit the gamma table size: */
74657465
that->max_gamma_8 = PNG_MAX_GAMMA_8;
74667466
# endif
@@ -7647,7 +7647,7 @@ image_transform_png_set_rgb_to_gray_ini(const image_transform *this,
76477647
else
76487648
{
76497649
/* The default (built in) coefficients, as above: */
7650-
# if PNG_LIBPNG_VER < 10700
7650+
# if PNG_LIBPNG_VER != 10700
76517651
data.red_coefficient = 6968 / 32768.;
76527652
data.green_coefficient = 23434 / 32768.;
76537653
data.blue_coefficient = 2366 / 32768.;
@@ -7730,7 +7730,7 @@ image_transform_png_set_rgb_to_gray_ini(const image_transform *this,
77307730
* conversion adds another +/-2 in the 16-bit case and
77317731
* +/-(1<<(15-PNG_MAX_GAMMA_8)) in the 8-bit case.
77327732
*/
7733-
# if PNG_LIBPNG_VER < 10700
7733+
# if PNG_LIBPNG_VER != 10700
77347734
if (that->this.bit_depth < 16)
77357735
that->max_gamma_8 = PNG_MAX_GAMMA_8;
77367736
# endif
@@ -7907,7 +7907,7 @@ image_transform_png_set_rgb_to_gray_mod(const image_transform *this,
79077907
{
79087908
double gray, err;
79097909

7910-
# if PNG_LIBPNG_VER < 10700
7910+
# if PNG_LIBPNG_VER != 10700
79117911
if (that->colour_type == PNG_COLOR_TYPE_PALETTE)
79127912
image_pixel_convert_PLTE(that);
79137913
# endif
@@ -8094,7 +8094,7 @@ image_transform_png_set_rgb_to_gray_mod(const image_transform *this,
80948094
double b = that->bluef;
80958095
double be = that->bluee;
80968096

8097-
# if PNG_LIBPNG_VER < 10700
8097+
# if PNG_LIBPNG_VER != 10700
80988098
/* The true gray case involves no math in earlier versions (not
80998099
* true, there was some if gamma correction was happening too.)
81008100
*/
@@ -9873,7 +9873,7 @@ gamma_component_validate(const char *name, const validate_info *vi,
98739873
* lost. This can result in up to a +/-1 error in the presence of
98749874
* an sbit less than the bit depth.
98759875
*/
9876-
# if PNG_LIBPNG_VER < 10700
9876+
# if PNG_LIBPNG_VER != 10700
98779877
# define SBIT_ERROR .5
98789878
# else
98799879
# define SBIT_ERROR 1.
@@ -10733,7 +10733,7 @@ static void perform_gamma_scale16_tests(png_modifier *pm)
1073310733
# ifndef PNG_MAX_GAMMA_8
1073410734
# define PNG_MAX_GAMMA_8 11
1073510735
# endif
10736-
# if defined PNG_MAX_GAMMA_8 || PNG_LIBPNG_VER < 10700
10736+
# if defined PNG_MAX_GAMMA_8 || PNG_LIBPNG_VER != 10700
1073710737
# define SBIT_16_TO_8 PNG_MAX_GAMMA_8
1073810738
# else
1073910739
# define SBIT_16_TO_8 16
@@ -11736,7 +11736,7 @@ int main(int argc, char **argv)
1173611736
* code that 16-bit arithmetic is used for 8-bit samples when it would make a
1173711737
* difference.
1173811738
*/
11739-
pm.assume_16_bit_calculations = PNG_LIBPNG_VER >= 10700;
11739+
pm.assume_16_bit_calculations = PNG_LIBPNG_VER == 10700;
1174011740

1174111741
/* Currently 16 bit expansion happens at the end of the pipeline, so the
1174211742
* calculations are done in the input bit depth not the output.
@@ -11760,13 +11760,13 @@ int main(int argc, char **argv)
1176011760
pm.test_lbg_gamma_threshold = 1;
1176111761
pm.test_lbg_gamma_transform = PNG_LIBPNG_VER >= 10600;
1176211762
pm.test_lbg_gamma_sbit = 1;
11763-
pm.test_lbg_gamma_composition = PNG_LIBPNG_VER >= 10700;
11763+
pm.test_lbg_gamma_composition = PNG_LIBPNG_VER == 10700;
1176411764

1176511765
/* And the test encodings */
1176611766
pm.encodings = test_encodings;
1176711767
pm.nencodings = ARRAY_SIZE(test_encodings);
1176811768

11769-
# if PNG_LIBPNG_VER < 10700
11769+
# if PNG_LIBPNG_VER != 10700
1177011770
pm.sbitlow = 8U; /* because libpng doesn't do sBIT below 8! */
1177111771
# else
1177211772
pm.sbitlow = 1U;
@@ -11796,7 +11796,7 @@ int main(int argc, char **argv)
1179611796
pm.maxout16 = .499; /* Error in *encoded* value */
1179711797
pm.maxabs16 = .00005;/* 1/20000 */
1179811798
pm.maxcalc16 =1./65535;/* +/-1 in 16 bits for compose errors */
11799-
# if PNG_LIBPNG_VER < 10700
11799+
# if PNG_LIBPNG_VER != 10700
1180011800
pm.maxcalcG = 1./((1<<PNG_MAX_GAMMA_8)-1);
1180111801
# else
1180211802
pm.maxcalcG = 1./((1<<16)-1);

0 commit comments

Comments
 (0)