Wrap palette code inside CONFIG_PALETTE flag.

This flag was already added to aomedia/master, so bringing it back to
webm/nextgenv2, as part of an effort to get the two codebases in sync.

Change-Id: I2b933a6a160e4210d1411a9e7978149eb8553205
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index 65a162b..000757f 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -1209,10 +1209,12 @@
   }
   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 = plane ? get_uv_tx_size(mbmi, pd) : mbmi->tx_size;
@@ -2785,8 +2787,10 @@
                           &td->bit_reader, pbi->decrypt_cb, pbi->decrypt_state);
 #endif
       av1_init_macroblockd(cm, &td->xd, td->dqcoeff);
+#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
     }
   }
 
@@ -3095,8 +3099,10 @@
                             pbi->decrypt_state);
 #endif  // CONFIG_ANS
         av1_init_macroblockd(cm, &twd->xd, twd->dqcoeff);
+#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) {
@@ -3283,10 +3289,14 @@
       memset(&cm->ref_frame_map, -1, sizeof(cm->ref_frame_map));
       pbi->need_resync = 0;
     }
+#if CONFIG_PALETTE
     cm->allow_screen_content_tools = aom_rb_read_bit(rb);
+#endif  // CONFIG_PALETTE
   } else {
     cm->intra_only = cm->show_frame ? 0 : aom_rb_read_bit(rb);
+#if CONFIG_PALETTE
     if (cm->intra_only) cm->allow_screen_content_tools = aom_rb_read_bit(rb);
+#endif  // CONFIG_PALETTE
     if (cm->error_resilient_mode) {
       cm->reset_frame_context = RESET_FRAME_CONTEXT_ALL;
     } else {
diff --git a/av1/decoder/decodemv.c b/av1/decoder/decodemv.c
index 3f9ab23..3ede7e0 100644
--- a/av1/decoder/decodemv.c
+++ b/av1/decoder/decodemv.c
@@ -25,6 +25,7 @@
 
 #include "aom_dsp/aom_dsp_common.h"
 
+#if CONFIG_EXT_INTRA || CONFIG_PALETTE
 static INLINE int read_uniform(aom_reader *r, int n) {
   int l = get_unsigned_bits(n);
   int m = (1 << l) - n;
@@ -37,6 +38,7 @@
   else
     return (v << 1) - m + aom_read_literal(r, 1);
 }
+#endif  // CONFIG_EXT_INTRA || CONFIG_PALETTE
 
 static PREDICTION_MODE read_intra_mode(aom_reader *r, const aom_prob *p) {
   return (PREDICTION_MODE)aom_read_tree(r, av1_intra_mode_tree, p);
@@ -443,6 +445,7 @@
   }
 }
 
+#if CONFIG_PALETTE
 static void read_palette_mode_info(AV1_COMMON *const cm, MACROBLOCKD *const xd,
                                    aom_reader *r) {
   MODE_INFO *const mi = xd->mi[0];
@@ -492,6 +495,7 @@
     }
   }
 }
+#endif  // CONFIG_PALETTE
 
 #if CONFIG_EXT_INTRA
 static void read_ext_intra_mode_info(AV1_COMMON *const cm,
@@ -503,7 +507,11 @@
 #if !ALLOW_FILTER_INTRA_MODES
   return;
 #endif
-  if (mbmi->mode == DC_PRED && mbmi->palette_mode_info.palette_size[0] == 0) {
+  if (mbmi->mode == DC_PRED
+#if CONFIG_PALETTE
+      && mbmi->palette_mode_info.palette_size[0] == 0
+#endif  // CONFIG_PALETTE
+      ) {
     mbmi->ext_intra_mode_info.use_ext_intra_mode[0] =
         aom_read(r, cm->fc->ext_intra_probs[0]);
     if (mbmi->ext_intra_mode_info.use_ext_intra_mode[0]) {
@@ -513,8 +521,11 @@
     if (counts)
       ++counts->ext_intra[0][mbmi->ext_intra_mode_info.use_ext_intra_mode[0]];
   }
-  if (mbmi->uv_mode == DC_PRED &&
-      mbmi->palette_mode_info.palette_size[1] == 0) {
+  if (mbmi->uv_mode == DC_PRED
+#if CONFIG_PALETTE
+      && mbmi->palette_mode_info.palette_size[1] == 0
+#endif  // CONFIG_PALETTE
+      ) {
     mbmi->ext_intra_mode_info.use_ext_intra_mode[1] =
         aom_read(r, cm->fc->ext_intra_probs[1]);
     if (mbmi->ext_intra_mode_info.use_ext_intra_mode[1]) {
@@ -607,10 +618,12 @@
 #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_EXT_INTRA
   mbmi->ext_intra_mode_info.use_ext_intra_mode[0] = 0;
   mbmi->ext_intra_mode_info.use_ext_intra_mode[1] = 0;
@@ -895,10 +908,12 @@
 #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_EXT_INTRA
   mbmi->ext_intra_mode_info.use_ext_intra_mode[0] = 0;
   mbmi->ext_intra_mode_info.use_ext_intra_mode[1] = 0;
@@ -1187,8 +1202,10 @@
   int16_t mode_ctx = 0;
   MV_REFERENCE_FRAME ref_frame;
 
+#if CONFIG_PALETTE
   mbmi->palette_mode_info.palette_size[0] = 0;
   mbmi->palette_mode_info.palette_size[1] = 0;
+#endif  // CONFIG_PALETTE
 
   read_ref_frames(cm, xd, r, mbmi->segment_id, mbmi->ref_frame);
   is_compound = has_second_ref(mbmi);
diff --git a/av1/decoder/decoder.h b/av1/decoder/decoder.h
index 3900b44..919e7b8 100644
--- a/av1/decoder/decoder.h
+++ b/av1/decoder/decoder.h
@@ -34,7 +34,9 @@
   DECLARE_ALIGNED(16, MACROBLOCKD, xd);
   /* dqcoeff are shared by all the planes. So planes must be decoded serially */
   DECLARE_ALIGNED(16, tran_low_t, dqcoeff[MAX_TX_SQUARE]);
+#if CONFIG_PALETTE
   DECLARE_ALIGNED(16, uint8_t, color_index_map[2][MAX_SB_SQUARE]);
+#endif  // CONFIG_PALETTE
 } TileData;
 
 typedef struct TileWorkerData {
@@ -44,7 +46,9 @@
   DECLARE_ALIGNED(16, MACROBLOCKD, xd);
   /* dqcoeff are shared by all the planes. So planes must be decoded serially */
   DECLARE_ALIGNED(16, tran_low_t, dqcoeff[MAX_TX_SQUARE]);
+#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;
 
diff --git a/av1/decoder/detokenize.c b/av1/decoder/detokenize.c
index 9a40f69..22d90db 100644
--- a/av1/decoder/detokenize.c
+++ b/av1/decoder/detokenize.c
@@ -332,6 +332,7 @@
   }
 }
 
+#if CONFIG_PALETTE
 void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane,
                                aom_reader *r) {
   MODE_INFO *const mi = xd->mi[0];
@@ -360,6 +361,7 @@
     }
   }
 }
+#endif  // CONFIG_PALETTE
 
 int av1_decode_block_tokens(MACROBLOCKD *const xd, int plane,
                             const scan_order *sc, int x, int y, TX_SIZE tx_size,
diff --git a/av1/decoder/detokenize.h b/av1/decoder/detokenize.h
index 69d6fab..dc96cf5 100644
--- a/av1/decoder/detokenize.h
+++ b/av1/decoder/detokenize.h
@@ -22,7 +22,10 @@
 extern "C" {
 #endif
 
+#if CONFIG_PALETTE
 void av1_decode_palette_tokens(MACROBLOCKD *const xd, int plane, aom_reader *r);
+#endif  // CONFIG_PALETTE
+
 int av1_decode_block_tokens(MACROBLOCKD *const xd, int plane,
                             const scan_order *sc, int x, int y, TX_SIZE tx_size,
                             TX_TYPE tx_type,