Commit f1c06a73 authored by Urvang Joshi's avatar Urvang Joshi

Palette: use insertion sort for sorting neighbors' scores.

While sorting, preserving the order of the rest of the list when moving
an element to the top of list makes hardware implementation much simpler.

The compression performance is roughly same: overall, avg performance on
screen-content set is 0.137% better than before in fact.

Bug=aom:127

Change-Id: Id1aa1e90254b44eae9133b47bca8f853f6a62c6b
parent e6aece86
......@@ -1262,17 +1262,20 @@ int av1_get_palette_color_context(const uint8_t *color_map, int cols, int r,
max_idx = j;
}
}
if (max_idx != i) {
int temp = scores[i];
scores[i] = scores[max_idx];
scores[max_idx] = temp;
temp = color_order[i];
color_order[i] = color_order[max_idx];
color_order[max_idx] = temp;
// Move the score at index 'max_idx' to index 'i', and shift the scores
// from 'i' to 'max_idx - 1' by 1.
const int max_score = scores[max_idx];
const uint8_t max_color_order = color_order[max_idx];
int k;
for (k = max_idx; k > i; --k) {
scores[k] = scores[k - 1];
color_order[k] = color_order[k - 1];
inverse_color_order[color_order[k]] = k;
}
scores[i] = max_score;
color_order[i] = max_color_order;
inverse_color_order[color_order[i]] = i;
inverse_color_order[color_order[max_idx]] = max_idx;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment