1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:57:35 +00:00

LibGfx: Implement PNG filtering on write

Is it another great upgrade to our PNG encoder like in 9aafaec259?
Well, not really - it's not a 2x or 55x improvement like you saw there,
but still it saves something:

- a screenshot of a blank Serenity desktop dropped from about 45 KiB
  to 40 KiB.
- re-encoding NASA photo of the Earth to PNG again saves about 25%
  (16.5 MiB -> 12.3 MiB), compared to not using filters.

[1]: https://commons.wikimedia.org/wiki/File:The_Blue_Marble_(remastered).jpg
This commit is contained in:
Karol Kosek 2022-07-10 00:18:18 +02:00 committed by Andreas Kling
parent 98a90d79de
commit b5420b8a9a
3 changed files with 124 additions and 6 deletions

View file

@ -43,4 +43,14 @@ ALWAYS_INLINE u8 paeth_predictor(u8 a, u8 b, u8 c)
return c;
}
ALWAYS_INLINE AK::SIMD::u8x4 paeth_predictor(AK::SIMD::u8x4 a, AK::SIMD::u8x4 b, AK::SIMD::u8x4 c)
{
return AK::SIMD::u8x4 {
paeth_predictor(a[0], b[0], c[0]),
paeth_predictor(a[1], b[1], c[1]),
paeth_predictor(a[2], b[2], c[2]),
paeth_predictor(a[3], b[3], c[3]),
};
}
};