Merge "Revert "Do not use a palette for one color images.""

This commit is contained in:
James Zern 2021-05-24 18:53:42 +00:00 committed by Gerrit Code Review
commit 315abbd60b
3 changed files with 1 additions and 39 deletions

View File

@ -550,25 +550,6 @@ static int BackwardReferencesLz77(int xsize, int ysize,
return ok; return ok;
} }
static int BackwardReferencesNone(int xsize, int ysize,
const uint32_t* const argb, int cache_bits,
VP8LBackwardRefs* const refs) {
const int pix_count = xsize * ysize;
int i;
const int use_color_cache = (cache_bits > 0);
VP8LColorCache hashers;
if (use_color_cache && !VP8LColorCacheInit(&hashers, cache_bits)) {
return 0;
}
VP8LClearBackwardRefs(refs);
for (i = 0; i < pix_count; ++i) {
AddSingleLiteral(argb[i], use_color_cache, &hashers, refs);
}
if (use_color_cache) VP8LColorCacheClear(&hashers);
return !refs->error_;
}
// Compute an LZ77 by forcing matches to happen within a given distance cost. // Compute an LZ77 by forcing matches to happen within a given distance cost.
// We therefore limit the algorithm to the lowest 32 values in the PlaneCode // We therefore limit the algorithm to the lowest 32 values in the PlaneCode
// definition. // definition.
@ -938,9 +919,6 @@ static int GetBackwardReferences(int width, int height,
res = BackwardReferencesLz77Box(width, height, argb, 0, hash_chain, res = BackwardReferencesLz77Box(width, height, argb, 0, hash_chain,
&hash_chain_box, refs_tmp); &hash_chain_box, refs_tmp);
break; break;
case kLZ77None:
res = BackwardReferencesNone(width, height, argb, 0, refs_tmp);
break;
default: default:
assert(0); assert(0);
} }

View File

@ -213,10 +213,7 @@ static WEBP_INLINE void VP8LRefsCursorNext(VP8LRefsCursor* const c) {
enum VP8LLZ77Type { enum VP8LLZ77Type {
kLZ77Standard = 1, kLZ77Standard = 1,
kLZ77RLE = 2, kLZ77RLE = 2,
kLZ77Box = 4, kLZ77Box = 4
// With kLZ77None, LZ77 is not even tried. For now, this is only useful for
// 1-color images but we could use it if we are sure the image is a photo.
kLZ77None = 8
}; };
// Evaluates best possible backward references for specified quality. // Evaluates best possible backward references for specified quality.

View File

@ -591,19 +591,6 @@ static int EncoderAnalyze(VP8LEncoder* const enc,
sizeof(*enc->palette_sorted_), PaletteCompareColorsForQsort); sizeof(*enc->palette_sorted_), PaletteCompareColorsForQsort);
} }
if (use_palette && enc->palette_size_ == 1) {
crunch_configs[0].entropy_idx_ = kDirect;
crunch_configs[0].sub_configs_size_ = 1;
crunch_configs[0].sub_configs_[0].lz77_ = kLZ77None;
crunch_configs[0].sub_configs_[0].do_no_cache_ = 1;
*crunch_configs_size = 1;
// Get the entropy image as small as possible.
enc->histo_bits_ = MAX_HUFFMAN_BITS;
// The transform image is unused as we are direct.
enc->transform_bits_ = MAX_TRANSFORM_BITS;
return 1;
}
// Empirical bit sizes. // Empirical bit sizes.
enc->histo_bits_ = GetHistoBits(method, use_palette, enc->histo_bits_ = GetHistoBits(method, use_palette,
pic->width, pic->height); pic->width, pic->height);