mirror of
https://github.com/webmproject/libwebp.git
synced 2025-07-12 22:14:29 +02:00
Enable Near-lossless feature.
Enable the WebP near-lossless feature by pre-processing the image to smoothen the pixels. On a 1000 PNG image corpus, for which WebP lossless (default settings) gets 25% compression gains, following is the performance of near-lossless feature at various '-near_lossless' levels: -near_lossless 90: 30% (very very high PSNR 54-60dB) -near_lossless 75: 38% (very high PSNR 48-54dB) -near_lossless 50: 45% (high PSNR 42-48dB) -near_lossless 25: 48% (moderate PSNR 36-42dB) -near_lossless 10: 50% (PSNR 30-36dB) WebP near-lossless is specifically useful for discrete-tone images like line-art, icons etc. Change-Id: I7d12a2c9362ccd076d09710ea05c85fa64664c38
This commit is contained in:
@ -20,8 +20,6 @@
|
||||
#include "../utils/utils.h"
|
||||
#include "./vp8enci.h"
|
||||
|
||||
#ifdef WEBP_EXPERIMENTAL_FEATURES
|
||||
|
||||
#define MIN_DIM_FOR_NEAR_LOSSLESS 64
|
||||
#define MAX_LIMIT_BITS 5
|
||||
|
||||
@ -131,15 +129,8 @@ static int QualityToLimitBits(int quality) {
|
||||
// 13..100 -> 4..1
|
||||
return MAX_LIMIT_BITS - (quality + 12) / 25;
|
||||
}
|
||||
#endif // WEBP_EXPERIMENTAL_FEATURES
|
||||
|
||||
int VP8ApplyNearLossless(int xsize, int ysize, uint32_t* argb, int quality) {
|
||||
#ifndef WEBP_EXPERIMENTAL_FEATURES
|
||||
(void)xsize;
|
||||
(void)ysize;
|
||||
(void)argb;
|
||||
(void)quality;
|
||||
#else
|
||||
int i;
|
||||
uint32_t* const copy_buffer =
|
||||
(uint32_t*)WebPSafeMalloc(xsize * 3, sizeof(*copy_buffer));
|
||||
@ -160,6 +151,5 @@ int VP8ApplyNearLossless(int xsize, int ysize, uint32_t* argb, int quality) {
|
||||
NearLossless(xsize, ysize, argb, i, copy_buffer);
|
||||
}
|
||||
WebPSafeFree(copy_buffer);
|
||||
#endif // WEBP_EXPERIMENTAL_FEATURES
|
||||
return 1;
|
||||
}
|
||||
|
Reference in New Issue
Block a user