diff --git a/Libraries/LibGfx/ImageFormats/AVIFLoader.cpp b/Libraries/LibGfx/ImageFormats/AVIFLoader.cpp index 1f68fc3c91b..01200ae3f3b 100644 --- a/Libraries/LibGfx/ImageFormats/AVIFLoader.cpp +++ b/Libraries/LibGfx/ImageFormats/AVIFLoader.cpp @@ -83,9 +83,6 @@ static ErrorOr decode_avif_header(AVIFLoadingContext& context) if (result != AVIF_RESULT_OK) return Error::from_string_literal("Failed to decode AVIF"); - if (context.decoder->image->depth != 8) - return Error::from_string_literal("Unsupported bitdepth"); - // Image header now decoded, save some results for fast access in other parts of the plugin. context.size = IntSize { context.decoder->image->width, context.decoder->image->height }; context.has_alpha = context.decoder->alphaPresent == 1; @@ -114,6 +111,7 @@ static ErrorOr decode_avif_image(AVIFLoadingContext& context) rgb.pixels = bitmap->scanline_u8(0); rgb.rowBytes = bitmap->pitch(); rgb.format = avifRGBFormat::AVIF_RGB_FORMAT_BGRA; + rgb.depth = 8; avifResult result = avifImageYUVToRGB(context.decoder->image, &rgb); if (result != AVIF_RESULT_OK) diff --git a/Tests/LibGfx/TestImageDecoder.cpp b/Tests/LibGfx/TestImageDecoder.cpp index 3e6a064ec2c..c8b56a6c60d 100644 --- a/Tests/LibGfx/TestImageDecoder.cpp +++ b/Tests/LibGfx/TestImageDecoder.cpp @@ -1130,7 +1130,15 @@ TEST_CASE(test_avif_simple_lossless) TEST_CASE(test_avif_simple_lossy_bitdepth10) { auto file = TRY_OR_FAIL(Core::MappedFile::map(TEST_INPUT("avif/simple-bitdepth10.avif"sv))); - EXPECT(!Gfx::AVIFImageDecoderPlugin::sniff(file->bytes())); + EXPECT(Gfx::AVIFImageDecoderPlugin::sniff(file->bytes())); + auto plugin_decoder = TRY_OR_FAIL(Gfx::AVIFImageDecoderPlugin::create(file->bytes())); + + auto frame = TRY_OR_FAIL(expect_single_frame_of_size(*plugin_decoder, { 240, 240 })); + + // While AVIF YUV contents are defined bit-exact, the YUV->RGB conversion isn't. + // So pixels changing by 1 or so below is fine if you change code. + EXPECT_EQ(frame.image->get_pixel(120, 232), Gfx::Color(0xf1, 0xef, 0xf0, 255)); + EXPECT_EQ(frame.image->get_pixel(198, 202), Gfx::Color(0x79, 0xab, 0xd6, 255)); } TEST_CASE(test_avif_icc_profile)