Remove PALETTE flag
This experiment is now adopted as it was cleared by Tapas.
Note: Palette use can still be controlled by command-line option
"--tune-content=..." in 'aomenc'.
Change-Id: I832f49f20f60c34bdef5b424755849c496687e87
diff --git a/av1/encoder/rdopt.c b/av1/encoder/rdopt.c
index ba45253..d22719d 100644
--- a/av1/encoder/rdopt.c
+++ b/av1/encoder/rdopt.c
@@ -51,9 +51,7 @@
#endif
#include "av1/encoder/hybrid_fwd_txfm.h"
#include "av1/encoder/mcomp.h"
-#if CONFIG_PALETTE
#include "av1/encoder/palette.h"
-#endif // CONFIG_PALETTE
#include "av1/encoder/ratectrl.h"
#include "av1/encoder/rd.h"
#include "av1/encoder/rdopt.h"
@@ -664,7 +662,6 @@
#define uv_rd_search_mode_order intra_rd_search_mode_order
#endif // CONFIG_CFL
-#if CONFIG_EXT_INTRA || CONFIG_FILTER_INTRA || CONFIG_PALETTE
static INLINE int write_uniform_cost(int n, int v) {
const int l = get_unsigned_bits(n);
const int m = (1 << l) - n;
@@ -674,7 +671,6 @@
else
return l * av1_cost_bit(128, 0);
}
-#endif // CONFIG_EXT_INTRA || CONFIG_FILTER_INTRA || CONFIG_PALETTE
// constants for prune 1 and prune 2 decision boundaries
#define FAST_EXT_TX_CORR_MID 0.0
@@ -1872,7 +1868,6 @@
visible_rows);
}
-#if CONFIG_PALETTE || CONFIG_INTRABC
int av1_count_colors(const uint8_t *src, int stride, int rows, int cols) {
int val_count[256];
memset(val_count, 0, sizeof(val_count));
@@ -1907,7 +1902,6 @@
return n;
}
#endif // CONFIG_HIGHBITDEPTH
-#endif // CONFIG_PALETTE || CONFIG_INTRABC
void av1_dist_block(const AV1_COMP *cpi, MACROBLOCK *x, int plane,
BLOCK_SIZE plane_bsize, int block, int blk_row, int blk_col,
@@ -3048,7 +3042,6 @@
return this_rd;
}
-#if CONFIG_PALETTE
// Extends 'color_map' array from 'orig_width x orig_height' to 'new_width x
// new_height'. Extra rows and columns are filled in by copying last valid
// row/column.
@@ -3284,7 +3277,6 @@
*mbmi = *best_mbmi;
return rate_overhead;
}
-#endif // CONFIG_PALETTE
static int64_t rd_pick_intra_sub_8x8_y_subblock_mode(
const AV1_COMP *const cpi, MACROBLOCK *x, int row, int col,
@@ -3357,9 +3349,7 @@
xd->mi[0]->mbmi.tx_size = tx_size;
-#if CONFIG_PALETTE
xd->mi[0]->mbmi.palette_mode_info.palette_size[0] = 0;
-#endif // CONFIG_PALETTE
#if CONFIG_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
@@ -3908,9 +3898,7 @@
av1_zero(filter_intra_mode_info);
mbmi->filter_intra_mode_info.use_filter_intra_mode[0] = 1;
mbmi->mode = DC_PRED;
-#if CONFIG_PALETTE
mbmi->palette_mode_info.palette_size[0] = 0;
-#endif // CONFIG_PALETTE
for (mode = 0; mode < FILTER_INTRA_MODES; ++mode) {
int this_rate;
@@ -4270,14 +4258,12 @@
#endif // CONFIG_HIGHBITDEPTH
#endif // CONFIG_EXT_INTRA
-#if CONFIG_PALETTE
// Returns true if palette can be used for this block.
static int can_use_palette(const AV1_COMP *const cpi,
const MB_MODE_INFO *const mbmi) {
return cpi->common.allow_screen_content_tools && mbmi->sb_type >= BLOCK_8X8 &&
mbmi->sb_type <= BLOCK_LARGEST;
}
-#endif // CONFIG_PALETTE
// This function is used only for intra_only frames
static int64_t rd_pick_intra_sby_mode(const AV1_COMP *const cpi, MACROBLOCK *x,
@@ -4306,7 +4292,6 @@
uint16_t filter_intra_mode_skip_mask = (1 << FILTER_INTRA_MODES) - 1;
#endif // CONFIG_FILTER_INTRA
const int *bmode_costs;
-#if CONFIG_PALETTE
PALETTE_MODE_INFO *const pmi = &mbmi->palette_mode_info;
uint8_t *best_palette_color_map =
cpi->common.allow_screen_content_tools
@@ -4314,7 +4299,6 @@
: NULL;
int palette_y_mode_ctx = 0;
const int try_palette = can_use_palette(cpi, mbmi);
-#endif // CONFIG_PALETTE
const MODE_INFO *above_mi = xd->above_mi;
const MODE_INFO *left_mi = xd->left_mi;
const PREDICTION_MODE A = av1_above_block_mode(mic, above_mi, 0);
@@ -4342,14 +4326,12 @@
#if CONFIG_FILTER_INTRA
mbmi->filter_intra_mode_info.use_filter_intra_mode[0] = 0;
#endif // CONFIG_FILTER_INTRA
-#if CONFIG_PALETTE
pmi->palette_size[0] = 0;
if (above_mi)
palette_y_mode_ctx +=
(above_mi->mbmi.palette_mode_info.palette_size[0] > 0);
if (left_mi)
palette_y_mode_ctx += (left_mi->mbmi.palette_mode_info.palette_size[0] > 0);
-#endif // CONFIG_PALETTE
if (cpi->sf.tx_type_search.fast_intra_tx_type_search)
x->use_default_intra_tx_type = 1;
@@ -4408,14 +4390,12 @@
// not the tokenonly rate.
this_rate_tokenonly -= tx_size_cost(cpi, x, bsize, mbmi->tx_size);
}
-#if CONFIG_PALETTE
if (try_palette && mbmi->mode == DC_PRED) {
this_rate +=
av1_cost_bit(av1_default_palette_y_mode_prob[bsize - BLOCK_8X8]
[palette_y_mode_ctx],
0);
}
-#endif // CONFIG_PALETTE
#if CONFIG_FILTER_INTRA
if (mbmi->mode == DC_PRED)
this_rate += av1_cost_bit(cpi->common.fc->filter_intra_probs[0], 0);
@@ -4461,14 +4441,12 @@
od_encode_rollback(&x->daala_enc, &post_buf);
#endif // CONFIG_PVQ
-#if CONFIG_PALETTE
if (try_palette) {
rd_pick_palette_intra_sby(cpi, x, bsize, palette_y_mode_ctx,
bmode_costs[DC_PRED], &best_mbmi,
best_palette_color_map, &best_rd, &best_model_rd,
rate, rate_tokenonly, distortion, skippable);
}
-#endif // CONFIG_PALETTE
#if CONFIG_FILTER_INTRA
if (beat_best_rd) {
@@ -5516,7 +5494,6 @@
}
#endif // CONFIG_VAR_TX
-#if CONFIG_PALETTE
static void rd_pick_palette_intra_sbuv(const AV1_COMP *const cpi, MACROBLOCK *x,
int dc_mode_cost,
uint8_t *best_palette_color_map,
@@ -5708,7 +5685,6 @@
rows * cols * sizeof(best_palette_color_map[0]));
}
}
-#endif // CONFIG_PALETTE
#if CONFIG_FILTER_INTRA
// Return 1 if an filter intra mode is selected; return 0 otherwise.
@@ -5728,9 +5704,7 @@
av1_zero(filter_intra_mode_info);
mbmi->filter_intra_mode_info.use_filter_intra_mode[1] = 1;
mbmi->uv_mode = UV_DC_PRED;
-#if CONFIG_PALETTE
mbmi->palette_mode_info.palette_size[1] = 0;
-#endif // CONFIG_PALETTE
for (mode = 0; mode < FILTER_INTRA_MODES; ++mode) {
mbmi->filter_intra_mode_info.filter_intra_mode[1] = mode;
@@ -6025,9 +5999,7 @@
static void init_sbuv_mode(MB_MODE_INFO *const mbmi) {
mbmi->uv_mode = UV_DC_PRED;
-#if CONFIG_PALETTE
mbmi->palette_mode_info.palette_size[1] = 0;
-#endif // CONFIG_PALETTE
#if CONFIG_FILTER_INTRA
mbmi->filter_intra_mode_info.use_filter_intra_mode[1] = 0;
#endif // CONFIG_FILTER_INTRA
@@ -6046,10 +6018,8 @@
od_rollback_buffer buf;
od_encode_checkpoint(&x->daala_enc, &buf);
#endif // CONFIG_PVQ
-#if CONFIG_PALETTE
PALETTE_MODE_INFO *const pmi = &mbmi->palette_mode_info;
const int try_palette = can_use_palette(cpi, mbmi);
-#endif // CONFIG_PALETTE
for (int mode_idx = 0; mode_idx < UV_INTRA_MODES; ++mode_idx) {
int this_rate;
@@ -6109,11 +6079,9 @@
if (mbmi->sb_type >= BLOCK_8X8 && mode == DC_PRED)
this_rate += av1_cost_bit(cpi->common.fc->filter_intra_probs[1], 0);
#endif // CONFIG_FILTER_INTRA
-#if CONFIG_PALETTE
if (try_palette && mode == UV_DC_PRED)
this_rate += av1_cost_bit(
av1_default_palette_uv_mode_prob[pmi->palette_size[0] > 0], 0);
-#endif // CONFIG_PALETTE
#if CONFIG_PVQ
od_encode_rollback(&x->daala_enc, &buf);
@@ -6130,7 +6098,6 @@
}
}
-#if CONFIG_PALETTE
if (try_palette) {
uint8_t *best_palette_color_map = x->palette_buffer->best_palette_color_map;
rd_pick_palette_intra_sbuv(cpi, x,
@@ -6138,7 +6105,6 @@
best_palette_color_map, &best_mbmi, &best_rd,
rate, rate_tokenonly, distortion, skippable);
}
-#endif // CONFIG_PALETTE
#if CONFIG_FILTER_INTRA
if (mbmi->sb_type >= BLOCK_8X8) {
@@ -9827,9 +9793,7 @@
if (mv_check_bounds(&x->mv_limits, &dv)) continue;
if (!is_dv_valid(dv, tile, mi_row, mi_col, bsize)) continue;
-#if CONFIG_PALETTE
memset(&mbmi->palette_mode_info, 0, sizeof(mbmi->palette_mode_info));
-#endif
mbmi->use_intrabc = 1;
mbmi->mode = DC_PRED;
mbmi->uv_mode = UV_DC_PRED;
@@ -10068,7 +10032,6 @@
av1_active_v_edge(cpi, mi_col, cpi->common.mib_size);
}
-#if CONFIG_PALETTE
static void restore_uv_color_map(const AV1_COMP *const cpi, MACROBLOCK *x) {
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
@@ -10118,7 +10081,6 @@
extend_palette_color_map(color_map, cols, rows, plane_block_width,
plane_block_height);
}
-#endif // CONFIG_PALETTE
#if CONFIG_FILTER_INTRA
static void pick_filter_intra_interframe(
@@ -10129,12 +10091,10 @@
#if CONFIG_EXT_INTRA
int8_t *uv_angle_delta,
#endif // CONFIG_EXT_INTRA
-#if CONFIG_PALETTE
- PALETTE_MODE_INFO *pmi_uv, int palette_ctx,
-#endif // CONFIG_PALETTE
- int skip_mask, unsigned int *ref_costs_single, int64_t *best_rd,
- int64_t *best_intra_rd, PREDICTION_MODE *best_intra_mode,
- int *best_mode_index, int *best_skip2, int *best_mode_skippable,
+ PALETTE_MODE_INFO *pmi_uv, int palette_ctx, int skip_mask,
+ unsigned int *ref_costs_single, int64_t *best_rd, int64_t *best_intra_rd,
+ PREDICTION_MODE *best_intra_mode, int *best_mode_index, int *best_skip2,
+ int *best_mode_skippable,
#if CONFIG_SUPERTX
int *returnrate_nocoef,
#endif // CONFIG_SUPERTX
@@ -10142,10 +10102,8 @@
const AV1_COMMON *const cm = &cpi->common;
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
-#if CONFIG_PALETTE
PALETTE_MODE_INFO *const pmi = &mbmi->palette_mode_info;
const int try_palette = can_use_palette(cpi, mbmi);
-#endif // CONFIG_PALETTE
int rate2 = 0, rate_y = INT_MAX, skippable = 0, rate_uv, rate_dummy, i;
int dc_mode_index;
const int *const intra_mode_cost = x->mbmode_cost[size_group_lookup[bsize]];
@@ -10179,9 +10137,7 @@
choose_intra_uv_mode(cpi, x, bsize, uv_tx, &rate_uv_intra[uv_tx],
&rate_uv_tokenonly[uv_tx], &dist_uv[uv_tx],
&skip_uv[uv_tx], &mode_uv[uv_tx]);
-#if CONFIG_PALETTE
if (cm->allow_screen_content_tools) pmi_uv[uv_tx] = *pmi;
-#endif // CONFIG_PALETTE
filter_intra_mode_info_uv[uv_tx] = mbmi->filter_intra_mode_info;
#if CONFIG_EXT_INTRA
uv_angle_delta[uv_tx] = mbmi->angle_delta[1];
@@ -10192,14 +10148,12 @@
distortion_uv = dist_uv[uv_tx];
skippable = skippable && skip_uv[uv_tx];
mbmi->uv_mode = mode_uv[uv_tx];
-#if CONFIG_PALETTE
if (cm->allow_screen_content_tools) {
pmi->palette_size[1] = pmi_uv[uv_tx].palette_size[1];
memcpy(pmi->palette_colors + PALETTE_MAX_SIZE,
pmi_uv[uv_tx].palette_colors + PALETTE_MAX_SIZE,
2 * PALETTE_MAX_SIZE * sizeof(pmi->palette_colors[0]));
}
-#endif // CONFIG_PALETTE
#if CONFIG_EXT_INTRA
mbmi->angle_delta[1] = uv_angle_delta[uv_tx];
#endif // CONFIG_EXT_INTRA
@@ -10212,11 +10166,9 @@
rate2 = rate_y + intra_mode_cost[mbmi->mode] + rate_uv +
x->intra_uv_mode_cost[mbmi->mode][mbmi->uv_mode];
-#if CONFIG_PALETTE
if (try_palette && mbmi->mode == DC_PRED)
rate2 += av1_cost_bit(
av1_default_palette_y_mode_prob[bsize - BLOCK_8X8][palette_ctx], 0);
-#endif // CONFIG_PALETTE
if (!xd->lossless[mbmi->segment_id]) {
// super_block_yrd above includes the cost of the tx_size in the
@@ -10313,10 +10265,8 @@
const SPEED_FEATURES *const sf = &cpi->sf;
MACROBLOCKD *const xd = &x->e_mbd;
MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
-#if CONFIG_PALETTE
const int try_palette = can_use_palette(cpi, mbmi);
PALETTE_MODE_INFO *const pmi = &mbmi->palette_mode_info;
-#endif // CONFIG_PALETTE
MB_MODE_INFO_EXT *const mbmi_ext = x->mbmi_ext;
const struct segmentation *const seg = &cm->seg;
PREDICTION_MODE this_mode;
@@ -10372,9 +10322,7 @@
int64_t dist_uvs[TX_SIZES_ALL];
int skip_uvs[TX_SIZES_ALL];
UV_PREDICTION_MODE mode_uv[TX_SIZES_ALL];
-#if CONFIG_PALETTE
PALETTE_MODE_INFO pmi_uv[TX_SIZES_ALL];
-#endif // CONFIG_PALETTE
#if CONFIG_EXT_INTRA
int8_t uv_angle_delta[TX_SIZES_ALL];
int is_directional_mode, angle_stats_ready = 0;
@@ -10421,15 +10369,11 @@
{ { 0 } },
};
-#if CONFIG_PALETTE || CONFIG_EXT_INTRA
const int rows = block_size_high[bsize];
const int cols = block_size_wide[bsize];
-#endif // CONFIG_PALETTE || CONFIG_EXT_INTRA
-#if CONFIG_PALETTE
int palette_ctx = 0;
const MODE_INFO *above_mi = xd->above_mi;
const MODE_INFO *left_mi = xd->left_mi;
-#endif // CONFIG_PALETTE
#if CONFIG_MOTION_VAR
int dst_width1[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE };
int dst_width2[MAX_MB_PLANE] = { MAX_SB_SIZE, MAX_SB_SIZE, MAX_SB_SIZE };
@@ -10464,7 +10408,6 @@
av1_zero(best_mbmode);
-#if CONFIG_PALETTE
av1_zero(pmi_uv);
if (try_palette) {
if (above_mi)
@@ -10472,7 +10415,6 @@
if (left_mi)
palette_ctx += (left_mi->mbmi.palette_mode_info.palette_size[0] > 0);
}
-#endif // CONFIG_PALETTE
estimate_ref_frame_costs(cm, xd, segment_id, ref_costs_single, ref_costs_comp,
&comp_mode_p);
@@ -10932,10 +10874,8 @@
mbmi->uv_mode = UV_DC_PRED;
mbmi->ref_frame[0] = ref_frame;
mbmi->ref_frame[1] = second_ref_frame;
-#if CONFIG_PALETTE
pmi->palette_size[0] = 0;
pmi->palette_size[1] = 0;
-#endif // CONFIG_PALETTE
#if CONFIG_FILTER_INTRA
mbmi->filter_intra_mode_info.use_filter_intra_mode[0] = 0;
mbmi->filter_intra_mode_info.use_filter_intra_mode[1] = 0;
@@ -11020,9 +10960,7 @@
choose_intra_uv_mode(cpi, x, bsize, uv_tx, &rate_uv_intra[uv_tx],
&rate_uv_tokenonly[uv_tx], &dist_uvs[uv_tx],
&skip_uvs[uv_tx], &mode_uv[uv_tx]);
-#if CONFIG_PALETTE
if (try_palette) pmi_uv[uv_tx] = *pmi;
-#endif // CONFIG_PALETTE
#if CONFIG_EXT_INTRA
uv_angle_delta[uv_tx] = mbmi->angle_delta[1];
@@ -11036,14 +10974,12 @@
distortion_uv = dist_uvs[uv_tx];
skippable = skippable && skip_uvs[uv_tx];
mbmi->uv_mode = mode_uv[uv_tx];
-#if CONFIG_PALETTE
if (try_palette) {
pmi->palette_size[1] = pmi_uv[uv_tx].palette_size[1];
memcpy(pmi->palette_colors + PALETTE_MAX_SIZE,
pmi_uv[uv_tx].palette_colors + PALETTE_MAX_SIZE,
2 * PALETTE_MAX_SIZE * sizeof(pmi->palette_colors[0]));
}
-#endif // CONFIG_PALETTE
#if CONFIG_EXT_INTRA
mbmi->angle_delta[1] = uv_angle_delta[uv_tx];
@@ -11066,12 +11002,10 @@
x->intra_uv_mode_cost[mbmi->mode][mbmi->uv_mode];
#endif // CONFIG_CB4X4
-#if CONFIG_PALETTE
if (try_palette && mbmi->mode == DC_PRED) {
rate2 += av1_cost_bit(
av1_default_palette_y_mode_prob[bsize - BLOCK_8X8][palette_ctx], 0);
}
-#endif // CONFIG_PALETTE
if (!xd->lossless[mbmi->segment_id] && bsize >= BLOCK_8X8) {
// super_block_yrd above includes the cost of the tx_size in the
@@ -11887,7 +11821,6 @@
}
#endif
-#if CONFIG_PALETTE
// Only try palette mode when the best mode so far is an intra mode.
if (try_palette && !is_inter_mode(best_mbmode.mode)) {
int rate2 = 0;
@@ -11983,15 +11916,11 @@
}
}
PALETTE_EXIT:
-#endif // CONFIG_PALETTE
#if CONFIG_FILTER_INTRA
// TODO(huisu): filter-intra is turned off in lossless mode for now to
// avoid a unit test failure
- if (!xd->lossless[mbmi->segment_id] &&
-#if CONFIG_PALETTE
- pmi->palette_size[0] == 0 &&
-#endif // CONFIG_PALETTE
+ if (!xd->lossless[mbmi->segment_id] && pmi->palette_size[0] == 0 &&
!dc_skipped && best_mode_index >= 0 &&
best_intra_rd < (best_rd + (best_rd >> 3))) {
pick_filter_intra_interframe(
@@ -12000,11 +11929,8 @@
#if CONFIG_EXT_INTRA
uv_angle_delta,
#endif // CONFIG_EXT_INTRA
-#if CONFIG_PALETTE
- pmi_uv, palette_ctx,
-#endif // CONFIG_PALETTE
- 0, ref_costs_single, &best_rd, &best_intra_rd, &best_intra_mode,
- &best_mode_index, &best_skip2, &best_mode_skippable,
+ pmi_uv, palette_ctx, 0, ref_costs_single, &best_rd, &best_intra_rd,
+ &best_intra_mode, &best_mode_index, &best_skip2, &best_mode_skippable,
#if CONFIG_SUPERTX
returnrate_nocoef,
#endif // CONFIG_SUPERTX
@@ -12285,12 +12211,10 @@
store_coding_context(x, ctx, best_mode_index, best_pred_diff,
best_mode_skippable);
-#if CONFIG_PALETTE
if (pmi->palette_size[1] > 0) {
assert(try_palette);
restore_uv_color_map(cpi, x);
}
-#endif // CONFIG_PALETTE
}
void av1_rd_pick_inter_mode_sb_seg_skip(const AV1_COMP *cpi,
@@ -12331,10 +12255,8 @@
assert(segfeature_active(&cm->seg, segment_id, SEG_LVL_SKIP));
-#if CONFIG_PALETTE
mbmi->palette_mode_info.palette_size[0] = 0;
mbmi->palette_mode_info.palette_size[1] = 0;
-#endif // CONFIG_PALETTE
#if CONFIG_FILTER_INTRA
mbmi->filter_intra_mode_info.use_filter_intra_mode[0] = 0;