TPL based qp decisions

Enable the TPL based qp decisions in Q mode. Calculate the quantizer
step size scaling based on the temporal dependency. The coding
performance is improved

         overall PSNR     SSIM
lowres      -0.70%       -0.09%
midres2     -1.26%       -0.75%
ugc480p     -2.48%       -1.29%
hdres2      -1.47%       -1.17%

STATS_CHANGED

Change-Id: Id925ec661c0a00047ad45aad34458620c8a1490c
diff --git a/av1/encoder/encoder_utils.c b/av1/encoder/encoder_utils.c
index 557268f..70edf58 100644
--- a/av1/encoder/encoder_utils.c
+++ b/av1/encoder/encoder_utils.c
@@ -542,6 +542,19 @@
   *q = av1_rc_pick_q_and_bounds(cpi, cm->width, cm->height, cpi->gf_frame_index,
                                 bottom_index, top_index);
 
+#if !CONFIG_REALTIME_ONLY
+  if (cpi->oxcf.rc_cfg.mode == AOM_Q &&
+      cpi->ppi->tpl_data.tpl_frame[cpi->gf_frame_index].is_valid &&
+      is_frame_tpl_eligible(gf_group, cpi->gf_frame_index) &&
+      !frame_is_intra_only(cm)) {
+    *q = av1_get_arf_q_index_q_mode(
+        cpi, &cpi->ppi->tpl_data.tpl_frame[cpi->gf_frame_index]);
+    *top_index = *bottom_index = *q;
+    if (gf_group->update_type[cpi->gf_frame_index] == ARF_UPDATE)
+      cpi->ppi->p_rc.arf_q = *q;
+  }
+#endif
+
   // Configure experimental use of segmentation for enhanced coding of
   // static regions if indicated.
   // Only allowed in the second pass of a two pass encode, as it requires