From 98c81386637f2ef292b714fed1091dafa7339378 Mon Sep 17 00:00:00 2001 From: Vikas Arora Date: Thu, 29 Jan 2015 16:02:09 -0800 Subject: [PATCH] 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 --- examples/cwebp.c | 4 +--- man/cwebp.1 | 12 ++++++------ src/enc/near_lossless.c | 10 ---------- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/examples/cwebp.c b/examples/cwebp.c index 040e804e..8b305266 100644 --- a/examples/cwebp.c +++ b/examples/cwebp.c @@ -615,10 +615,8 @@ static void HelpLong(void) { " green=0xe0 and blue=0xd0\n"); printf(" -noalpha ............... discard any transparency information\n"); printf(" -lossless .............. encode image losslessly\n"); -#ifdef WEBP_EXPERIMENTAL_FEATURES - printf(" -near_lossless ......... use near-lossless image\n" + printf(" -near_lossless ... use near-lossless image\n" " preprocessing (0=off..100)\n"); -#endif printf(" -hint ......... specify image characteristics hint,\n"); printf(" one of: photo, picture or graph\n"); diff --git a/man/cwebp.1 b/man/cwebp.1 index d5a3beb2..8460fa45 100644 --- a/man/cwebp.1 +++ b/man/cwebp.1 @@ -218,12 +218,12 @@ Using this option will discard the alpha channel. .B \-lossless Encode the image without any loss. .TP -.\" .B \-near_lossless " int -.\" Use near-lossless image preprocessing. This option adjusts pixel values -.\" to help compressibility, but has minimal impact on the visual quality. -.\" It triggers lossless compression mode automatically. -.\" Range is 0 (no preprocessing, the default) to 100. -.\" .TP +.BI \-near_lossless " int +Use near-lossless image preprocessing. This option adjusts pixel values +to help compressibility, but has minimal impact on the visual quality. +It triggers lossless compression mode automatically. +Range is 0 (no preprocessing, the default) to 100. +.TP .BI \-hint " string Specify the hint about input image type. Possible values are: \fBphoto\fP, \fBpicture\fP or \fBgraph\fP. diff --git a/src/enc/near_lossless.c b/src/enc/near_lossless.c index 20ac39f6..573b5c74 100644 --- a/src/enc/near_lossless.c +++ b/src/enc/near_lossless.c @@ -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; }