Remove ediv_size_correction.

Removes the frame size correction to the error divisor used when
estimating the active worst quality in 2-pass vbr. In fact in VP9 the
adjustment based on frame size went the other way, but this could
be part of an interaction with other changes in VP9 not yet ported
over.

Change the default ERROR_DIVISOR to 96 such that the change is
neutral for 1080P.

Substantial metric gains for lowres and ugc360p.
Results more mixed for midres.
? Small net gains for hdres (720p) but not all test points completed.

lowres  -0.597	-0.637	-0.866	-0.640
midres  -0.027	-0.031	-0.259	 0.183
ugc360p -0.785	-0.599	-1.435	-0.581
hdres   -0.077	-0.132	 0.009	-0.106

Note that this change alters the active q range calculation.
For small image formats in particular it may often result in a
higher minQ value, especially for early key frames and alt ref
frames. This may lower both the rate and quality somewhat
even if overall bdrate metrics improve. The tweaks to certain
unit test thresholds reflect this and it is likely that these may
need further tweaking in response to other rate control and
bit distribution changes.

STATS_CHANGED

Change-Id: I5053861baf0c9a215865485f1c47884fe64b5727
diff --git a/av1/encoder/pass2_strategy.c b/av1/encoder/pass2_strategy.c
index f401b7d..e45d1e1 100644
--- a/av1/encoder/pass2_strategy.c
+++ b/av1/encoder/pass2_strategy.c
@@ -121,13 +121,6 @@
   section->duration -= frame->duration;
 }
 
-// Calculate the linear size relative to a baseline of 1080P
-#define BASE_SIZE 2073600.0  // 1920x1080
-static double get_linear_size_factor(const AV1_COMP *cpi) {
-  const double this_area = cpi->initial_width * cpi->initial_height;
-  return pow(this_area / BASE_SIZE, 0.5);
-}
-
 // This function returns the maximum target rate per frame.
 static int frame_max_bits(const RATE_CONTROL *rc,
                           const AV1EncoderConfig *oxcf) {
@@ -157,7 +150,7 @@
   return fclamp(pow(error_term, power_term), 0.05, 5.0);
 }
 
-#define ERR_DIVISOR 100.0
+#define ERR_DIVISOR 96.0
 #define FACTOR_PT_LOW 0.70
 #define FACTOR_PT_HIGH 0.90
 
@@ -165,8 +158,8 @@
 // calculation of a correction_factor.
 static int find_qindex_by_rate_with_correction(
     AV1_COMP *cpi, int desired_bits_per_mb, aom_bit_depth_t bit_depth,
-    FRAME_TYPE frame_type, double error_per_mb, double ediv_size_correction,
-    double group_weight_factor, int best_qindex, int worst_qindex) {
+    FRAME_TYPE frame_type, double error_per_mb, double group_weight_factor,
+    int best_qindex, int worst_qindex) {
   assert(best_qindex <= worst_qindex);
   int low = best_qindex;
   int high = worst_qindex;
@@ -185,8 +178,8 @@
   while (low < high) {
     const int mid = (low + high) >> 1;
     const double mid_factor =
-        calc_correction_factor(error_per_mb, ERR_DIVISOR - ediv_size_correction,
-                               FACTOR_PT_LOW, FACTOR_PT_HIGH, mid, bit_depth);
+        calc_correction_factor(error_per_mb, ERR_DIVISOR, FACTOR_PT_LOW,
+                               FACTOR_PT_HIGH, mid, bit_depth);
     const int mid_bits_per_mb = av1_rc_bits_per_mb(
         frame_type, mid, mid_factor * group_weight_factor, bit_depth);
     if (mid_bits_per_mb > desired_bits_per_mb) {
@@ -197,9 +190,8 @@
   }
 #if CONFIG_DEBUG
   assert(low == high);
-  const double low_factor =
-      calc_correction_factor(error_per_mb, ERR_DIVISOR - ediv_size_correction,
-                             FACTOR_PT_LOW, FACTOR_PT_HIGH, low, bit_depth);
+  const double low_factor = calc_correction_factor(
+      error_per_mb, ERR_DIVISOR, FACTOR_PT_LOW, FACTOR_PT_HIGH, low, bit_depth);
   const int low_bits_per_mb = av1_rc_bits_per_mb(
       frame_type, low, low_factor * group_weight_factor, bit_depth);
   assert(low_bits_per_mb <= desired_bits_per_mb || low == worst_qindex);
@@ -228,23 +220,12 @@
         (int)((uint64_t)section_target_bandwidth << BPER_MB_NORMBITS) /
         active_mbs;
 
-    // Larger image formats are expected to be a little harder to code
-    // relatively given the same prediction error score. This in part at
-    // least relates to the increased size and hence coding overheads of
-    // motion vectors. Some account of this is made through adjustment of
-    // the error divisor.
-    double ediv_size_correction =
-        AOMMAX(0.2, AOMMIN(5.0, get_linear_size_factor(cpi)));
-    if (ediv_size_correction < 1.0)
-      ediv_size_correction = -(1.0 / ediv_size_correction);
-    ediv_size_correction *= 4.0;
-
     // Try and pick a max Q that will be high enough to encode the
     // content at the given rate.
     int q = find_qindex_by_rate_with_correction(
         cpi, target_norm_bits_per_mb, cpi->common.seq_params.bit_depth,
-        INTER_FRAME, av_err_per_mb, ediv_size_correction, group_weight_factor,
-        rc->best_quality, rc->worst_quality);
+        INTER_FRAME, av_err_per_mb, group_weight_factor, rc->best_quality,
+        rc->worst_quality);
 
     // Restriction on active max q for constrained quality mode.
     if (cpi->oxcf.rc_mode == AOM_CQ) q = AOMMAX(q, oxcf->cq_level);
diff --git a/test/fwd_kf_test.cc b/test/fwd_kf_test.cc
index 6c428d9..1dc01c1 100644
--- a/test/fwd_kf_test.cc
+++ b/test/fwd_kf_test.cc
@@ -23,8 +23,8 @@
 } FwdKfTestParam;
 
 const FwdKfTestParam kTestParams[] = {
-  { 4, 37.3 },  { 6, 36.5 },  { 8, 35.8 },
-  { 12, 34.3 }, { 16, 34.3 }, { 18, 33.7 }
+  { 4, 37.0 },  { 6, 36.0 },  { 8, 35.0 },
+  { 12, 34.2 }, { 16, 34.0 }, { 18, 33.7 }
 };
 
 // Params: encoding mode and index into the kMaxKfDists array to control
diff --git a/test/gf_max_pyr_height_test.cc b/test/gf_max_pyr_height_test.cc
index 2d78493..28b363b 100644
--- a/test/gf_max_pyr_height_test.cc
+++ b/test/gf_max_pyr_height_test.cc
@@ -21,7 +21,7 @@
   int gf_max_pyr_height;
   double psnr_thresh;
 } kTestParams[] = {
-  { 0, 34.75 }, { 1, 34.75 }, { 2, 35.25 }, { 3, 35.50 }, { 4, 35.50 },
+  { 0, 34.5 }, { 1, 34.75 }, { 2, 35.25 }, { 3, 35.50 }, { 4, 35.50 },
 };
 
 // Compiler may decide to add some padding to the struct above for alignment,