Updated the near-lossless level mapping.

Updated the near-lossless level mapping and make it correlated to lossy
quality i.e 100 => minimum loss (in-fact no-loss) and the visual-quality loss
increases with decrease in near-lossless level (quality) till value 0.

The new mapping implies following (PSNR) loss-metric:
-near_lossless 100: No-loss (bit-stream same as -lossless).
-near_lossless  80: Very very high PSNR (around 54dB).
-near_lossless  60: Very high PSNR (around 48dB).
-near_lossless  40: High PSNR (around 42dB).
-near_lossless  20: Moderate PSNR (around 36dB).
-near_lossless   0: Low PSNR (around 30dB).

Change-Id: I930de4b18950faf2868c97d42e9e49ba0b642960
This commit is contained in:
Vikas Arora 2015-02-05 11:16:37 -08:00
parent 19f0ba0eb9
commit 4c82284d2e
5 changed files with 13 additions and 8 deletions

View File

@ -616,7 +616,7 @@ static void HelpLong(void) {
printf(" -noalpha ............... discard any transparency information\n");
printf(" -lossless .............. encode image losslessly\n");
printf(" -near_lossless <int> ... use near-lossless image\n"
" preprocessing (0=off..100)\n");
" preprocessing (0..100=off)\n");
printf(" -hint <string> ......... specify image characteristics hint,\n");
printf(" one of: photo, picture or graph\n");

View File

@ -1,5 +1,5 @@
.\" Hey, EMACS: -*- nroff -*-
.TH CWEBP 1 "July 30, 2014"
.TH CWEBP 1 "Feb 4, 2015"
.SH NAME
cwebp \- compress an image file to a WebP file
.SH SYNOPSIS
@ -222,7 +222,7 @@ Encode the image without any loss.
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.
Range is 0 (maximum preprocessing) to 100 (no preprocessing, the default).
.TP
.BI \-hint " string
Specify the hint about input image type. Possible values are:

View File

@ -47,7 +47,7 @@ int WebPConfigInitInternal(WebPConfig* config,
config->emulate_jpeg_size = 0;
config->thread_level = 0;
config->low_memory = 0;
config->near_lossless = 0;
config->near_lossless = 100;
// TODO(skal): tune.
switch (preset) {

View File

@ -125,9 +125,14 @@ static void NearLossless(int xsize, int ysize, uint32_t* argb,
}
static int QualityToLimitBits(int quality) {
// quality mapping 0..12 -> 5
// 13..100 -> 4..1
return MAX_LIMIT_BITS - (quality + 12) / 25;
// quality mapping:
// 0..19 -> 5
// 0..39 -> 4
// 0..59 -> 3
// 0..79 -> 2
// 0..99 -> 1
// 100 -> 0
return MAX_LIMIT_BITS - quality / 20;
}
int VP8ApplyNearLossless(int xsize, int ysize, uint32_t* argb, int quality) {

View File

@ -1254,7 +1254,7 @@ WebPEncodingError VP8LEncodeStream(const WebPConfig* const config,
}
// Apply near-lossless preprocessing.
use_near_lossless = !enc->use_palette_ && config->near_lossless;
use_near_lossless = !enc->use_palette_ && (config->near_lossless < 100);
if (use_near_lossless) {
if (!VP8ApplyNearLossless(width, height, picture->argb,
config->near_lossless)) {