Index: third_party/libwebp/enc/vp8l.c |
diff --git a/third_party/libwebp/enc/vp8l.c b/third_party/libwebp/enc/vp8l.c |
index 945870ca46a59e61c14bda5493e88c7e01f28e5d..15726318e253c22e70c127cc4bf5f805204605f2 100644 |
--- a/third_party/libwebp/enc/vp8l.c |
+++ b/third_party/libwebp/enc/vp8l.c |
@@ -25,10 +25,6 @@ |
#include "../utils/utils.h" |
#include "../webp/format_constants.h" |
-#if defined(__cplusplus) || defined(c_plusplus) |
-extern "C" { |
-#endif |
- |
#define PALETTE_KEY_RIGHT_SHIFT 22 // Key for 1K buffer. |
#define MAX_HUFF_IMAGE_SIZE (16 * 1024 * 1024) |
#define MAX_COLORS_FOR_GRAPH 64 |
@@ -168,9 +164,6 @@ static int VP8LEncAnalyze(VP8LEncoder* const enc, WebPImageHint image_hint) { |
} |
if (pred_entropy < 0.95 * non_pred_entropy) { |
enc->use_predict_ = 1; |
- // TODO(vikasa): Observed some correlation of cross_color transform with |
- // predict. Need to investigate this further and add separate heuristic |
- // for setting use_cross_color flag. |
enc->use_cross_color_ = 1; |
} |
} |
@@ -451,12 +444,12 @@ static void StoreImageToBitMask( |
int bits, n_bits; |
int code, distance; |
- PrefixEncode(v->len, &code, &n_bits, &bits); |
+ VP8LPrefixEncode(v->len, &code, &n_bits, &bits); |
WriteHuffmanCode(bw, codes, 256 + code); |
VP8LWriteBits(bw, n_bits, bits); |
distance = PixOrCopyDistance(v); |
- PrefixEncode(distance, &code, &n_bits, &bits); |
+ VP8LPrefixEncode(distance, &code, &n_bits, &bits); |
WriteHuffmanCode(bw, codes + 4, code); |
VP8LWriteBits(bw, n_bits, bits); |
} |
@@ -702,7 +695,7 @@ static int ApplyCrossColorFilter(const VP8LEncoder* const enc, |
const int ccolor_transform_bits = enc->transform_bits_; |
const int transform_width = VP8LSubSampleSize(width, ccolor_transform_bits); |
const int transform_height = VP8LSubSampleSize(height, ccolor_transform_bits); |
- const int step = (quality == 0) ? 32 : 8; |
+ const int step = (quality < 25) ? 32 : (quality > 50) ? 8 : 16; |
VP8LColorSpaceTransform(width, height, ccolor_transform_bits, step, |
enc->argb_, enc->transform_data_); |
@@ -827,7 +820,7 @@ static void ApplyPalette(uint32_t* src, uint32_t* dst, |
} |
if (use_LUT) { |
- int inv_palette[MAX_PALETTE_SIZE] = { 0 }; |
+ uint8_t inv_palette[MAX_PALETTE_SIZE] = { 0 }; |
for (i = 0; i < palette_size; ++i) { |
const int color = (palette[i] >> 8) & 0xff; |
inv_palette[color] = i; |
@@ -895,7 +888,7 @@ static WebPEncodingError EncodePalette(VP8LBitWriter* const bw, |
if (err != VP8_ENC_OK) goto Error; |
dst = enc->argb_; |
- row = WebPSafeMalloc((uint64_t)width, sizeof(*row)); |
+ row = (uint8_t*)WebPSafeMalloc((uint64_t)width, sizeof(*row)); |
if (row == NULL) return VP8_ENC_ERROR_OUT_OF_MEMORY; |
ApplyPalette(src, dst, pic->argb_stride, enc->current_width_, |
@@ -959,6 +952,9 @@ static VP8LEncoder* VP8LEncoderNew(const WebPConfig* const config, |
} |
enc->config_ = config; |
enc->pic_ = picture; |
+ |
+ VP8LDspInit(); |
+ |
return enc; |
} |
@@ -1170,6 +1166,3 @@ int VP8LEncodeImage(const WebPConfig* const config, |
//------------------------------------------------------------------------------ |
-#if defined(__cplusplus) || defined(c_plusplus) |
-} // extern "C" |
-#endif |