mirror of
https://github.com/webmproject/libwebp.git
synced 2025-01-27 15:12:54 +01:00
Use histogram_bits to initalize transform_bits.
This change gains back 1% in compression density for method=3 and 0.5% for method=4, at the expense of 10% slower compression speed. Change-Id: I491aa1c726def934161d4a4377e009737fbeff82
This commit is contained in:
parent
2132992d47
commit
bc374ff39e
@ -929,15 +929,24 @@ static int GetHistoBits(int method, int use_palette, int width, int height) {
|
||||
(histo_bits > MAX_HUFFMAN_BITS) ? MAX_HUFFMAN_BITS : histo_bits;
|
||||
}
|
||||
|
||||
static int GetTransformBits(int method, int histo_bits) {
|
||||
const int max_transform_bits = (method < 4) ? 6 : (method > 4) ? 4 : 5;
|
||||
return (histo_bits > max_transform_bits) ? max_transform_bits : histo_bits;
|
||||
}
|
||||
|
||||
static int GetCacheBits(float quality) {
|
||||
return (quality <= 25.f) ? 0 : 7;
|
||||
}
|
||||
|
||||
static void FinishEncParams(VP8LEncoder* const enc) {
|
||||
const WebPConfig* const config = enc->config_;
|
||||
const WebPPicture* const pic = enc->pic_;
|
||||
const int method = config->method;
|
||||
const float quality = config->quality;
|
||||
const int use_palette = enc->use_palette_;
|
||||
enc->transform_bits_ = (method < 4) ? 5 : (method > 4) ? 3 : 4;
|
||||
enc->histo_bits_ = GetHistoBits(method, use_palette, pic->width, pic->height);
|
||||
enc->cache_bits_ = (quality <= 25.f) ? 0 : 7;
|
||||
enc->transform_bits_ = GetTransformBits(method, enc->histo_bits_);
|
||||
enc->cache_bits_ = GetCacheBits(quality);
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user