Lossy encoding: smoothen transparent areas to improve compression

If "exact" is false, we can modify the luma samples in fully transparent
areas to facilitate lossy compression. Experiments on some PNG images
show compression improvement of more than 20%.

Change-Id: I1a728cfa920a6652bc1f600d87c01f7f648c4942
This commit is contained in:
hui su
2017-07-05 10:03:01 -07:00
parent e50650c77f
commit 7d67a1646d
3 changed files with 86 additions and 39 deletions

View File

@ -336,10 +336,6 @@ int WebPEncode(const WebPConfig* config, WebPPicture* pic) {
if (!config->lossless) {
VP8Encoder* enc = NULL;
if (!config->exact) {
WebPCleanupTransparentArea(pic);
}
if (pic->use_argb || pic->y == NULL || pic->u == NULL || pic->v == NULL) {
// Make sure we have YUVA samples.
if (config->use_sharp_yuv || (config->preprocessing & 4)) {
@ -361,6 +357,10 @@ int WebPEncode(const WebPConfig* config, WebPPicture* pic) {
}
}
if (!config->exact) {
WebPCleanupTransparentArea(pic);
}
enc = InitVP8Encoder(config, pic);
if (enc == NULL) return 0; // pic->error is already set.
// Note: each of the tasks below account for 20% in the progress report.