From b8c44f1aa43512c4f2f4c395e31fcce8d1071be6 Mon Sep 17 00:00:00 2001 From: Lode Vandevenne Date: Sat, 21 Nov 2015 17:00:14 +0100 Subject: [PATCH] 3% speed improvement for lossless webp encoder for low effort mode: prevent updating unused histogram. Benchmark on 1000 PNGs, 30 iterations, lossless, quality 0, method 0: before: Compression (output/input): 2.9120/3.2667 bpp, Encode rate (raw data): 34.578 MP/s after: Compression (output/input): 2.9120/3.2667 bpp, Encode rate (raw data): 36.980 MP/s Change-Id: Id62759d4d111a6ba41c85c611a15d4f6ffc9f935 --- src/dsp/lossless_enc.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/dsp/lossless_enc.c b/src/dsp/lossless_enc.c index bf20af30..e60f303e 100644 --- a/src/dsp/lossless_enc.c +++ b/src/dsp/lossless_enc.c @@ -692,7 +692,7 @@ void VP8LResidualImage(int width, int height, int bits, int low_effort, uint32_t* const current_tile_rows = argb_scratch + width; int tile_y; int histo[4][256]; - memset(histo, 0, sizeof(histo)); + if (!low_effort) memset(histo, 0, sizeof(histo)); for (tile_y = 0; tile_y < tiles_per_col; ++tile_y) { const int tile_y_offset = tile_y * max_tile_size; const int this_tile_height = @@ -720,14 +720,16 @@ void VP8LResidualImage(int width, int height, int bits, int low_effort, image[tile_y * tiles_per_row + tile_x] = 0xff000000u | (pred << 8); CopyTileWithPrediction(width, height, tile_x, tile_y, bits, pred, argb_scratch, argb); - for (y = 0; y < max_tile_size; ++y) { - int all_x; - int all_y = tile_y_offset + y; - if (all_y >= height) { - break; - } - for (all_x = tile_x_offset; all_x < all_x_max; ++all_x) { - UpdateHisto(histo, argb[all_y * width + all_x]); + if (!low_effort) { + for (y = 0; y < max_tile_size; ++y) { + int all_x; + int all_y = tile_y_offset + y; + if (all_y >= height) { + break; + } + for (all_x = tile_x_offset; all_x < all_x_max; ++all_x) { + UpdateHisto(histo, argb[all_y * width + all_x]); + } } } }