mirror of
https://github.com/webmproject/libwebp.git
synced 2025-02-13 07:22:52 +01:00
cache_bits passed to EncodeImageInternal()
should be 0 when not using color cache. Change-Id: Id15c9b6bfbeb7c69a0189fa4c411df2763f9dead
This commit is contained in:
parent
e38b40a996
commit
0e6fa06595
@ -1113,8 +1113,7 @@ static WebPEncodingError ApplyPalette(VP8LBitWriter* const bw,
|
|||||||
int VP8LEncodeImage(const WebPConfig* const config,
|
int VP8LEncodeImage(const WebPConfig* const config,
|
||||||
WebPPicture* const picture) {
|
WebPPicture* const picture) {
|
||||||
int ok = 0;
|
int ok = 0;
|
||||||
int use_color_cache = 1;
|
int cache_bits = 7; // If equal to 0, don't use color cache.
|
||||||
int cache_bits = 7;
|
|
||||||
int width, height, quality;
|
int width, height, quality;
|
||||||
VP8LEncoder* enc = NULL;
|
VP8LEncoder* enc = NULL;
|
||||||
WebPEncodingError err = VP8_ENC_OK;
|
WebPEncodingError err = VP8_ENC_OK;
|
||||||
@ -1152,7 +1151,7 @@ int VP8LEncodeImage(const WebPConfig* const config,
|
|||||||
if (enc->use_palette_) {
|
if (enc->use_palette_) {
|
||||||
err = ApplyPalette(&bw, enc, width, height, quality);
|
err = ApplyPalette(&bw, enc, width, height, quality);
|
||||||
if (err != VP8_ENC_OK) goto Error;
|
if (err != VP8_ENC_OK) goto Error;
|
||||||
use_color_cache = 0;
|
cache_bits = 0; // Don't use color cache.
|
||||||
}
|
}
|
||||||
|
|
||||||
// In case image is not packed.
|
// In case image is not packed.
|
||||||
@ -1187,18 +1186,23 @@ int VP8LEncodeImage(const WebPConfig* const config,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_color_cache) {
|
VP8LWriteBits(&bw, 1, 0); // No more transforms.
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Estimate the color cache size.
|
||||||
|
|
||||||
|
if (cache_bits > 0) {
|
||||||
if (quality > 25) {
|
if (quality > 25) {
|
||||||
if (!VP8LCalculateEstimateForPaletteSize(enc->argb_, enc->current_width_,
|
if (!VP8LCalculateEstimateForPaletteSize(enc->argb_, enc->current_width_,
|
||||||
height, &cache_bits)) {
|
height, &cache_bits)) {
|
||||||
err = VP8_ENC_ERROR_INVALID_CONFIGURATION;
|
err = VP8_ENC_ERROR_INVALID_CONFIGURATION;
|
||||||
goto Error;
|
goto Error;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
cache_bits = 0; // Don't use color cache.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
VP8LWriteBits(&bw, 1, 0); // No more transforms.
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Encode and write the transformed image.
|
// Encode and write the transformed image.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user