From 016a5daa5933e20290322571100d98c014793b6f Mon Sep 17 00:00:00 2001 From: Urvang Joshi Date: Wed, 3 Aug 2016 17:02:03 -0700 Subject: [PATCH] Palette code: simpler and faster duplicate removal Change-Id: I0c1baa5ca73c1f067d69239d3e31d1050b4706d2 --- vp10/encoder/rdopt.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/vp10/encoder/rdopt.c b/vp10/encoder/rdopt.c index cf65caa6f..d736ad123 100644 --- a/vp10/encoder/rdopt.c +++ b/vp10/encoder/rdopt.c @@ -1921,21 +1921,13 @@ static int rd_pick_palette_intra_sby(VP10_COMP *cpi, MACROBLOCK *x, centroids[i] = roundf(centroids[i]); // remove duplicates i = 1; - k = n; - while (i < k) { - if (centroids[i] == centroids[i - 1]) { - j = i; - while (j < k - 1) { - assert((j + 1) < PALETTE_MAX_SIZE); - assert(j > 0); - centroids[j] = centroids[j + 1]; - ++j; - } - --k; - } else { + for (j = 1; j < n; ++j) { + if (centroids[j] != centroids[j - 1]) { // found a new unique centroid + centroids[i] = centroids[j]; ++i; } } + k = i; // number of unique centroids #if CONFIG_VP9_HIGHBITDEPTH if (cpi->common.use_highbitdepth)