mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-13 06:24:27 +02:00
gif2webp: Improved compression for lossy animated WebP
We reduce transparency by turning some transparent pixels into corresponding RGB values from previous canvas. This improves compression by about 23%. Change-Id: I02d70a43a1d0906ac09a7e2dc510be3b2d38f593
This commit is contained in:
@ -166,6 +166,11 @@ static int OptimizeAndEncodeFrame(
|
||||
// Update prev_canvas by simply copying from 'curr'.
|
||||
WebPUtilCopyPixels(curr, prev_canvas);
|
||||
} else {
|
||||
if (!config->lossless) {
|
||||
// For lossy compression, it's better to replace transparent pixels of
|
||||
// 'curr' with actual RGB values, whenever possible.
|
||||
WebPUtilReduceTransparency(prev_canvas, &rect, curr);
|
||||
}
|
||||
if (!WebPFrameCacheShouldTryKeyFrame(cache)) {
|
||||
// Add this as a frame rectangle.
|
||||
if (!WebPFrameCacheAddFrame(cache, config, info, sub_image, NULL, NULL)) {
|
||||
|
Reference in New Issue
Block a user