mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-28 14:38:21 +01:00
Tune Lossless compression for lower qualities.
This is required for WebP lossy+Alpha images, where Alpha channel is taking 60-70% of the compression (CPU) cycles. Also evaluated on 1000 PNG corpus and overall compression speed is 15-40% better for lossy (PNG+Alpha) compression. The pure lossless compression numbers are almost same (or little better) with this change. Change-Id: I9e5ae7372ed6227a9a5b64cd9cff84c747195a57
This commit is contained in:
parent
19eb012c55
commit
0478b5d214
@ -80,7 +80,7 @@ static int EncodeLossless(const uint8_t* const data, int width, int height,
|
|||||||
config.lossless = 1;
|
config.lossless = 1;
|
||||||
config.method = effort_level; // impact is very small
|
config.method = effort_level; // impact is very small
|
||||||
// Set a moderate default quality setting for alpha.
|
// Set a moderate default quality setting for alpha.
|
||||||
config.quality = 6.f * effort_level;
|
config.quality = 5.f * effort_level;
|
||||||
assert(config.quality >= 0 && config.quality <= 100.f);
|
assert(config.quality >= 0 && config.quality <= 100.f);
|
||||||
|
|
||||||
ok = VP8LBitWriterInit(&tmp_bw, (width * height) >> 3);
|
ok = VP8LBitWriterInit(&tmp_bw, (width * height) >> 3);
|
||||||
|
@ -555,10 +555,10 @@ static int BackwardReferencesHashChainDistanceOnly(
|
|||||||
}
|
}
|
||||||
// 2) Add to the hash_chain (but cannot add the last pixel)
|
// 2) Add to the hash_chain (but cannot add the last pixel)
|
||||||
{
|
{
|
||||||
const int last = (len < pix_count - 1 - i) ? len
|
const int last = (len + i < pix_count - 1) ? len + i
|
||||||
: pix_count - 1 - i;
|
: pix_count - 1;
|
||||||
for (k = 0; k < last; ++k) {
|
for (k = i; k < last; ++k) {
|
||||||
HashChainInsert(hash_chain, &argb[i + k], i + k);
|
HashChainInsert(hash_chain, &argb[k], k);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 3) jump.
|
// 3) jump.
|
||||||
|
@ -390,17 +390,12 @@ int VP8LGetHistoImageSymbols(int xsize, int ysize,
|
|||||||
// Heuristic params for HistogramCombine().
|
// Heuristic params for HistogramCombine().
|
||||||
const int num_tries_no_success = 8 + (quality >> 1);
|
const int num_tries_no_success = 8 + (quality >> 1);
|
||||||
const int iter_mult = (quality < 27) ? 1 : 1 + ((quality - 27) >> 4);
|
const int iter_mult = (quality < 27) ? 1 : 1 + ((quality - 27) >> 4);
|
||||||
int num_pairs = (quality >> 1);
|
const int num_pairs = (quality < 25) ? 10 : (5 * quality) >> 3;
|
||||||
|
|
||||||
VP8LHistogramSet* const image_out =
|
VP8LHistogramSet* const image_out =
|
||||||
VP8LAllocateHistogramSet(histo_image_raw_size, cache_bits);
|
VP8LAllocateHistogramSet(histo_image_raw_size, cache_bits);
|
||||||
if (image_out == NULL) return 0;
|
if (image_out == NULL) return 0;
|
||||||
|
|
||||||
if (num_pairs > (histo_image_raw_size >> 2)) {
|
|
||||||
num_pairs = histo_image_raw_size >> 2;
|
|
||||||
}
|
|
||||||
num_pairs += 10;
|
|
||||||
|
|
||||||
// Build histogram image.
|
// Build histogram image.
|
||||||
HistogramBuildImage(xsize, histo_bits, refs, image_out);
|
HistogramBuildImage(xsize, histo_bits, refs, image_out);
|
||||||
// Collapse similar histograms.
|
// Collapse similar histograms.
|
||||||
|
Loading…
Reference in New Issue
Block a user