Enforce q deltas at different ARF levels

Whilst the 2 pass code VBR allocates different numbers of bits to different
levels in an ARF group, in some cases Q becomes fixed based on the current
active min and max Q, such that frames at different levels have the same Q.

This patch alters the maximum Q allowed at each of up to 4 ARF levels so that
we still have deltas between levels in this scenario.

Note that increasing Q at successive levels is one of the assumptions that
underpins the calculation of the Q factor in the temporal dependency model.

This change is not necessarily optimal but gives some net gains.

(Overall psnr, ssim where -ve is better)

Low res: -0.034, -0.320
ugc360p: -0.090, -0.210
Mid res: -0.159, -0.285
Hd res:   0.110, -0.077

STATS_CHANGED

Change-Id: I53554887185086f5c5ee50e20328b505598877f8
diff --git a/av1/encoder/ratectrl.c b/av1/encoder/ratectrl.c
index 695cba4..b68df10 100644
--- a/av1/encoder/ratectrl.c
+++ b/av1/encoder/ratectrl.c
@@ -1016,7 +1016,7 @@
 
 static const double rate_factor_deltas[RATE_FACTOR_LEVELS] = {
   1.00,  // INTER_NORMAL
-  1.25,  // GF_ARF_LOW
+  1.50,  // GF_ARF_LOW
   2.00,  // GF_ARF_STD
   2.00,  // KF_STD
 };
@@ -1024,8 +1024,14 @@
 int av1_frame_type_qdelta(const AV1_COMP *cpi, int q) {
   const RATE_FACTOR_LEVEL rf_lvl = get_rate_factor_level(&cpi->gf_group);
   const FRAME_TYPE frame_type = (rf_lvl == KF_STD) ? KEY_FRAME : INTER_FRAME;
-  return av1_compute_qdelta_by_rate(&cpi->rc, frame_type, q,
-                                    rate_factor_deltas[rf_lvl],
+  double rate_factor;
+
+  rate_factor = rate_factor_deltas[rf_lvl];
+  if (rf_lvl == GF_ARF_LOW) {
+    rate_factor -= (cpi->gf_group.layer_depth[cpi->gf_group.index] - 2) * 0.2;
+    rate_factor = AOMMAX(rate_factor, 1.0);
+  }
+  return av1_compute_qdelta_by_rate(&cpi->rc, frame_type, q, rate_factor,
                                     cpi->common.seq_params.bit_depth);
 }