WebPAnimEncoder: Disable filtering when blending is used with lossy encoding.

When FlattenSimilarBlocks() was making some blocks transparent with
averaged RGB values, filtering in lossy compression was causing
blockiness just outside the edge of these blocks.
Disabling filtering for that particular case avoid these block
artifacts.

The total encoded size of the 6k GIF set remains roughly the same (in
fact, reduces a bit).

Change-Id: Ida71cbabd59d851e16d871f53d19473312b3cc77
This commit is contained in:
Urvang Joshi 2016-03-31 17:25:22 +00:00 committed by James Zern
parent eb423903a4
commit 9a950c5375

View File

@ -768,9 +768,10 @@ typedef struct {
// Generates a candidate encoded frame given a picture and metadata.
static WebPEncodingError EncodeCandidate(WebPPicture* const sub_frame,
const FrameRect* const rect,
const WebPConfig* const config,
const WebPConfig* const encoder_config,
int use_blending,
Candidate* const candidate) {
WebPConfig config = *encoder_config;
WebPEncodingError error_code = VP8_ENC_OK;
assert(candidate != NULL);
memset(candidate, 0, sizeof(*candidate));
@ -788,7 +789,13 @@ static WebPEncodingError EncodeCandidate(WebPPicture* const sub_frame,
// Encode picture.
WebPMemoryWriterInit(&candidate->mem_);
if (!EncodeFrame(config, sub_frame, &candidate->mem_)) {
if (!config.lossless && use_blending) {
// Disable filtering to avoid blockiness in reconstructed frames at the
// time of decoding.
config.autofilter = 0;
config.filter_strength = 0;
}
if (!EncodeFrame(&config, sub_frame, &candidate->mem_)) {
error_code = sub_frame->error_code;
goto Err;
}