mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-27 22:28:22 +01:00
Revert "Re-enable encoding of alpha plane with color cache for next release."
This avoids generating file that would trigger a decoding bug
found in 0.4.0 -> 0.4.3 libwebp versions.
This reverts commit 6ecd72f845
.
Change-Id: I4667cc8f7b851ba44479e3fe2b9d844b2c56fcf4
This commit is contained in:
parent
e88c4ca013
commit
97934e2447
@ -79,7 +79,11 @@ static int EncodeLossless(const uint8_t* const data, int width, int height,
|
|||||||
config.quality = 8.f * effort_level;
|
config.quality = 8.f * effort_level;
|
||||||
assert(config.quality >= 0 && config.quality <= 100.f);
|
assert(config.quality >= 0 && config.quality <= 100.f);
|
||||||
|
|
||||||
ok = (VP8LEncodeStream(&config, &picture, bw) == VP8_ENC_OK);
|
// TODO(urvang): Temporary fix to avoid generating images that trigger
|
||||||
|
// a decoder bug related to alpha with color cache.
|
||||||
|
// See: https://code.google.com/p/webp/issues/detail?id=239
|
||||||
|
// Need to re-enable this later.
|
||||||
|
ok = (VP8LEncodeStream(&config, &picture, bw, 0 /*use_cache*/) == VP8_ENC_OK);
|
||||||
WebPPictureFree(&picture);
|
WebPPictureFree(&picture);
|
||||||
ok = ok && !bw->error_;
|
ok = ok && !bw->error_;
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
|
@ -824,7 +824,8 @@ static WebPEncodingError EncodeImageInternal(VP8LBitWriter* const bw,
|
|||||||
VP8LHashChain* const hash_chain,
|
VP8LHashChain* const hash_chain,
|
||||||
VP8LBackwardRefs refs_array[2],
|
VP8LBackwardRefs refs_array[2],
|
||||||
int width, int height, int quality,
|
int width, int height, int quality,
|
||||||
int low_effort, int* cache_bits,
|
int low_effort,
|
||||||
|
int use_cache, int* cache_bits,
|
||||||
int histogram_bits,
|
int histogram_bits,
|
||||||
size_t init_byte_position,
|
size_t init_byte_position,
|
||||||
int* const hdr_size,
|
int* const hdr_size,
|
||||||
@ -856,7 +857,7 @@ static WebPEncodingError EncodeImageInternal(VP8LBitWriter* const bw,
|
|||||||
goto Error;
|
goto Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
*cache_bits = MAX_COLOR_CACHE_BITS;
|
*cache_bits = use_cache ? MAX_COLOR_CACHE_BITS : 0;
|
||||||
// 'best_refs' is the reference to the best backward refs and points to one
|
// 'best_refs' is the reference to the best backward refs and points to one
|
||||||
// of refs_array[0] or refs_array[1].
|
// of refs_array[0] or refs_array[1].
|
||||||
// Calculate backward references from ARGB image.
|
// Calculate backward references from ARGB image.
|
||||||
@ -1384,7 +1385,7 @@ static void VP8LEncoderDelete(VP8LEncoder* enc) {
|
|||||||
|
|
||||||
WebPEncodingError VP8LEncodeStream(const WebPConfig* const config,
|
WebPEncodingError VP8LEncodeStream(const WebPConfig* const config,
|
||||||
const WebPPicture* const picture,
|
const WebPPicture* const picture,
|
||||||
VP8LBitWriter* const bw) {
|
VP8LBitWriter* const bw, int use_cache) {
|
||||||
WebPEncodingError err = VP8_ENC_OK;
|
WebPEncodingError err = VP8_ENC_OK;
|
||||||
const int quality = (int)config->quality;
|
const int quality = (int)config->quality;
|
||||||
const int low_effort = (config->method == 0);
|
const int low_effort = (config->method == 0);
|
||||||
@ -1480,8 +1481,8 @@ WebPEncodingError VP8LEncodeStream(const WebPConfig* const config,
|
|||||||
// Encode and write the transformed image.
|
// Encode and write the transformed image.
|
||||||
err = EncodeImageInternal(bw, enc->argb_, &enc->hash_chain_, enc->refs_,
|
err = EncodeImageInternal(bw, enc->argb_, &enc->hash_chain_, enc->refs_,
|
||||||
enc->current_width_, height, quality, low_effort,
|
enc->current_width_, height, quality, low_effort,
|
||||||
&enc->cache_bits_, enc->histo_bits_, byte_position,
|
use_cache, &enc->cache_bits_, enc->histo_bits_,
|
||||||
&hdr_size, &data_size);
|
byte_position, &hdr_size, &data_size);
|
||||||
if (err != VP8_ENC_OK) goto Error;
|
if (err != VP8_ENC_OK) goto Error;
|
||||||
|
|
||||||
if (picture->stats != NULL) {
|
if (picture->stats != NULL) {
|
||||||
@ -1566,7 +1567,7 @@ int VP8LEncodeImage(const WebPConfig* const config,
|
|||||||
if (!WebPReportProgress(picture, 5, &percent)) goto UserAbort;
|
if (!WebPReportProgress(picture, 5, &percent)) goto UserAbort;
|
||||||
|
|
||||||
// Encode main image stream.
|
// Encode main image stream.
|
||||||
err = VP8LEncodeStream(config, picture, &bw);
|
err = VP8LEncodeStream(config, picture, &bw, 1 /*use_cache*/);
|
||||||
if (err != VP8_ENC_OK) goto Error;
|
if (err != VP8_ENC_OK) goto Error;
|
||||||
|
|
||||||
// TODO(skal): have a fine-grained progress report in VP8LEncodeStream().
|
// TODO(skal): have a fine-grained progress report in VP8LEncodeStream().
|
||||||
|
@ -67,9 +67,10 @@ int VP8LEncodeImage(const WebPConfig* const config,
|
|||||||
const WebPPicture* const picture);
|
const WebPPicture* const picture);
|
||||||
|
|
||||||
// Encodes the main image stream using the supplied bit writer.
|
// Encodes the main image stream using the supplied bit writer.
|
||||||
|
// If 'use_cache' is false, disables the use of color cache.
|
||||||
WebPEncodingError VP8LEncodeStream(const WebPConfig* const config,
|
WebPEncodingError VP8LEncodeStream(const WebPConfig* const config,
|
||||||
const WebPPicture* const picture,
|
const WebPPicture* const picture,
|
||||||
VP8LBitWriter* const bw);
|
VP8LBitWriter* const bw, int use_cache);
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user