Commit 79f4fc47 authored by Urvang Joshi's avatar Urvang Joshi

get_palette_color_context: Make code more readable.

For clarity, use separate variables for 'color_ctx_hash' and
'color_ctx' instead of reusing same variables for both.

BUG=webm:1324

Change-Id: I3a516ea54353e1f0737822c613a68da252e30c6e
parent 349b723f
......@@ -911,11 +911,13 @@ int av1_get_palette_color_context(const uint8_t *color_map, int cols, int r,
// this (or similar) bug: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59124
int scores[PALETTE_MAX_SIZE + 10];
const int weights[4] = { 3, 2, 3, 2 };
int color_ctx = 0;
int color_ctx_hash;
int color_ctx;
int color_neighbors[4];
int inverse_color_order[PALETTE_MAX_SIZE];
assert(n <= PALETTE_MAX_SIZE);
// Get color indices of neighbors.
color_neighbors[0] = (c - 1 >= 0) ? color_map[r * cols + c - 1] : -1;
color_neighbors[1] =
(c - 1 >= 0 && r - 1 >= 0) ? color_map[(r - 1) * cols + c - 1] : -1;
......@@ -960,15 +962,19 @@ int av1_get_palette_color_context(const uint8_t *color_map, int cols, int r,
}
}
for (i = 0; i < 4; ++i) color_ctx = color_ctx * 11 + scores[i];
// Get hash value of context.
color_ctx_hash = 0;
for (i = 0; i < 4; ++i) color_ctx_hash = color_ctx_hash * 11 + scores[i];
for (i = 0; i < PALETTE_COLOR_CONTEXTS; ++i)
if (color_ctx == palette_color_context_lookup[i]) {
// Lookup context from hash.
color_ctx = 0; // Default.
for (i = 0; i < PALETTE_COLOR_CONTEXTS; ++i) {
if (color_ctx_hash == palette_color_context_lookup[i]) {
color_ctx = i;
break;
}
}
if (color_ctx >= PALETTE_COLOR_CONTEXTS) color_ctx = 0;
if (color_idx != NULL) {
*color_idx = inverse_color_order[color_map[r * cols + c]];
}
......
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