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/bitstream.c b/av1/encoder/bitstream.c
index 61483e3..4a6fbd8 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -50,9 +50,9 @@
#include "av1/encoder/cost.h"
#include "av1/encoder/encodemv.h"
#include "av1/encoder/mcomp.h"
-#if CONFIG_PALETTE && CONFIG_PALETTE_DELTA_ENCODING
+#if CONFIG_PALETTE_DELTA_ENCODING
#include "av1/encoder/palette.h"
-#endif // CONFIG_PALETTE && CONFIG_PALETTE_DELTA_ENCODING
+#endif // CONFIG_PALETTE_DELTA_ENCODING
#include "av1/encoder/segmentation.h"
#include "av1/encoder/subexp.h"
#include "av1/encoder/tokenize.h"
@@ -67,7 +67,6 @@
inter_singleref_comp_mode_encodings[INTER_SINGLEREF_COMP_MODES];
#endif // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
-#if CONFIG_EXT_INTRA || CONFIG_FILTER_INTRA || CONFIG_PALETTE
static INLINE void write_uniform(aom_writer *w, int n, int v) {
const int l = get_unsigned_bits(n);
const int m = (1 << l) - n;
@@ -79,7 +78,6 @@
aom_write_literal(w, (v - m) & 1, 1);
}
}
-#endif // CONFIG_EXT_INTRA || CONFIG_FILTER_INTRA || CONFIG_PALETTE
#if CONFIG_EXT_TX
static struct av1_token ext_tx_inter_encodings[EXT_TX_SETS_INTER][TX_TYPES];
@@ -622,7 +620,6 @@
}
#endif
-#if CONFIG_PALETTE
static void pack_palette_tokens(aom_writer *w, const TOKENEXTRA **tp, int n,
int num) {
const TOKENEXTRA *p = *tp;
@@ -635,7 +632,6 @@
}
*tp = p;
}
-#endif // CONFIG_PALETTE
#if !CONFIG_PVQ
#if CONFIG_SUPERTX
@@ -1280,11 +1276,7 @@
const MB_MODE_INFO *const mbmi,
int mi_row, int mi_col,
aom_writer *w) {
- if (mbmi->mode == DC_PRED
-#if CONFIG_PALETTE
- && mbmi->palette_mode_info.palette_size[0] == 0
-#endif // CONFIG_PALETTE
- ) {
+ if (mbmi->mode == DC_PRED && mbmi->palette_mode_info.palette_size[0] == 0) {
aom_write(w, mbmi->filter_intra_mode_info.use_filter_intra_mode[0],
cm->fc->filter_intra_probs[0]);
if (mbmi->filter_intra_mode_info.use_filter_intra_mode[0]) {
@@ -1305,11 +1297,8 @@
(void)mi_col;
#endif // CONFIG_CB4X4
- if (mbmi->uv_mode == UV_DC_PRED
-#if CONFIG_PALETTE
- && mbmi->palette_mode_info.palette_size[1] == 0
-#endif // CONFIG_PALETTE
- ) {
+ if (mbmi->uv_mode == UV_DC_PRED &&
+ mbmi->palette_mode_info.palette_size[1] == 0) {
aom_write(w, mbmi->filter_intra_mode_info.use_filter_intra_mode[1],
cm->fc->filter_intra_probs[1]);
if (mbmi->filter_intra_mode_info.use_filter_intra_mode[1]) {
@@ -1400,7 +1389,6 @@
}
}
-#if CONFIG_PALETTE
#if CONFIG_PALETTE_DELTA_ENCODING
// Transmit color values with delta encoding. Write the first value as
// literal, and the deltas between each value and the previous one. "min_val" is
@@ -1590,7 +1578,6 @@
}
}
}
-#endif // CONFIG_PALETTE
void av1_write_tx_type(const AV1_COMMON *const cm, const MACROBLOCKD *xd,
#if CONFIG_SUPERTX
@@ -1878,10 +1865,8 @@
#if CONFIG_EXT_INTRA
write_intra_angle_info(xd, ec_ctx, w);
#endif // CONFIG_EXT_INTRA
-#if CONFIG_PALETTE
if (bsize >= BLOCK_8X8 && cm->allow_screen_content_tools)
write_palette_mode_info(cm, xd, mi, w);
-#endif // CONFIG_PALETTE
#if CONFIG_FILTER_INTRA
if (bsize >= BLOCK_8X8 || unify_bsize)
write_filter_intra_mode_info(cm, xd, mbmi, mi_row, mi_col, w);
@@ -2286,11 +2271,9 @@
#if CONFIG_EXT_INTRA
write_intra_angle_info(xd, ec_ctx, w);
#endif // CONFIG_EXT_INTRA
-#if CONFIG_PALETTE
if (bsize >= BLOCK_8X8 && bsize <= BLOCK_LARGEST &&
cm->allow_screen_content_tools)
write_palette_mode_info(cm, xd, mi, w);
-#endif // CONFIG_PALETTE
#if CONFIG_FILTER_INTRA
if (bsize >= BLOCK_8X8 || unify_bsize)
write_filter_intra_mode_info(cm, xd, mbmi, mi_row, mi_col, w);
@@ -2536,7 +2519,6 @@
#endif // CONFIG_DEPENDENT_HORZTILES
cm->mi_rows, cm->mi_cols);
-#if CONFIG_PALETTE
for (plane = 0; plane <= 1; ++plane) {
const uint8_t palette_size_plane =
mbmi->palette_mode_info.palette_size[plane];
@@ -2553,7 +2535,6 @@
assert(*tok < tok_end + mbmi->skip);
}
}
-#endif // CONFIG_PALETTE
#if CONFIG_COEF_INTERLEAVE
if (!mbmi->skip) {
@@ -4349,14 +4330,10 @@
assert(cpi->common.ans_window_size_log2 < 24);
aom_wb_write_literal(wb, cpi->common.ans_window_size_log2 - 8, 4);
#endif // CONFIG_ANS && ANS_MAX_SYMBOLS
-#if CONFIG_PALETTE || CONFIG_INTRABC
aom_wb_write_bit(wb, cm->allow_screen_content_tools);
-#endif // CONFIG_PALETTE || CONFIG_INTRABC
} else {
if (!cm->show_frame) aom_wb_write_bit(wb, cm->intra_only);
-#if CONFIG_PALETTE || CONFIG_INTRABC
if (cm->intra_only) aom_wb_write_bit(wb, cm->allow_screen_content_tools);
-#endif // CONFIG_PALETTE || CONFIG_INTRABC
#if !CONFIG_NO_FRAME_CONTEXT_SIGNALING
if (!cm->error_resilient_mode) {
if (cm->intra_only) {
diff --git a/av1/encoder/block.h b/av1/encoder/block.h
index 5d6b08f..2bdfff3 100644
--- a/av1/encoder/block.h
+++ b/av1/encoder/block.h
@@ -89,12 +89,10 @@
int row_max;
} MvLimits;
-#if CONFIG_PALETTE
typedef struct {
uint8_t best_palette_color_map[MAX_SB_SQUARE];
float kmeans_data_buf[2 * MAX_SB_SQUARE];
} PALETTE_BUFFER;
-#endif // CONFIG_PALETTE
typedef struct macroblock MACROBLOCK;
struct macroblock {
@@ -148,9 +146,7 @@
uint8_t *left_pred_buf;
#endif // CONFIG_MOTION_VAR
-#if CONFIG_PALETTE
PALETTE_BUFFER *palette_buffer;
-#endif // CONFIG_PALETTE
// These define limits to motion vector components to prevent them
// from extending outside the UMV borders
@@ -206,14 +202,12 @@
int partition_cost[PARTITION_CONTEXTS + CONFIG_UNPOISON_PARTITION_CTX]
[PARTITION_TYPES];
#endif // CONFIG_EXT_PARTITION_TYPES
-#if CONFIG_PALETTE
int palette_y_size_cost[PALETTE_BLOCK_SIZES][PALETTE_SIZES];
int palette_uv_size_cost[PALETTE_BLOCK_SIZES][PALETTE_SIZES];
int palette_y_color_cost[PALETTE_SIZES][PALETTE_COLOR_INDEX_CONTEXTS]
[PALETTE_COLORS];
int palette_uv_color_cost[PALETTE_SIZES][PALETTE_COLOR_INDEX_CONTEXTS]
[PALETTE_COLORS];
-#endif // CONFIG_PALETTE
int tx_size_cost[TX_SIZES - 1][TX_SIZE_CONTEXTS][TX_SIZES];
#if CONFIG_EXT_TX
int inter_tx_type_costs[EXT_TX_SETS_INTER][EXT_TX_SIZES][TX_TYPES];
diff --git a/av1/encoder/context_tree.c b/av1/encoder/context_tree.c
index b1c01b2..41ca53e 100644
--- a/av1/encoder/context_tree.c
+++ b/av1/encoder/context_tree.c
@@ -64,13 +64,11 @@
#endif
}
-#if CONFIG_PALETTE
for (i = 0; i < 2; ++i) {
CHECK_MEM_ERROR(
cm, ctx->color_index_map[i],
aom_memalign(32, num_pix * sizeof(*ctx->color_index_map[i])));
}
-#endif // CONFIG_PALETTE
}
static void free_mode_context(PICK_MODE_CONTEXT *ctx) {
@@ -98,12 +96,10 @@
#endif
}
-#if CONFIG_PALETTE
for (i = 0; i < 2; ++i) {
aom_free(ctx->color_index_map[i]);
ctx->color_index_map[i] = 0;
}
-#endif // CONFIG_PALETTE
}
static void alloc_tree_contexts(AV1_COMMON *cm, PC_TREE *tree,
diff --git a/av1/encoder/context_tree.h b/av1/encoder/context_tree.h
index bcfcc27..8027a3f 100644
--- a/av1/encoder/context_tree.h
+++ b/av1/encoder/context_tree.h
@@ -27,9 +27,7 @@
typedef struct {
MODE_INFO mic;
MB_MODE_INFO_EXT mbmi_ext;
-#if CONFIG_PALETTE
uint8_t *color_index_map[2];
-#endif // CONFIG_PALETTE
#if CONFIG_VAR_TX
uint8_t *blk_skip[MAX_MB_PLANE];
#endif
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index f1982d8..b157a69 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -649,9 +649,7 @@
p[i].txb_entropy_ctx = ctx->txb_entropy_ctx[i];
#endif // CONFIG_LV_MAP
}
-#if CONFIG_PALETTE
for (i = 0; i < 2; ++i) pd[i].color_index_map = ctx->color_index_map[i];
-#endif // CONFIG_PALETTE
// Restore the coding context of the MB to that that was in place
// when the mode was picked for it
for (y = 0; y < mi_height; y++)
@@ -1413,9 +1411,7 @@
#endif
}
-#if CONFIG_PALETTE
for (i = 0; i < 2; ++i) pd[i].color_index_map = ctx->color_index_map[i];
-#endif // CONFIG_PALETTE
ctx->skippable = 0;
@@ -5012,7 +5008,6 @@
}
#endif // CONFIG_GLOBAL_MOTION
-#if CONFIG_PALETTE
// Estimate if the source frame is screen content, based on the portion of
// blocks that have no more than 4 (experimentally selected) luma colors.
static int is_screen_content(const uint8_t *src,
@@ -5040,7 +5035,6 @@
// The threshold is 10%.
return counts * blk_h * blk_w * 10 > width * height;
}
-#endif // CONFIG_PALETTE
static void encode_frame_internal(AV1_COMP *cpi) {
ThreadData *const td = &cpi->td;
@@ -5068,9 +5062,7 @@
av1_zero(rdc->coef_counts);
av1_zero(rdc->comp_pred_diff);
-#if CONFIG_PALETTE || CONFIG_INTRABC
if (frame_is_intra_only(cm)) {
-#if CONFIG_PALETTE
cm->allow_screen_content_tools =
cpi->oxcf.content == AOM_CONTENT_SCREEN ||
is_screen_content(cpi->source->y_buffer,
@@ -5079,11 +5071,7 @@
#endif // CONFIG_HIGHBITDEPTH
cpi->source->y_stride, cpi->source->y_width,
cpi->source->y_height);
-#else
- cm->allow_screen_content_tools = cpi->oxcf.content == AOM_CONTENT_SCREEN;
-#endif // CONFIG_PALETTE
}
-#endif // CONFIG_PALETTE || CONFIG_INTRABC
#if CONFIG_GLOBAL_MOTION
av1_zero(rdc->global_motion_used);
@@ -5702,11 +5690,7 @@
}
#endif // CONFIG_ENTROPY_STATS
#if CONFIG_FILTER_INTRA
- if (mbmi->mode == DC_PRED
-#if CONFIG_PALETTE
- && mbmi->palette_mode_info.palette_size[0] == 0
-#endif // CONFIG_PALETTE
- ) {
+ if (mbmi->mode == DC_PRED && mbmi->palette_mode_info.palette_size[0] == 0) {
const int use_filter_intra_mode =
mbmi->filter_intra_mode_info.use_filter_intra_mode[0];
++counts->filter_intra[0][use_filter_intra_mode];
@@ -5717,10 +5701,7 @@
is_chroma_reference(mi_row, mi_col, bsize, xd->plane[1].subsampling_x,
xd->plane[1].subsampling_y)
#endif
-#if CONFIG_PALETTE
- && mbmi->palette_mode_info.palette_size[1] == 0
-#endif // CONFIG_PALETTE
- ) {
+ && mbmi->palette_mode_info.palette_size[1] == 0) {
const int use_filter_intra_mode =
mbmi->filter_intra_mode_info.use_filter_intra_mode[1];
++counts->filter_intra[1][use_filter_intra_mode];
@@ -5978,14 +5959,12 @@
sum_intra_stats(td->counts, xd, mi, xd->above_mi, xd->left_mi,
frame_is_intra_only(cm), mi_row, mi_col);
}
-#if CONFIG_PALETTE
if (bsize >= BLOCK_8X8 && !dry_run) {
for (plane = 0; plane <= 1; ++plane) {
if (mbmi->palette_mode_info.palette_size[plane] > 0)
av1_tokenize_palette_sb(td, plane, t, dry_run, bsize, rate);
}
}
-#endif // CONFIG_PALETTE
#if CONFIG_VAR_TX
mbmi->min_tx_size = get_min_tx_size(mbmi->tx_size);
#endif
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 2dadc97..da2370b 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -529,9 +529,7 @@
av1_free_pc_tree(&cpi->td);
-#if CONFIG_PALETTE
aom_free(cpi->td.mb.palette_buffer);
-#endif // CONFIG_PALETTE
#if CONFIG_ANS
aom_buf_ans_free(&cpi->buf_ans);
@@ -2323,12 +2321,10 @@
cm->reset_frame_context = RESET_FRAME_CONTEXT_NONE;
#endif
-#if CONFIG_PALETTE
if (x->palette_buffer == NULL) {
CHECK_MEM_ERROR(cm, x->palette_buffer,
aom_memalign(16, sizeof(*x->palette_buffer)));
}
-#endif // CONFIG_PALETTE
#if CONFIG_EXT_INTER
set_compound_tools(cm);
#endif // CONFIG_EXT_INTER
@@ -2962,9 +2958,7 @@
// Deallocate allocated thread data.
if (t < cpi->num_workers - 1) {
-#if CONFIG_PALETTE
aom_free(thread_data->td->palette_buffer);
-#endif // CONFIG_PALETTE
#if CONFIG_MOTION_VAR
aom_free(thread_data->td->above_pred_buf);
aom_free(thread_data->td->left_pred_buf);
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index e71c91c..1902647 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -350,9 +350,7 @@
uint8_t *left_pred_buf;
#endif
-#if CONFIG_PALETTE
PALETTE_BUFFER *palette_buffer;
-#endif // CONFIG_PALETTE
} ThreadData;
struct EncWorkerData;
diff --git a/av1/encoder/ethread.c b/av1/encoder/ethread.c
index 1aa1d52..1768757 100644
--- a/av1/encoder/ethread.c
+++ b/av1/encoder/ethread.c
@@ -124,12 +124,10 @@
CHECK_MEM_ERROR(cm, thread_data->td->counts,
aom_calloc(1, sizeof(*thread_data->td->counts)));
-#if CONFIG_PALETTE
// Allocate buffers used by palette coding mode.
CHECK_MEM_ERROR(
cm, thread_data->td->palette_buffer,
aom_memalign(16, sizeof(*thread_data->td->palette_buffer)));
-#endif // CONFIG_PALETTE
// Create threads
if (!winterface->reset(worker))
@@ -169,10 +167,8 @@
sizeof(cpi->common.counts));
}
-#if CONFIG_PALETTE
if (i < num_workers - 1)
thread_data->td->mb.palette_buffer = thread_data->td->palette_buffer;
-#endif // CONFIG_PALETTE
}
// Encode a frame
diff --git a/av1/encoder/rd.c b/av1/encoder/rd.c
index d6867f0..073b714 100644
--- a/av1/encoder/rd.c
+++ b/av1/encoder/rd.c
@@ -117,7 +117,6 @@
fc->switchable_interp_cdf[i],
av1_switchable_interp_inv);
-#if CONFIG_PALETTE
for (i = 0; i < PALETTE_BLOCK_SIZES; ++i) {
av1_cost_tokens_from_cdf(x->palette_y_size_cost[i],
fc->palette_y_size_cdf[i], NULL);
@@ -133,7 +132,6 @@
fc->palette_uv_color_index_cdf[i][j], NULL);
}
}
-#endif // CONFIG_PALETTE
for (i = 0; i < MAX_TX_DEPTH; ++i)
for (j = 0; j < TX_SIZE_CONTEXTS; ++j)
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;
diff --git a/av1/encoder/rdopt.h b/av1/encoder/rdopt.h
index 83c3fb8..e1b5b2d 100644
--- a/av1/encoder/rdopt.h
+++ b/av1/encoder/rdopt.h
@@ -57,7 +57,6 @@
OUTPUT_HAS_DECODED_PIXELS
} OUTPUT_STATUS;
-#if CONFIG_PALETTE || CONFIG_INTRABC
// Returns the number of colors in 'src'.
int av1_count_colors(const uint8_t *src, int stride, int rows, int cols);
#if CONFIG_HIGHBITDEPTH
@@ -65,7 +64,6 @@
int av1_count_colors_highbd(const uint8_t *src8, int stride, int rows, int cols,
int bit_depth);
#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,
diff --git a/av1/encoder/tokenize.c b/av1/encoder/tokenize.c
index 2cc918e..f7fe706 100644
--- a/av1/encoder/tokenize.c
+++ b/av1/encoder/tokenize.c
@@ -329,7 +329,6 @@
}
#endif // !CONFIG_PVQ || CONFIG_VAR_TX
-#if CONFIG_PALETTE
void av1_tokenize_palette_sb(const struct ThreadData *const td, int plane,
TOKENEXTRA **t, RUN_TYPE dry_run, BLOCK_SIZE bsize,
int *rate) {
@@ -379,7 +378,6 @@
}
if (rate) *rate += this_rate;
}
-#endif // CONFIG_PALETTE
#if CONFIG_PVQ
static void add_pvq_block(AV1_COMMON *const cm, MACROBLOCK *const x,
diff --git a/av1/encoder/tokenize.h b/av1/encoder/tokenize.h
index 5827ee3..02c0be6 100644
--- a/av1/encoder/tokenize.h
+++ b/av1/encoder/tokenize.h
@@ -37,9 +37,7 @@
typedef struct {
aom_cdf_prob (*tail_cdf)[CDF_SIZE(ENTROPY_TOKENS)];
aom_cdf_prob (*head_cdf)[CDF_SIZE(ENTROPY_TOKENS)];
-#if CONFIG_PALETTE
aom_cdf_prob *palette_cdf;
-#endif // CONFIG_PALETTE
int eob_val;
int first_val;
const aom_prob *context_tree;
@@ -76,11 +74,9 @@
TOKENEXTRA **t, RUN_TYPE dry_run, int mi_row,
int mi_col, BLOCK_SIZE bsize, int *rate);
#endif
-#if CONFIG_PALETTE
void av1_tokenize_palette_sb(const struct ThreadData *const td, int plane,
TOKENEXTRA **t, RUN_TYPE dry_run, BLOCK_SIZE bsize,
int *rate);
-#endif // CONFIG_PALETTE
void av1_tokenize_sb(const struct AV1_COMP *cpi, struct ThreadData *td,
TOKENEXTRA **t, RUN_TYPE dry_run, BLOCK_SIZE bsize,
int *rate, const int mi_row, const int mi_col);