mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:47:34 +00:00
WebP/Lossy: Clamp negative quantization indices to zero
The spec doesn't talk about this happening in the text, but `dequant_init()` in 20.4 stores `q` in an int and clamps that to 0 later.
This commit is contained in:
parent
c2ec97dd79
commit
661b2d394d
3 changed files with 24 additions and 3 deletions
|
@ -404,6 +404,27 @@ TEST_CASE(test_webp_extended_lossy_uncompressed_alpha)
|
|||
EXPECT_EQ(frame.image->get_pixel(355, 106), Gfx::Color(0, 0, 0, 0));
|
||||
}
|
||||
|
||||
TEST_CASE(test_webp_extended_lossy_negative_quantization_offset)
|
||||
{
|
||||
auto file = MUST(Core::MappedFile::map(TEST_INPUT("smolkling.webp"sv)));
|
||||
EXPECT(Gfx::WebPImageDecoderPlugin::sniff(file->bytes()));
|
||||
auto plugin_decoder = MUST(Gfx::WebPImageDecoderPlugin::create(file->bytes()));
|
||||
MUST(plugin_decoder->initialize());
|
||||
|
||||
EXPECT_EQ(plugin_decoder->frame_count(), 1u);
|
||||
EXPECT(!plugin_decoder->is_animated());
|
||||
EXPECT(!plugin_decoder->loop_count());
|
||||
|
||||
EXPECT_EQ(plugin_decoder->size(), Gfx::IntSize(264, 264));
|
||||
|
||||
auto frame = MUST(plugin_decoder->frame(0));
|
||||
EXPECT_EQ(frame.image->size(), Gfx::IntSize(264, 264));
|
||||
|
||||
// While VP8 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(16, 16), Gfx::Color(0x3c, 0x24, 0x1a, 255));
|
||||
}
|
||||
|
||||
TEST_CASE(test_webp_lossy_4)
|
||||
{
|
||||
// This is https://commons.wikimedia.org/wiki/File:Fr%C3%BChling_bl%C3%BChender_Kirschenbaum.jpg,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue