From b60869a18efc95ca9b6e09b5137eba6a1c250520 Mon Sep 17 00:00:00 2001 From: James Zern Date: Fri, 21 May 2021 10:23:05 -0700 Subject: [PATCH] Revert "Do not use a palette for one color images." This reverts commit b6513fbaa8a3e21d1d726f6c63bbfa76f157b9a2. This change can produce files that can cause decode failures in some versions of chrome and safari/ios/macos. https://chromium-review.googlesource.com/c/chromium/src/+/2876279 The chrome fix will be available in M92. This change can be revisited after it and the mac updates are more widely deployed. Bug: b/186640109,b/188702956 Change-Id: I296b8fe88c6c48219e3edf532226c4f972f1605b --- src/enc/backward_references_enc.c | 22 ---------------------- src/enc/backward_references_enc.h | 5 +---- src/enc/vp8l_enc.c | 13 ------------- 3 files changed, 1 insertion(+), 39 deletions(-) diff --git a/src/enc/backward_references_enc.c b/src/enc/backward_references_enc.c index d99fb8ba..519b36a0 100644 --- a/src/enc/backward_references_enc.c +++ b/src/enc/backward_references_enc.c @@ -550,25 +550,6 @@ static int BackwardReferencesLz77(int xsize, int ysize, 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. // We therefore limit the algorithm to the lowest 32 values in the PlaneCode // definition. @@ -938,9 +919,6 @@ static int GetBackwardReferences(int width, int height, res = BackwardReferencesLz77Box(width, height, argb, 0, hash_chain, &hash_chain_box, refs_tmp); break; - case kLZ77None: - res = BackwardReferencesNone(width, height, argb, 0, refs_tmp); - break; default: assert(0); } diff --git a/src/enc/backward_references_enc.h b/src/enc/backward_references_enc.h index 5c901df2..4c0267b4 100644 --- a/src/enc/backward_references_enc.h +++ b/src/enc/backward_references_enc.h @@ -213,10 +213,7 @@ static WEBP_INLINE void VP8LRefsCursorNext(VP8LRefsCursor* const c) { enum VP8LLZ77Type { kLZ77Standard = 1, kLZ77RLE = 2, - 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 + kLZ77Box = 4 }; // Evaluates best possible backward references for specified quality. diff --git a/src/enc/vp8l_enc.c b/src/enc/vp8l_enc.c index 9ed6ea2a..e330e716 100644 --- a/src/enc/vp8l_enc.c +++ b/src/enc/vp8l_enc.c @@ -591,19 +591,6 @@ static int EncoderAnalyze(VP8LEncoder* const enc, 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. enc->histo_bits_ = GetHistoBits(method, use_palette, pic->width, pic->height);