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);
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index a06264d..b7d8e84 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -4891,6 +4891,9 @@
#error "CONFIG_PVQ currently requires CONFIG_DAALA_EC."
#endif
od_adapt_ctx_reset(adapt, 0);
+#elif CONFIG_EC_ADAPT
+ this_tile->tctx = *cm->fc;
+ td->mb.e_mbd.tile_ctx = &this_tile->tctx;
#endif // #if CONFIG_PVQ
for (mi_row = tile_info->mi_row_start; mi_row < tile_info->mi_row_end;
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index dce432b..83ed874 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -280,6 +280,9 @@
#if CONFIG_PVQ
PVQ_QUEUE pvq_q;
#endif
+#if CONFIG_EC_ADAPT
+ FRAME_CONTEXT tctx;
+#endif
} TileDataEnc;
typedef struct RD_COUNTS {