Commit c6300aa1 authored by Urvang Joshi's avatar Urvang Joshi

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
parent 51a95933
......@@ -131,6 +131,8 @@ set(AOM_AV1_ENCODER_SOURCES
"${AOM_ROOT}/av1/encoder/mbgraph.h"
"${AOM_ROOT}/av1/encoder/mcomp.c"
"${AOM_ROOT}/av1/encoder/mcomp.h"
"${AOM_ROOT}/av1/encoder/palette.c"
"${AOM_ROOT}/av1/encoder/palette.h")
"${AOM_ROOT}/av1/encoder/picklpf.c"
"${AOM_ROOT}/av1/encoder/picklpf.h"
"${AOM_ROOT}/av1/encoder/ratectrl.c"
......@@ -363,13 +365,6 @@ if (CONFIG_LV_MAP)
"${AOM_ROOT}/av1/encoder/encodetxb.h")
endif ()
if (CONFIG_PALETTE)
set(AOM_AV1_ENCODER_SOURCES
${AOM_AV1_ENCODER_SOURCES}
"${AOM_ROOT}/av1/encoder/palette.c"
"${AOM_ROOT}/av1/encoder/palette.h")
endif ()
if (CONFIG_CFL)
set(AOM_AV1_COMMON_SOURCES
${AOM_AV1_COMMON_SOURCES}
......
......@@ -74,11 +74,9 @@ AV1_CX_SRCS-yes += encoder/tokenize.h
AV1_CX_SRCS-yes += encoder/treewriter.h
AV1_CX_SRCS-yes += encoder/mcomp.c
AV1_CX_SRCS-yes += encoder/encoder.c
ifeq ($(CONFIG_PALETTE),yes)
AV1_CX_SRCS-yes += encoder/k_means_template.h
AV1_CX_SRCS-yes += encoder/palette.h
AV1_CX_SRCS-yes += encoder/palette.c
endif
AV1_CX_SRCS-yes += encoder/picklpf.c
AV1_CX_SRCS-yes += encoder/picklpf.h
AV1_CX_SRCS-$(CONFIG_LOOP_RESTORATION) += encoder/pickrst.c
......
......@@ -307,14 +307,12 @@ typedef struct {
typedef int8_t MV_REFERENCE_FRAME;
#if CONFIG_PALETTE
typedef struct {
// Number of base colors for Y (0) and UV (1)
uint8_t palette_size[2];
// Value of base colors for Y, U, and V
uint16_t palette_colors[3 * PALETTE_MAX_SIZE];
} PALETTE_MODE_INFO;
#endif // CONFIG_PALETTE
#if CONFIG_FILTER_INTRA
#define USE_3TAP_INTRA_FILTER 1 // 0: 4-tap; 1: 3-tap
......@@ -399,9 +397,8 @@ typedef struct MB_MODE_INFO {
// Only for INTRA blocks
UV_PREDICTION_MODE uv_mode;
#if CONFIG_PALETTE
PALETTE_MODE_INFO palette_mode_info;
#endif // CONFIG_PALETTE
#if CONFIG_INTRABC
uint8_t use_intrabc;
#endif // CONFIG_INTRABC
......@@ -635,9 +632,7 @@ typedef struct macroblockd_plane {
dequant_val_type_nuq seg_dequant_nuq[MAX_SEGMENTS][QUANT_PROFILES]
[COEF_BANDS];
#endif
#if CONFIG_PALETTE
uint8_t *color_index_map;
#endif // CONFIG_PALETTE
// number of 4x4s in current block
uint16_t n4_w, n4_h;
......
......@@ -5678,12 +5678,10 @@ void av1_average_tile_intra_cdfs(FRAME_CONTEXT *fc, FRAME_CONTEXT *ec_ctxs[],
AVERAGE_TILE_CDFS(txfm_partition_cdf)
#endif
#endif // CONFIG_NEW_MULTISYMBOL
#if CONFIG_PALETTE
AVERAGE_TILE_CDFS(palette_y_size_cdf)
AVERAGE_TILE_CDFS(palette_uv_size_cdf)
AVERAGE_TILE_CDFS(palette_y_color_index_cdf)
AVERAGE_TILE_CDFS(palette_uv_color_index_cdf)
#endif
}
void av1_average_tile_inter_cdfs(AV1_COMMON *cm, FRAME_CONTEXT *fc,
......
......@@ -1474,7 +1474,6 @@ static const aom_prob default_comp_inter_mode_p[COMP_INTER_MODE_CONTEXTS] = {
};
#endif // CONFIG_EXT_INTER && CONFIG_COMPOUND_SINGLEREF
#if CONFIG_PALETTE
// TODO(huisu): tune these cdfs
const aom_cdf_prob
default_palette_y_size_cdf[PALETTE_BLOCK_SIZES][CDF_SIZE(PALETTE_SIZES)] = {
......@@ -1740,8 +1739,6 @@ static const int palette_color_index_context_lookup[MAX_COLOR_CONTEXT_HASH +
1] = { -1, -1, 0, -1, -1,
4, 3, 2, 1 };
#endif // CONFIG_PALETTE
// The transform size is coded as an offset to the smallest transform
// block size.
const aom_tree_index av1_tx_size_tree[MAX_TX_DEPTH][TREE_SIZE(TX_SIZES)] = {
......@@ -1807,7 +1804,6 @@ static const aom_prob
};
#endif // CONFIG_LOOP_RESTORATION
#if CONFIG_PALETTE
#define NUM_PALETTE_NEIGHBORS 3 // left, top-left and top.
int av1_get_palette_color_index_context(const uint8_t *color_map, int stride,
int r, int c, int palette_size,
......@@ -1892,8 +1888,6 @@ int av1_get_palette_color_index_context(const uint8_t *color_map, int stride,
#undef NUM_PALETTE_NEIGHBORS
#undef MAX_COLOR_CONTEXT_HASH
#endif // CONFIG_PALETTE
#if CONFIG_VAR_TX
static const aom_prob default_txfm_partition_probs[TXFM_PARTITION_CONTEXTS] = {
250, 231, 212, 241, 166, 66, 241, 230, 135, 243, 154, 64, 248, 161, 63, 128,
......@@ -5059,12 +5053,10 @@ static void init_mode_probs(FRAME_CONTEXT *fc) {
av1_copy(fc->partition_prob, default_partition_probs);
av1_copy(fc->intra_inter_prob, default_intra_inter_p);
av1_copy(fc->comp_inter_prob, default_comp_inter_p);
#if CONFIG_PALETTE
av1_copy(fc->palette_y_size_cdf, default_palette_y_size_cdf);
av1_copy(fc->palette_uv_size_cdf, default_palette_uv_size_cdf);
av1_copy(fc->palette_y_color_index_cdf, default_palette_y_color_index_cdf);
av1_copy(fc->palette_uv_color_index_cdf, default_palette_uv_color_index_cdf);
#endif // CONFIG_PALETTE
#if CONFIG_NEW_MULTISYMBOL
av1_copy(fc->comp_inter_cdf, default_comp_inter_cdf);
#endif // CONFIG_NEW_MULTISYMBOL
......
......@@ -40,7 +40,6 @@ extern "C" {
#define INTER_COMPOUND_OFFSET(mode) ((mode)-NEAREST_NEARESTMV)
#endif // CONFIG_EXT_INTER
#if CONFIG_PALETTE
// Number of possible contexts for a color index.
// As can be seen from av1_get_palette_color_index_context(), the possible
// contexts are (2,0,0), (2,2,1), (3,2,0), (4,1,0), (5,0,0). These are mapped to
......@@ -70,7 +69,6 @@ extern "C" {
#define PALETTE_UV_MODE_CONTEXTS 2
#define PALETTE_MAX_BLOCK_SIZE (64 * 64)
#endif // CONFIG_PALETTE
#if CONFIG_INTRABC
#define INTRABC_PROB_DEFAULT 192
......@@ -234,7 +232,6 @@ typedef struct frame_contexts {
#endif // CONFIG_MOTION_VAR || CONFIG_WARPED_MOTION
aom_prob intra_inter_prob[INTRA_INTER_CONTEXTS];
aom_prob comp_inter_prob[COMP_INTER_CONTEXTS];
#if CONFIG_PALETTE
aom_cdf_prob palette_y_size_cdf[PALETTE_BLOCK_SIZES][CDF_SIZE(PALETTE_SIZES)];
aom_cdf_prob palette_uv_size_cdf[PALETTE_BLOCK_SIZES]
[CDF_SIZE(PALETTE_SIZES)];
......@@ -244,7 +241,6 @@ typedef struct frame_contexts {
aom_cdf_prob palette_uv_color_index_cdf[PALETTE_SIZES]
[PALETTE_COLOR_INDEX_CONTEXTS]
[CDF_SIZE(PALETTE_COLORS)];
#endif // CONFIG_PALETTE
#if CONFIG_NEW_MULTISYMBOL
aom_cdf_prob comp_inter_cdf[COMP_INTER_CONTEXTS][CDF_SIZE(2)];
aom_cdf_prob single_ref_cdf[REF_CONTEXTS][SINGLE_REFS - 1][CDF_SIZE(2)];
......@@ -516,12 +512,10 @@ typedef struct FRAME_COUNTS {
extern const aom_cdf_prob av1_kf_y_mode_cdf[INTRA_MODES][INTRA_MODES]
[CDF_SIZE(INTRA_MODES)];
#if CONFIG_PALETTE
extern const aom_prob av1_default_palette_y_mode_prob[PALETTE_BLOCK_SIZES]
[PALETTE_Y_MODE_CONTEXTS];
extern const aom_prob
av1_default_palette_uv_mode_prob[PALETTE_UV_MODE_CONTEXTS];
#endif // CONFIG_PALETTE
extern const int av1_intra_mode_ind[INTRA_MODES];
extern const int av1_intra_mode_inv[INTRA_MODES];
......@@ -552,10 +546,8 @@ extern const aom_tree_index
#endif
extern const aom_tree_index
av1_switchable_interp_tree[TREE_SIZE(SWITCHABLE_FILTERS)];
#if CONFIG_PALETTE
extern const aom_tree_index
av1_palette_color_index_tree[PALETTE_SIZES][TREE_SIZE(PALETTE_COLORS)];
#endif // CONFIG_PALETTE
extern const aom_tree_index av1_tx_size_tree[MAX_TX_DEPTH][TREE_SIZE(TX_SIZES)];
#if CONFIG_EXT_INTRA && CONFIG_INTRA_INTERP
extern const aom_tree_index av1_intra_filter_tree[TREE_SIZE(INTRA_FILTERS)];
......@@ -607,14 +599,12 @@ static INLINE int av1_ceil_log2(int n) {
return i;
}
#if CONFIG_PALETTE
// Returns the context for palette color index at row 'r' and column 'c',
// along with the 'color_order' of neighbors and the 'color_idx'.
// The 'color_map' is a 2D array with the given 'stride'.
int av1_get_palette_color_index_context(const uint8_t *color_map, int stride,
int r, int c, int palette_size,
uint8_t *color_order, int *color_idx);
#endif // CONFIG_PALETTE
#ifdef __cplusplus
} // extern "C"
......
......@@ -385,7 +385,6 @@ typedef enum {
(CFL_SIGN_V(js) * CFL_SIGNS + CFL_SIGN_U(js) - CFL_SIGNS)
#endif
#if CONFIG_PALETTE
typedef enum {
TWO_COLORS,
THREE_COLORS,
......@@ -408,7 +407,6 @@ typedef enum {
PALETTE_COLOR_EIGHT,
PALETTE_COLORS
} PALETTE_COLOR;
#endif // CONFIG_PALETTE
// Note: All directional predictors must be between V_PRED and D63_PRED (both
// inclusive).
......
......@@ -232,9 +232,7 @@ typedef struct AV1Common {
int allow_high_precision_mv;
#if CONFIG_PALETTE || CONFIG_INTRABC
int allow_screen_content_tools;
#endif // CONFIG_PALETTE || CONFIG_INTRABC
#if CONFIG_EXT_INTER
#if CONFIG_INTERINTRA
int allow_interintra_compound;
......
......@@ -153,7 +153,7 @@ int av1_get_pred_context_intra_interp(const MACROBLOCKD *xd) {
#endif // CONFIG_INTRA_INTERP
#endif // CONFIG_EXT_INTRA
#if CONFIG_PALETTE && 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 plane, uint16_t *cache) {
int above_n = 0, left_n = 0;
......@@ -193,7 +193,7 @@ int av1_get_palette_cache(const MODE_INFO *above_mi, const MODE_INFO *left_mi,
assert(n <= 2 * PALETTE_MAX_SIZE);
return n;
}
#endif // CONFIG_PALETTE && CONFIG_PALETTE_DELTA_ENCODING
#endif // CONFIG_PALETTE_DELTA_ENCODING
// The mode info data structure has a one element border above and to the
// left of the entries corresponding to real macroblocks.
......
......@@ -86,14 +86,14 @@ int av1_get_pred_context_intra_interp(const MACROBLOCKD *xd);
#endif // CONFIG_INTRA_INTERP
#endif // CONFIG_EXT_INTRA
#if CONFIG_PALETTE && CONFIG_PALETTE_DELTA_ENCODING
#if CONFIG_PALETTE_DELTA_ENCODING
// Get a list of palette base colors that are used in the above and left blocks,
// 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"
// in ascending order.
int av1_get_palette_cache(const MODE_INFO *above_mi, const MODE_INFO *left_mi,
int plane, uint16_t *cache);
#endif // CONFIG_PALETTE && CONFIG_PALETTE_DELTA_ENCODING
#endif // CONFIG_PALETTE_DELTA_ENCODING
int av1_get_intra_inter_context(const MACROBLOCKD *xd);
......
......@@ -2991,7 +2991,6 @@ static void predict_intra_block_helper(const MACROBLOCKD *xd, int wpx, int hpx,
const int have_bottom_left =
has_bottom_left(bsize, mi_row, mi_col, bottom_available, have_left,
tx_size, row_off, col_off, pd->subsampling_y);
#if CONFIG_PALETTE
if (xd->mi[0]->mbmi.palette_mode_info.palette_size[plane != 0] > 0) {
const int stride = wpx;
int r, c;
......@@ -3020,7 +3019,6 @@ static void predict_intra_block_helper(const MACROBLOCKD *xd, int wpx, int hpx,
#endif // CONFIG_HIGHBITDEPTH
return;
}
#endif // CONFIG_PALETTE
#if CONFIG_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
......
......@@ -1898,12 +1898,10 @@ static void decode_token_and_recon_block(AV1Decoder *const pbi,
int row_y, col_y, row_c, col_c;
int plane;
#if CONFIG_PALETTE
for (plane = 0; plane <= 1; ++plane) {
if (mbmi->palette_mode_info.palette_size[plane])
av1_decode_palette_tokens(xd, plane, r);
}
#endif
for (row_y = 0; row_y < tu_num_h_y; row_y++) {
for (col_y = 0; col_y < tu_num_w_y; col_y++) {
......@@ -1983,12 +1981,10 @@ static void decode_token_and_recon_block(AV1Decoder *const pbi,
#else // CONFIG_COEF_INTERLEAVE
if (!is_inter_block(mbmi)) {
int plane;
#if CONFIG_PALETTE
for (plane = 0; plane <= 1; ++plane) {
if (mbmi->palette_mode_info.palette_size[plane])
av1_decode_palette_tokens(xd, plane, r);
}
#endif // CONFIG_PALETTE
for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
const struct macroblockd_plane *const pd = &xd->plane[plane];
const TX_SIZE tx_size = av1_get_tx_size(plane, xd);
......@@ -3841,10 +3837,8 @@ static const uint8_t *decode_tiles(AV1Decoder *pbi, const uint8_t *data,
td->xd.daala_dec.state.adapt = &td->tctx.pvq_context;
#endif
#if CONFIG_PALETTE
td->xd.plane[0].color_index_map = td->color_index_map[0];
td->xd.plane[1].color_index_map = td->color_index_map[1];
#endif // CONFIG_PALETTE
}
}
......@@ -4223,10 +4217,8 @@ static const uint8_t *decode_tiles_mt(AV1Decoder *pbi, const uint8_t *data,
// Initialise the tile context from the frame context
twd->tctx = *cm->fc;
twd->xd.tile_ctx = &twd->tctx;
#if CONFIG_PALETTE
twd->xd.plane[0].color_index_map = twd->color_index_map[0];
twd->xd.plane[1].color_index_map = twd->color_index_map[1];
#endif // CONFIG_PALETTE
worker->had_error = 0;
if (i == num_workers - 1 || tile_col == tile_cols_end - 1) {
......@@ -4561,17 +4553,13 @@ static size_t read_uncompressed_header(AV1Decoder *pbi,
#if CONFIG_ANS && ANS_MAX_SYMBOLS
cm->ans_window_size_log2 = aom_rb_read_literal(rb, 4) + 8;
#endif // CONFIG_ANS && ANS_MAX_SYMBOLS
#if CONFIG_PALETTE || CONFIG_INTRABC
cm->allow_screen_content_tools = aom_rb_read_bit(rb);
#endif // CONFIG_PALETTE || CONFIG_INTRABC
#if CONFIG_TEMPMV_SIGNALING
cm->use_prev_frame_mvs = 0;
#endif
} else {
cm->intra_only = cm->show_frame ? 0 : aom_rb_read_bit(rb);
#if CONFIG_PALETTE || CONFIG_INTRABC
if (cm->intra_only) cm->allow_screen_content_tools = aom_rb_read_bit(rb);
#endif // CONFIG_PALETTE || CONFIG_INTRABC
#if CONFIG_TEMPMV_SIGNALING
if (cm->intra_only || cm->error_resilient_mode) cm->use_prev_frame_mvs = 0;
#endif
......
......@@ -691,7 +691,6 @@ static int read_skip(AV1_COMMON *cm, const MACROBLOCKD *xd, int segment_id,
}
}
#if CONFIG_PALETTE
#if CONFIG_PALETTE_DELTA_ENCODING
static int uint16_compare(const void *a, const void *b) {
const uint16_t va = *(const uint16_t *)a;
......@@ -840,7 +839,6 @@ static void read_palette_mode_info(AV1_COMMON *const cm, MACROBLOCKD *const xd,
}
}
}
#endif // CONFIG_PALETTE
#if CONFIG_FILTER_INTRA
static void read_filter_intra_mode_info(AV1_COMMON *const cm,
......@@ -852,11 +850,7 @@ static void read_filter_intra_mode_info(AV1_COMMON *const cm,
FILTER_INTRA_MODE_INFO *filter_intra_mode_info =
&mbmi->filter_intra_mode_info;
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) {
filter_intra_mode_info->use_filter_intra_mode[0] =
aom_read(r, cm->fc->filter_intra_probs[0], ACCT_STR);
if (filter_intra_mode_info->use_filter_intra_mode[0]) {
......@@ -879,11 +873,8 @@ static void read_filter_intra_mode_info(AV1_COMMON *const cm,
(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) {
filter_intra_mode_info->use_filter_intra_mode[1] =
aom_read(r, cm->fc->filter_intra_probs[1], ACCT_STR);
if (filter_intra_mode_info->use_filter_intra_mode[1]) {
......@@ -1210,13 +1201,11 @@ static void read_intra_frame_mode_info(AV1_COMMON *const cm,
#if CONFIG_EXT_INTRA
read_intra_angle_info(cm, xd, r);
#endif // CONFIG_EXT_INTRA
#if CONFIG_PALETTE
mbmi->palette_mode_info.palette_size[0] = 0;
mbmi->palette_mode_info.palette_size[1] = 0;
if (bsize >= BLOCK_8X8 && bsize <= BLOCK_LARGEST &&
cm->allow_screen_content_tools)
read_palette_mode_info(cm, xd, r);
#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;
......@@ -1818,12 +1807,10 @@ static void read_intra_block_mode_info(AV1_COMMON *const cm, const int mi_row,
#if CONFIG_EXT_INTRA
read_intra_angle_info(cm, xd, r);
#endif // CONFIG_EXT_INTRA
#if CONFIG_PALETTE
mbmi->palette_mode_info.palette_size[0] = 0;
mbmi->palette_mode_info.palette_size[1] = 0;
if (bsize >= BLOCK_8X8 && cm->allow_screen_content_tools)
read_palette_mode_info(cm, xd, r);
#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;
......@@ -2241,10 +2228,8 @@ static void read_inter_block_mode_info(AV1Decoder *const pbi,
assert(NELEMENTS(mode_2_counter) == MB_MODE_COUNT);
#if CONFIG_PALETTE
mbmi->palette_mode_info.palette_size[0] = 0;
mbmi->palette_mode_info.palette_size[1] = 0;
#endif // CONFIG_PALETTE
memset(ref_mvs, 0, sizeof(ref_mvs));
......
......@@ -54,9 +54,7 @@ typedef struct TileData {
CFL_CTX cfl;
#endif
DECLARE_ALIGNED(16, FRAME_CONTEXT, tctx);
#if CONFIG_PALETTE
DECLARE_ALIGNED(16, uint8_t, color_index_map[2][MAX_SB_SQUARE]);
#endif // CONFIG_PALETTE
} TileData;
typedef struct TileWorkerData {
......@@ -74,9 +72,7 @@ typedef struct TileWorkerData {
CFL_CTX cfl;
#endif
FRAME_CONTEXT tctx;
#if CONFIG_PALETTE
DECLARE_ALIGNED(16, uint8_t, color_index_map[2][MAX_SB_SQUARE]);
#endif // CONFIG_PALETTE
struct aom_internal_error_info error_info;
} TileWorkerData;
......@@ -213,7 +209,6 @@ static INLINE int dec_is_ref_frame_buf(AV1Decoder *const pbi,
}
#endif // CONFIG_EXT_REFS
#if CONFIG_EXT_INTRA || CONFIG_FILTER_INTRA || CONFIG_PALETTE
#define ACCT_STR __func__
static INLINE int av1_read_uniform(aom_reader *r, int n) {
const int l = get_unsigned_bits(n);
......@@ -225,7 +220,6 @@ static INLINE int av1_read_uniform(aom_reader *r, int n) {
else
return (v << 1) - m + aom_read_literal(r, 1, ACCT_STR);
}
#endif // CONFIG_EXT_INTRA || CONFIG_FILTER_INTRA || CONFIG_PALETTE
#ifdef __cplusplus
} // extern "C"
......
......@@ -218,7 +218,6 @@ static int decode_coefs(MACROBLOCKD *xd, PLANE_TYPE type, tran_low_t *dqcoeff,
}
#endif // !CONFIG_PVQ
#if CONFIG_PALETTE
void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane,
aom_reader *r) {
const MODE_INFO *const mi = xd->mi[0];
......@@ -281,7 +280,6 @@ void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane,
color_map + (rows - 1) * plane_block_width, plane_block_width);
}
}
#endif // CONFIG_PALETTE
#if !CONFIG_PVQ || CONFIG_VAR_TX
int av1_decode_block_tokens(AV1_COMMON *cm, MACROBLOCKD *const xd, int plane,
......
......@@ -22,9 +22,7 @@
extern "C" {
#endif
#if CONFIG_PALETTE
void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane, aom_reader *r);
#endif // CONFIG_PALETTE
#if !CONFIG_PVQ || CONFIG_VAR_TX
int av1_decode_block_tokens(AV1_COMMON *cm, MACROBLOCKD *const xd, int plane,
......
......@@ -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 @@ static struct av1_token
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 @@ static INLINE void write_uniform(aom_writer *w, int n, int v) {
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 @@ static void update_skip_probs(AV1_COMMON *cm, aom_writer *w,
}
#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 @@ static void pack_palette_tokens(aom_writer *w, const TOKENEXTRA **tp, int n,
}
*tp = p;
}
#endif // CONFIG_PALETTE
#if !CONFIG_PVQ
#if CONFIG_SUPERTX
......@@ -1280,11 +1276,7 @@ static void write_filter_intra_mode_info(const AV1_COMMON *const cm,
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 @@ static void write_filter_intra_mode_info(const AV1_COMMON *const cm,
(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 @@ static void write_mb_interp_filter(AV1_COMP *cpi, const MACROBLOCKD *xd,
}
}
#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 @@ static void write_palette_mode_info(const AV1_COMMON *cm, const MACROBLOCKD *xd,
}
}
}
#endif // CONFIG_PALETTE
void av1_write_tx_type(const AV1_COMMON *const cm, const MACROBLOCKD *xd,
#if CONFIG_SUPERTX
......@@ -1878,10 +1865,8 @@ static void pack_inter_mode_mvs(AV1_COMP *cpi, const int mi_row,
#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 @@ static void write_mb_modes_kf(AV1_COMMON *cm,
#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 @@ static void write_tokens_b(AV1_COMP *cpi, const TileInfo *const tile,
#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 @@ static void write_tokens_b(AV1_COMP *cpi, const TileInfo *const tile,
assert(*tok < tok_end + mbmi->skip);
}
}
#endif // CONFIG_PALETTE
#if CONFIG_COEF_INTERLEAVE
if (!mbmi->skip) {
......@@ -4349,14 +4330,10 @@ static void write_uncompressed_header(AV1_COMP *cpi,
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) {
......
......@@ -89,12 +89,10 @@ typedef struct {
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 @@ struct macroblock {
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 @@ struct macroblock {
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];
......
......@@ -64,13 +64,11 @@ static void alloc_mode_context(AV1_COMMON *cm, int num_4x4_blk,
#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 @@ static void free_mode_context(PICK_MODE_CONTEXT *ctx) {
#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,
......
......@@ -27,9 +27,7 @@ struct ThreadData;
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
......
......@@ -649,9 +649,7 @@ static void update_state(const AV1_COMP *const cpi, ThreadData *td,
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 @@ static void rd_pick_sb_modes(const AV1_COMP *const cpi, TileDataEnc *tile_data,
#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 @@ static int do_gm_search_logic(SPEED_FEATURES *const sf, int num_refs_using_gm,
}
#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 @@ static int is_screen_content(const uint8_t *src,
// 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 @@ static void encode_frame_internal(AV1_COMP *cpi) {
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 @@ static void encode_frame_internal(AV1_COMP *cpi) {
#endif // CONFIG_HIGHBITDEPTH
cpi->source->y_stride, cpi->source->y_width,