Merge "Recover tile coding performance" into nextgenv2
diff --git a/vp10/common/blockd.h b/vp10/common/blockd.h
index 92a0885..fb3f44b 100644
--- a/vp10/common/blockd.h
+++ b/vp10/common/blockd.h
@@ -519,7 +519,11 @@
 int pick_intra_filter(int angle);
 #endif  // CONFIG_EXT_INTRA
 
+#if CONFIG_EXT_TILE
+#define FIXED_TX_TYPE 1
+#else
 #define FIXED_TX_TYPE 0
+#endif
 
 static INLINE TX_TYPE get_default_tx_type(PLANE_TYPE plane_type,
                                           const MACROBLOCKD *xd,
diff --git a/vp10/decoder/decoder.c b/vp10/decoder/decoder.c
index d3fee85..a158ee8 100644
--- a/vp10/decoder/decoder.c
+++ b/vp10/decoder/decoder.c
@@ -399,7 +399,13 @@
 
   swap_frame_buffers(pbi);
 
-  vpx_extend_frame_inner_borders(cm->frame_to_show);
+#if CONFIG_EXT_TILE
+  // For now, we only extend the frame borders when the whole frame is decoded.
+  // Later, if needed, extend the border for the decoded tile on the frame
+  // border.
+  if (pbi->dec_tile_row == -1 && pbi->dec_tile_col == -1)
+#endif  // CONFIG_EXT_TILE
+    vpx_extend_frame_inner_borders(cm->frame_to_show);
 
   vpx_clear_system_state();
 
diff --git a/vp10/encoder/speed_features.c b/vp10/encoder/speed_features.c
index c50b949..25766bb 100644
--- a/vp10/encoder/speed_features.c
+++ b/vp10/encoder/speed_features.c
@@ -494,7 +494,7 @@
   sf->disable_filter_search_var_thresh = 0;
   sf->adaptive_interp_filter_search = 0;
   sf->allow_partition_search_skip = 0;
-#if CONFIG_EXT_REFS
+#if CONFIG_EXT_REFS || CONFIG_EXT_TILE
   sf->use_upsampled_references = 0;
 #else
   sf->use_upsampled_references = 1;
@@ -530,7 +530,11 @@
   sf->simple_model_rd_from_var = 0;
 
   // Set this at the appropriate speed levels
+#if CONFIG_EXT_TILE
+  sf->use_transform_domain_distortion = 1;
+#else
   sf->use_transform_domain_distortion = 0;
+#endif
 
   if (oxcf->mode == REALTIME)
     set_rt_speed_feature(cpi, sf, oxcf->speed, oxcf->content);
diff --git a/vp10/vp10_cx_iface.c b/vp10/vp10_cx_iface.c
index 5f4c003..169c9dd 100644
--- a/vp10/vp10_cx_iface.c
+++ b/vp10/vp10_cx_iface.c
@@ -1158,6 +1158,14 @@
   }
 }
 
+static vpx_codec_err_t ctrl_use_reference(vpx_codec_alg_priv_t *ctx,
+                                          va_list args) {
+  const int reference_flag = va_arg(args, int);
+
+  vp10_use_as_reference(ctx->cpi, reference_flag);
+  return VPX_CODEC_OK;
+}
+
 static vpx_codec_err_t ctrl_set_roi_map(vpx_codec_alg_priv_t *ctx,
                                         va_list args) {
   (void)ctx;
@@ -1254,6 +1262,7 @@
 
 static vpx_codec_ctrl_fn_map_t encoder_ctrl_maps[] = {
   {VP8_COPY_REFERENCE,                ctrl_copy_reference},
+  {VP8E_USE_REFERENCE,                ctrl_use_reference},
 
   // Setters
   {VP8_SET_REFERENCE,                 ctrl_set_reference},
diff --git a/vpx/vp8cx.h b/vpx/vp8cx.h
index 7504c0e..d9764a4 100644
--- a/vpx/vp8cx.h
+++ b/vpx/vp8cx.h
@@ -141,6 +141,12 @@
  * \sa #vpx_codec_control
  */
 enum vp8e_enc_control_id {
+  /*!\brief Codec control function to set which reference frame encoder can use.
+   *
+   * Supported in codecs: VP8, VP9
+   */
+  VP8E_USE_REFERENCE         = 7,
+
   /*!\brief Codec control function to pass an ROI map to encoder.
    *
    * Supported in codecs: VP8, VP9
@@ -703,6 +709,8 @@
  *
  */
 
+VPX_CTRL_USE_TYPE_DEPRECATED(VP8E_USE_REFERENCE, int)
+#define VPX_CTRL_VP8E_USE_REFERENCE
 VPX_CTRL_USE_TYPE(VP8E_SET_FRAME_FLAGS,        int)
 #define VPX_CTRL_VP8E_SET_FRAME_FLAGS
 VPX_CTRL_USE_TYPE(VP8E_SET_TEMPORAL_LAYER_ID,  int)