Commit 3748bc2a authored by Hui Su's avatar Hui Su

palette-delta-encoding: remove dependency on above SB row

Do not refer to above MB when on SB boundary. This helps to
reduce line buffer.

Keyframe coding gain on the screen_content testset drops from
1.28% to 1.20%.

Change-Id: I4b06fd137d6c9ea68d618035381f09d0746ba9e8
parent 1ddf2314
...@@ -154,8 +154,13 @@ int av1_get_pred_context_intra_interp(const MACROBLOCKD *xd) { ...@@ -154,8 +154,13 @@ int av1_get_pred_context_intra_interp(const MACROBLOCKD *xd) {
#endif // CONFIG_EXT_INTRA #endif // CONFIG_EXT_INTRA
#if CONFIG_PALETTE_DELTA_ENCODING #if CONFIG_PALETTE_DELTA_ENCODING
int av1_get_palette_cache(const MODE_INFO *above_mi, const MODE_INFO *left_mi, int av1_get_palette_cache(const MACROBLOCKD *const xd, int plane,
int plane, uint16_t *cache) { uint16_t *cache) {
const int row = -xd->mb_to_top_edge >> 3;
// Do not refer to above SB row when on SB boundary.
const MODE_INFO *const above_mi =
(row % (1 << MIN_SB_SIZE_LOG2)) ? xd->above_mi : NULL;
const MODE_INFO *const left_mi = xd->left_mi;
int above_n = 0, left_n = 0; int above_n = 0, left_n = 0;
if (above_mi) if (above_mi)
above_n = above_mi->mbmi.palette_mode_info.palette_size[plane != 0]; above_n = above_mi->mbmi.palette_mode_info.palette_size[plane != 0];
...@@ -166,8 +171,9 @@ int av1_get_palette_cache(const MODE_INFO *above_mi, const MODE_INFO *left_mi, ...@@ -166,8 +171,9 @@ int av1_get_palette_cache(const MODE_INFO *above_mi, const MODE_INFO *left_mi,
int left_idx = plane * PALETTE_MAX_SIZE; int left_idx = plane * PALETTE_MAX_SIZE;
int n = 0; int n = 0;
const uint16_t *above_colors = const uint16_t *above_colors =
above_mi->mbmi.palette_mode_info.palette_colors; above_mi ? above_mi->mbmi.palette_mode_info.palette_colors : NULL;
const uint16_t *left_colors = left_mi->mbmi.palette_mode_info.palette_colors; const uint16_t *left_colors =
left_mi ? left_mi->mbmi.palette_mode_info.palette_colors : NULL;
// Merge the sorted lists of base colors from above and left to get // Merge the sorted lists of base colors from above and left to get
// combined sorted color cache. // combined sorted color cache.
while (above_n > 0 && left_n > 0) { while (above_n > 0 && left_n > 0) {
......
...@@ -91,8 +91,8 @@ int av1_get_pred_context_intra_interp(const MACROBLOCKD *xd); ...@@ -91,8 +91,8 @@ int av1_get_pred_context_intra_interp(const MACROBLOCKD *xd);
// referred to as "color cache". The return value is the number of colors in the // referred to as "color cache". The return value is the number of colors in the
// cache (<= 2 * PALETTE_MAX_SIZE). The color values are stored in "cache" // cache (<= 2 * PALETTE_MAX_SIZE). The color values are stored in "cache"
// in ascending order. // in ascending order.
int av1_get_palette_cache(const MODE_INFO *above_mi, const MODE_INFO *left_mi, int av1_get_palette_cache(const MACROBLOCKD *const xd, int plane,
int plane, uint16_t *cache); uint16_t *cache);
#endif // CONFIG_PALETTE_DELTA_ENCODING #endif // CONFIG_PALETTE_DELTA_ENCODING
int av1_get_intra_inter_context(const MACROBLOCKD *xd); int av1_get_intra_inter_context(const MACROBLOCKD *xd);
......
...@@ -704,9 +704,7 @@ static int uint16_compare(const void *a, const void *b) { ...@@ -704,9 +704,7 @@ static int uint16_compare(const void *a, const void *b) {
static void read_palette_colors_y(MACROBLOCKD *const xd, int bit_depth, static void read_palette_colors_y(MACROBLOCKD *const xd, int bit_depth,
PALETTE_MODE_INFO *const pmi, aom_reader *r) { PALETTE_MODE_INFO *const pmi, aom_reader *r) {
uint16_t color_cache[2 * PALETTE_MAX_SIZE]; uint16_t color_cache[2 * PALETTE_MAX_SIZE];
const MODE_INFO *const above_mi = xd->above_mi; const int n_cache = av1_get_palette_cache(xd, 0, color_cache);
const MODE_INFO *const left_mi = xd->left_mi;
const int n_cache = av1_get_palette_cache(above_mi, left_mi, 0, color_cache);
const int n = pmi->palette_size[0]; const int n = pmi->palette_size[0];
int idx = 0; int idx = 0;
for (int i = 0; i < n_cache && idx < n; ++i) for (int i = 0; i < n_cache && idx < n; ++i)
...@@ -734,9 +732,7 @@ static void read_palette_colors_uv(MACROBLOCKD *const xd, int bit_depth, ...@@ -734,9 +732,7 @@ static void read_palette_colors_uv(MACROBLOCKD *const xd, int bit_depth,
const int n = pmi->palette_size[1]; const int n = pmi->palette_size[1];
// U channel colors. // U channel colors.
uint16_t color_cache[2 * PALETTE_MAX_SIZE]; uint16_t color_cache[2 * PALETTE_MAX_SIZE];
const MODE_INFO *const above_mi = xd->above_mi; const int n_cache = av1_get_palette_cache(xd, 1, color_cache);
const MODE_INFO *const left_mi = xd->left_mi;
const int n_cache = av1_get_palette_cache(above_mi, left_mi, 1, color_cache);
int idx = PALETTE_MAX_SIZE; int idx = PALETTE_MAX_SIZE;
for (int i = 0; i < n_cache && idx < PALETTE_MAX_SIZE + n; ++i) for (int i = 0; i < n_cache && idx < PALETTE_MAX_SIZE + n; ++i)
if (aom_read_bit(r, ACCT_STR)) pmi->palette_colors[idx++] = color_cache[i]; if (aom_read_bit(r, ACCT_STR)) pmi->palette_colors[idx++] = color_cache[i];
......
...@@ -1394,10 +1394,8 @@ static void write_palette_colors_y(const MACROBLOCKD *const xd, ...@@ -1394,10 +1394,8 @@ static void write_palette_colors_y(const MACROBLOCKD *const xd,
const PALETTE_MODE_INFO *const pmi, const PALETTE_MODE_INFO *const pmi,
int bit_depth, aom_writer *w) { int bit_depth, aom_writer *w) {
const int n = pmi->palette_size[0]; const int n = pmi->palette_size[0];
const MODE_INFO *const above_mi = xd->above_mi;
const MODE_INFO *const left_mi = xd->left_mi;
uint16_t color_cache[2 * PALETTE_MAX_SIZE]; uint16_t color_cache[2 * PALETTE_MAX_SIZE];
const int n_cache = av1_get_palette_cache(above_mi, left_mi, 0, color_cache); const int n_cache = av1_get_palette_cache(xd, 0, color_cache);
int out_cache_colors[PALETTE_MAX_SIZE]; int out_cache_colors[PALETTE_MAX_SIZE];
uint8_t cache_color_found[2 * PALETTE_MAX_SIZE]; uint8_t cache_color_found[2 * PALETTE_MAX_SIZE];
const int n_out_cache = const int n_out_cache =
...@@ -1423,10 +1421,8 @@ static void write_palette_colors_uv(const MACROBLOCKD *const xd, ...@@ -1423,10 +1421,8 @@ static void write_palette_colors_uv(const MACROBLOCKD *const xd,
const uint16_t *colors_u = pmi->palette_colors + PALETTE_MAX_SIZE; const uint16_t *colors_u = pmi->palette_colors + PALETTE_MAX_SIZE;
const uint16_t *colors_v = pmi->palette_colors + 2 * PALETTE_MAX_SIZE; const uint16_t *colors_v = pmi->palette_colors + 2 * PALETTE_MAX_SIZE;
// U channel colors. // U channel colors.
const MODE_INFO *const above_mi = xd->above_mi;
const MODE_INFO *const left_mi = xd->left_mi;
uint16_t color_cache[2 * PALETTE_MAX_SIZE]; uint16_t color_cache[2 * PALETTE_MAX_SIZE];
const int n_cache = av1_get_palette_cache(above_mi, left_mi, 1, color_cache); const int n_cache = av1_get_palette_cache(xd, 1, color_cache);
int out_cache_colors[PALETTE_MAX_SIZE]; int out_cache_colors[PALETTE_MAX_SIZE];
uint8_t cache_color_found[2 * PALETTE_MAX_SIZE]; uint8_t cache_color_found[2 * PALETTE_MAX_SIZE];
const int n_out_cache = av1_index_color_cache( const int n_out_cache = av1_index_color_cache(
......
...@@ -3051,11 +3051,8 @@ static int rd_pick_palette_intra_sby(const AV1_COMP *const cpi, MACROBLOCK *x, ...@@ -3051,11 +3051,8 @@ static int rd_pick_palette_intra_sby(const AV1_COMP *const cpi, MACROBLOCK *x,
if (rows * cols > PALETTE_MAX_BLOCK_SIZE) return 0; if (rows * cols > PALETTE_MAX_BLOCK_SIZE) return 0;
#if CONFIG_PALETTE_DELTA_ENCODING #if CONFIG_PALETTE_DELTA_ENCODING
const MODE_INFO *above_mi = xd->above_mi;
const MODE_INFO *left_mi = xd->left_mi;
uint16_t color_cache[2 * PALETTE_MAX_SIZE]; uint16_t color_cache[2 * PALETTE_MAX_SIZE];
const int n_cache = const int n_cache = av1_get_palette_cache(xd, 0, color_cache);
av1_get_palette_cache(above_mi, left_mi, 0, color_cache);
#endif // CONFIG_PALETTE_DELTA_ENCODING #endif // CONFIG_PALETTE_DELTA_ENCODING
for (n = colors > PALETTE_MAX_SIZE ? PALETTE_MAX_SIZE : colors; n >= 2; for (n = colors > PALETTE_MAX_SIZE ? PALETTE_MAX_SIZE : colors; n >= 2;
...@@ -5526,10 +5523,8 @@ static void rd_pick_palette_intra_sbuv(const AV1_COMP *const cpi, MACROBLOCK *x, ...@@ -5526,10 +5523,8 @@ static void rd_pick_palette_intra_sbuv(const AV1_COMP *const cpi, MACROBLOCK *x,
#endif // CONFIG_HIGHBITDEPTH #endif // CONFIG_HIGHBITDEPTH
#if CONFIG_PALETTE_DELTA_ENCODING #if CONFIG_PALETTE_DELTA_ENCODING
const MODE_INFO *above_mi = xd->above_mi;
const MODE_INFO *left_mi = xd->left_mi;
uint16_t color_cache[2 * PALETTE_MAX_SIZE]; uint16_t color_cache[2 * PALETTE_MAX_SIZE];
const int n_cache = av1_get_palette_cache(above_mi, left_mi, 1, color_cache); const int n_cache = av1_get_palette_cache(xd, 1, color_cache);
#endif // CONFIG_PALETTE_DELTA_ENCODING #endif // CONFIG_PALETTE_DELTA_ENCODING
colors = colors_u > colors_v ? colors_u : colors_v; colors = colors_u > colors_v ? colors_u : colors_v;
......
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