Optimize the size of TokenExtra structure

TokenExtra structure is optimized by declaring
color_ctx and token using bit fields.

BUG=aomedia:2970

Change-Id: I72843d4f7bae6d23cf86f2658dd639075619a5e3
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index ad41af2..ff8cd5f 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -349,7 +349,8 @@
   ++p;
   --num;
   for (int i = 0; i < num; ++i) {
-    assert((p->color_ctx >= 0) && (p->color_ctx < CDF_SIZE(PALETTE_COLORS)));
+    assert((p->color_ctx >= 0) &&
+           (p->color_ctx < PALETTE_COLOR_INDEX_CONTEXTS));
     aom_cdf_prob *color_map_cdf = map_pb_cdf[palette_size_idx][p->color_ctx];
     aom_write_symbol(w, p->token, color_map_cdf, n);
     ++p;
diff --git a/av1/encoder/tokenize.h b/av1/encoder/tokenize.h
index d5e1dfd..ddd5525 100644
--- a/av1/encoder/tokenize.h
+++ b/av1/encoder/tokenize.h
@@ -20,9 +20,18 @@
 extern "C" {
 #endif
 
+// The color_ctx and token members of the TokenExtra structure are used
+// to store index of the color context and color index of each pixel in
+// case of palette mode.
+// 1) color_ctx can take 5 (PALETTE_COLOR_INDEX_CONTEXTS) valid values, i.e.,
+// from 0 to 4. As per the current implementation it can take values in the
+// range of [-1, 4]. Here -1 corresponds to invalid color index context and is
+// used for default initialization. Hence color_ctx requires 4 bits (signed).
+// 2) token can take values in the range of [0, 7] as maximum number of possible
+// colors is 8 (PALETTE_COLORS). Hence token requires 3 bits (unsigned).
 typedef struct {
-  int8_t color_ctx;
-  uint8_t token;
+  int8_t color_ctx : 4;
+  uint8_t token : 3;
 } TokenExtra;
 
 typedef struct {