EC_ADAPT: add per tile contexts.

This will support adapting in each tile.

(https://bugs.chromium.org/p/aomedia/issues/detail?id=71)

Change-Id: I3eced47715749a48f78c4ccf151c4d0b58f36c0d
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index ea2adf3..2746d7b 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -3836,7 +3836,7 @@
     for (tile_col = 0; tile_col < tile_cols; tile_col++) {
       const int tile_idx = tile_row * tile_cols + tile_col;
       TileBufferEnc *const buf = &tile_buffers[tile_row][tile_col];
-#if CONFIG_PVQ
+#if CONFIG_PVQ || CONFIG_EC_ADAPT
       TileDataEnc *this_tile = &cpi->tile_data[tile_idx];
 #endif
       const TOKENEXTRA *tok = tok_buffers[tile_row][tile_col];
@@ -3917,6 +3917,10 @@
       // NOTE: This will not work with CONFIG_ANS turned on.
       od_adapt_ctx_reset(&cpi->td.mb.daala_enc.state.adapt, 0);
       cpi->td.mb.pvq_q = &this_tile->pvq_q;
+#elif CONFIG_EC_ADAPT
+      // Initialise tile context from the frame context
+      this_tile->tctx = *cm->fc;
+      cpi->td.mb.e_mbd.tile_ctx = &this_tile->tctx;
 #endif
       write_modes(cpi, &tile_info, &mode_bc, &tok, tok_end);
       assert(tok == tok_end);