From ff379db3173a44189546d6421034d7d416ef7172 Mon Sep 17 00:00:00 2001 From: skal Date: Tue, 12 Nov 2013 00:09:45 +0100 Subject: [PATCH] few % speedup of lossless encoding mostly visible for method 4 and up Change-Id: I1561d871bc055ec5f7998eb193d927927d3f2add --- src/enc/backward_references.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/enc/backward_references.c b/src/enc/backward_references.c index 7ded6bc3..79cc236f 100644 --- a/src/enc/backward_references.c +++ b/src/enc/backward_references.c @@ -324,10 +324,10 @@ static int BackwardReferencesHashChain(int xsize, int ysize, const int ix = VP8LColorCacheGetIndex(&hashers, pixel); refs->refs[refs->size] = PixOrCopyCreateCacheIdx(ix); } else { + if (use_color_cache) VP8LColorCacheInsert(&hashers, pixel); refs->refs[refs->size] = PixOrCopyCreateLiteral(pixel); } ++refs->size; - if (use_color_cache) VP8LColorCacheInsert(&hashers, pixel); i++; // Backward reference to be done for next pixel. len = len2; offset = offset2; @@ -357,10 +357,10 @@ static int BackwardReferencesHashChain(int xsize, int ysize, const int ix = VP8LColorCacheGetIndex(&hashers, pixel); refs->refs[refs->size] = PixOrCopyCreateCacheIdx(ix); } else { + if (use_color_cache) VP8LColorCacheInsert(&hashers, pixel); refs->refs[refs->size] = PixOrCopyCreateLiteral(pixel); } ++refs->size; - if (use_color_cache) VP8LColorCacheInsert(&hashers, pixel); if (i + 1 < pix_count) { HashChainInsert(hash_chain, &argb[i], i); } @@ -577,13 +577,13 @@ static int BackwardReferencesHashChainDistanceOnly( const int ix = VP8LColorCacheGetIndex(&hashers, argb[i]); cost_val += GetCacheCost(cost_model, ix) * mul0; } else { + if (use_color_cache) VP8LColorCacheInsert(&hashers, argb[i]); cost_val += GetLiteralCost(cost_model, argb[i]) * mul1; } if (cost[i] > cost_val) { cost[i] = (float)cost_val; dist_array[i] = 1; // only one is inserted. } - if (use_color_cache) VP8LColorCacheInsert(&hashers, argb[i]); } next_symbol: ; } @@ -675,9 +675,9 @@ static int BackwardReferencesHashChainFollowChosenPath( const int idx = VP8LColorCacheGetIndex(&hashers, argb[i]); refs->refs[size] = PixOrCopyCreateCacheIdx(idx); } else { + if (use_color_cache) VP8LColorCacheInsert(&hashers, argb[i]); refs->refs[size] = PixOrCopyCreateLiteral(argb[i]); } - if (use_color_cache) VP8LColorCacheInsert(&hashers, argb[i]); if (i + 1 < pix_count) { HashChainInsert(hash_chain, &argb[i], i); }