mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-17 22:39:52 +02:00
lossless: simpler alpha cleanup preprocessing
setting all transparent pixels to black rather than the "flatten" method. 0.3% smaller filesize on the 1000 PNGs if alpha cleanup is used (before: 18685774, after: 18622472) Change-Id: Ib0db9e7ccde55b36e82de07855f2dbb630fe62b1
This commit is contained in:
committed by
Pascal Massimino
parent
ba7f4b68c9
commit
fb4c7832f1
@ -324,14 +324,15 @@ int WebPEncode(const WebPConfig* config, WebPPicture* pic) {
|
||||
if (pic->width > WEBP_MAX_DIMENSION || pic->height > WEBP_MAX_DIMENSION)
|
||||
return WebPEncodingSetError(pic, VP8_ENC_ERROR_BAD_DIMENSION);
|
||||
|
||||
if (!config->exact) {
|
||||
WebPCleanupTransparentArea(pic);
|
||||
}
|
||||
|
||||
if (pic->stats != NULL) memset(pic->stats, 0, sizeof(*pic->stats));
|
||||
|
||||
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->preprocessing & 4) {
|
||||
@ -379,6 +380,10 @@ int WebPEncode(const WebPConfig* config, WebPPicture* pic) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!config->exact) {
|
||||
WebPCleanupTransparentAreaLossless(pic);
|
||||
}
|
||||
|
||||
ok = VP8LEncodeImage(config, pic); // Sets pic->error in case of problem.
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user