Stop backward adaptation if EXT_TILE + cm->large_scale_tile

Backwards adaptation doesn't really make sense in this context,
because ext-tile means the decoder might not decode every tile in the
frame, in which case it can't work out how to adapt probabilities.

It turns out that the tests in the tree were passing when
SIMPLE_BWD_ADAPT was disabled because (presumably) all of them
happened to decode every tile, so backward adaptation worked as you'd
expect. With SIMPLE_BWD_ADAPT, there's some code in get_tile_buffers
to figure out which is the largest tile. This wasn't mirrored in
get_ls_tile_buffers, which caused the encoder and decoder to get out
of sync because they ended up with different CDFs. You also can't
easily fix things in get_ls_tile_buffers because that code is careful
not to calculate the size of tiles it doesn't need.

BUG=aomedia:917

Change-Id: Ia926692f86ca1466252108e09da3de590d45f048
diff --git a/av1/decoder/decodeframe.c b/av1/decoder/decodeframe.c
index cd37088..7071e8c 100644
--- a/av1/decoder/decodeframe.c
+++ b/av1/decoder/decodeframe.c
@@ -3299,7 +3299,13 @@
                        " state");
   }
 
-  if (!cm->error_resilient_mode) {
+#if CONFIG_EXT_TILE
+  const int might_bwd_adapt =
+      !(cm->error_resilient_mode || cm->large_scale_tile);
+#else
+  const int might_bwd_adapt = !cm->error_resilient_mode;
+#endif  // CONFIG_EXT_TILE
+  if (might_bwd_adapt) {
     cm->refresh_frame_context = aom_rb_read_bit(rb)
                                     ? REFRESH_FRAME_CONTEXT_FORWARD
                                     : REFRESH_FRAME_CONTEXT_BACKWARD;
diff --git a/av1/encoder/bitstream.c b/av1/encoder/bitstream.c
index 884d27b..29458b2 100644
--- a/av1/encoder/bitstream.c
+++ b/av1/encoder/bitstream.c
@@ -4155,7 +4155,13 @@
   }
 #endif  // CONFIG_REFERENCE_BUFFER
 
-  if (!cm->error_resilient_mode) {
+#if CONFIG_EXT_TILE
+  const int might_bwd_adapt =
+      !(cm->error_resilient_mode || cm->large_scale_tile);
+#else
+  const int might_bwd_adapt = !cm->error_resilient_mode;
+#endif  // CONFIG_EXT_TILE
+  if (might_bwd_adapt) {
     aom_wb_write_bit(
         wb, cm->refresh_frame_context == REFRESH_FRAME_CONTEXT_FORWARD);
   }
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 19d8686..691d479 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -2480,6 +2480,11 @@
       (oxcf->error_resilient_mode || oxcf->frame_parallel_decoding_mode)
           ? REFRESH_FRAME_CONTEXT_FORWARD
           : REFRESH_FRAME_CONTEXT_BACKWARD;
+#if CONFIG_EXT_TILE
+  if (oxcf->large_scale_tile)
+    cm->refresh_frame_context = REFRESH_FRAME_CONTEXT_FORWARD;
+#endif  // CONFIG_EXT_TILE
+
 #if !CONFIG_NO_FRAME_CONTEXT_SIGNALING
   cm->reset_frame_context = RESET_FRAME_CONTEXT_NONE;
 #endif
@@ -5406,7 +5411,11 @@
       // Only reset the current context.
       cm->reset_frame_context = RESET_FRAME_CONTEXT_CURRENT;
     }
-#endif
+#if CONFIG_EXT_TILE
+    if (cpi->oxcf.large_scale_tile)
+      cm->refresh_frame_context = REFRESH_FRAME_CONTEXT_FORWARD;
+#endif  // CONFIG_EXT_TILE
+#endif  // !CONFIG_NO_FRAME_CONTEXT_SIGNALING
   }
   if (cpi->oxcf.mtu == 0) {
     cm->num_tg = cpi->oxcf.num_tile_groups;
@@ -6206,6 +6215,10 @@
       (oxcf->error_resilient_mode || oxcf->frame_parallel_decoding_mode)
           ? REFRESH_FRAME_CONTEXT_FORWARD
           : REFRESH_FRAME_CONTEXT_BACKWARD;
+#if CONFIG_EXT_TILE
+  if (oxcf->large_scale_tile)
+    cm->refresh_frame_context = REFRESH_FRAME_CONTEXT_FORWARD;
+#endif  // CONFIG_EXT_TILE
 
   cpi->refresh_last_frame = 1;
   cpi->refresh_golden_frame = 0;