Further improve compression for very static videos

For unforced (including the 1st) keyframe, we make two changes:

(1) For active_best_quality, divide original by 3, instead of 4. This
works better when tested over larger set of very static videos.

(2) Earlier, recode loop either:
  (a) ended up using q = active_best_quality after several loops, OR
  (b) selected a worse q than active_best_quality and ended up on the
  borderline of undershooting.

So, we just start with q = active_best_quality directly, making encodes
of the unforced keyframe much faster and also the best quality, whenever
there is enough bandwidth. (I observed that, in practice, best quality
always seems to be selected for such very static videos).

This seems to give a much better trade-off between PSNR and bitrate.

STATS_CHANGED for very static videos.
Exactly neutral for non-static videos.

BUG=b/119104564

Change-Id: Idb39a510a9119227e3edc69ea99bf27ab1a669ec
diff --git a/av1/encoder/ratectrl.c b/av1/encoder/ratectrl.c
index c31baa9..56203cd 100644
--- a/av1/encoder/ratectrl.c
+++ b/av1/encoder/ratectrl.c
@@ -997,7 +997,7 @@
           get_kf_active_quality(rc, active_worst_quality, bit_depth);
 
       if (cpi->twopass.kf_zeromotion_pct >= STATIC_KF_GROUP_THRESH) {
-        active_best_quality /= 4;
+        active_best_quality /= 3;
       }
 
       // Allow somewhat lower kf minq with small image formats.
@@ -1163,7 +1163,9 @@
   active_worst_quality =
       clamp(active_worst_quality, active_best_quality, rc->worst_quality);
 
-  if (oxcf->rc_mode == AOM_Q) {
+  if (oxcf->rc_mode == AOM_Q ||
+      (frame_is_intra_only(cm) && !rc->this_key_frame_forced &&
+       cpi->twopass.kf_zeromotion_pct >= STATIC_KF_GROUP_THRESH)) {
     q = active_best_quality;
     // Special case code to try and match quality with forced key frames.
   } else if (frame_is_intra_only(cm) && rc->this_key_frame_forced) {