mirror of
https://github.com/SerenityOS/serenity
synced 2026-05-15 03:16:44 +02:00
AnimationWriter already only stores the smallest rect that contains changing pixels between two frames. For example, when doing a screen recording and only the mouse cursor moves, we already only encode the pixels in the (single) rectangle containing old and new mouse cursor positions. Within that rectangle, there can still be many pixels that are identical over the two frames. When possible, we now replace all identical pixels with transparent black. This has two advantages: 1. It can reduce the number of colors in the image. In particular, for wow.gif (and likely many other gifs), new frames had more than 256 colors before, and have fewer than 256 colors after this change. 2. Long run of identical pixels compress better. In some cases, this transform might make things slighly worse, for example if the input image already consists of long runs of a single color. We'll now add another color to it (transparent black), without it helping much. And the decoder now must do some blending, slowing down decoding a bit. But most of the time this should be a pretty big win. We can tweak the heuristic when to do it later. This transform is possible when: * The new frame doesn't already have transparent pixels (which are different from the old frame) * The encoder/decoder can handle frames with transparent pixels For the latter reason, encoders currently have to opt in to this.
5.1 KiB
5.1 KiB