Skip to content

Commit 602b79c

Browse files
committed
Re-enable the RgbColorTypeWithTrnsBeforePlte test
Relax the RgbColorTypeWithTrnsBeforePlte test by allowing the decoded image to have alpha (if libpng 1.6.47 or newer is used).
1 parent 589a05d commit 602b79c

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

tests/data/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,9 @@ An opaque blue circle on a transparent green background.
2323

2424
It is of color type 2 (PNG_COLOR_TYPE_RGB) and has a tRNS chunk before a PLTE
2525
chunk. Since the PNG specification version 1.2 says "the tRNS chunk [...] must
26-
follow the PLTE chunk, if any", libpng considers the tRNS chunk as invalid and
27-
ignores it.
26+
follow the PLTE chunk, if any", libpng 1.6.46 or older considers the tRNS chunk
27+
as invalid and ignores it. The behavior changed starting with libpng 1.6.47.
28+
See https://github.com/pnggroup/libpng/blob/libpng16/CHANGES#L6243-L6246.
2829

2930
### File [circle_custom_properties.avif](circle_custom_properties.avif)
3031

tests/gtest/avifreadimagetest.cc

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,18 +82,17 @@ TEST(PngTest, RgbColorTypeWithTrnsAfterPlte) {
8282
}
8383

8484
// Verify we can read a PNG file with PNG_COLOR_TYPE_RGB and a tRNS chunk
85-
// before a PLTE chunk. libpng considers the tRNS chunk as invalid and ignores
86-
// it, so the decoded image should have no alpha.
87-
// This test is disabled because the behavior seemed to have changed starting
88-
// with libpng 1.6.47.
85+
// before a PLTE chunk, with no MSan use-of-uninitialized-value warnings in
86+
// avifImageRGBToYUV(). libpng 1.6.46 or older considers the tRNS chunk as
87+
// invalid and ignores it, so the decoded image has no alpha. The behavior
88+
// changed starting with libpng 1.6.47.
8989
// See https://github.com/pnggroup/libpng/blob/libpng16/CHANGES#L6243-L6246.
90-
TEST(PngTest, DISABLED_RgbColorTypeWithTrnsBeforePlte) {
90+
TEST(PngTest, RgbColorTypeWithTrnsBeforePlte) {
9191
const ImagePtr image = testutil::ReadImage(
9292
data_path, "circle-trns-before-plte.png", AVIF_PIXEL_FORMAT_YUV444, 8);
9393
ASSERT_NE(image, nullptr);
9494
EXPECT_EQ(image->width, 100u);
9595
EXPECT_EQ(image->height, 60u);
96-
EXPECT_EQ(image->alphaPlane, nullptr);
9796
}
9897

9998
constexpr size_t kColorProfileSize = 376;

0 commit comments

Comments
 (0)