Move vbrmin/max_section/vbrbias to RateControlCfg

vbrmin_section and vbrmax_section parameters are used for both
1-pass and 2-pass, so it is better to move them to RateControlCfg.
vbrbias is also moved since it could potentially be used in 1-pass,
even though it isn't today.

Change-Id: I3f3f56e077a6ad9793baa6db08b7d0e3d2c38596
diff --git a/av1/av1_cx_iface.c b/av1/av1_cx_iface.c
index 95751fc..0d795b2 100644
--- a/av1/av1_cx_iface.c
+++ b/av1/av1_cx_iface.c
@@ -821,6 +821,9 @@
   rc_cfg->target_bandwidth = 1000 * cfg->rc_target_bitrate;
   rc_cfg->drop_frames_water_mark = cfg->rc_dropframe_thresh;
   rc_cfg->vbr_corpus_complexity_lap = extra_cfg->vbr_corpus_complexity_lap;
+  rc_cfg->vbrbias = cfg->rc_2pass_vbr_bias_pct;
+  rc_cfg->vbrmin_section = cfg->rc_2pass_vbr_minsection_pct;
+  rc_cfg->vbrmax_section = cfg->rc_2pass_vbr_maxsection_pct;
 
   // Set Toolset related configuration.
   tool_cfg->bit_depth = cfg->g_bit_depth;
@@ -903,9 +906,6 @@
       resize_cfg->resize_mode ? 0 : extra_cfg->enable_tpl_model;
 
   // Set two-pass configuration.
-  two_pass_cfg->vbrbias = cfg->rc_2pass_vbr_bias_pct;
-  two_pass_cfg->vbrmin_section = cfg->rc_2pass_vbr_minsection_pct;
-  two_pass_cfg->vbrmax_section = cfg->rc_2pass_vbr_maxsection_pct;
   two_pass_cfg->stats_in = cfg->rc_twopass_stats_in;
 
   // Set Key frame configuration.
diff --git a/av1/encoder/encoder.h b/av1/encoder/encoder.h
index ac189a4..5cdd47a 100644
--- a/av1/encoder/encoder.h
+++ b/av1/encoder/encoder.h
@@ -497,6 +497,23 @@
    * constant quality.
    */
   enum aom_rc_mode mode;
+  /*!
+   * Indicates the bias (expressed on a scale of 0 to 100) for determining
+   * target size for the current frame. The value 0 indicates the optimal CBR
+   * mode value should be used, and 100 indicates the optimal VBR mode value
+   * should be used.
+   */
+  int vbrbias;
+  /*!
+   * Indicates the minimum bitrate to be used for a single frame as a percentage
+   * of the target bitrate.
+   */
+  int vbrmin_section;
+  /*!
+   * Indicates the maximum bitrate to be used for a single frame as a percentage
+   * of the target bitrate.
+   */
+  int vbrmax_section;
 } RateControlCfg;
 
 /*!\cond */
@@ -598,24 +615,6 @@
    * pass, concatenated.
    */
   aom_fixed_buf_t stats_in;
-
-  /*!
-   * Indicates the bias (expressed on a scale of 0 to 100) for determining
-   * target size for the current frame. The value 0 indicates the optimal CBR
-   * mode value should be used, and 100 indicates the optimal VBR mode value
-   * should be used.
-   */
-  int vbrbias;
-  /*!
-   * Indicates the minimum bitrate to be used for a single GOP as a percentage
-   *  of the target bitrate.
-   */
-  int vbrmin_section;
-  /*!
-   * Indicates the maximum bitrate to be used for a single GOP as a percentage
-   * of the target bitrate.
-   */
-  int vbrmax_section;
 } TwoPassCfg;
 /*!\cond */
 
diff --git a/av1/encoder/pass2_strategy.c b/av1/encoder/pass2_strategy.c
index acd6982..70c4450 100644
--- a/av1/encoder/pass2_strategy.c
+++ b/av1/encoder/pass2_strategy.c
@@ -73,7 +73,7 @@
   double modified_error =
       av_err * pow(this_frame->coded_error * this_frame->weight /
                        DOUBLE_DIVIDE_CHECK(av_err),
-                   oxcf->two_pass_cfg.vbrbias / 100.0);
+                   oxcf->rc_cfg.vbrbias / 100.0);
 
   // Correction for active area. Frames with a reduced active area
   // (eg due to formatting bars) have a higher error per mb for the
@@ -154,7 +154,7 @@
 static int frame_max_bits(const RATE_CONTROL *rc,
                           const AV1EncoderConfig *oxcf) {
   int64_t max_bits = ((int64_t)rc->avg_frame_bandwidth *
-                      (int64_t)oxcf->two_pass_cfg.vbrmax_section) /
+                      (int64_t)oxcf->rc_cfg.vbrmax_section) /
                      100;
   if (max_bits < 0)
     max_bits = 0;
@@ -2944,9 +2944,9 @@
     const FIRSTPASS_STATS *s = twopass->stats_in;
     double modified_error_total = 0.0;
     twopass->modified_error_min =
-        (avg_error * oxcf->two_pass_cfg.vbrmin_section) / 100;
+        (avg_error * oxcf->rc_cfg.vbrmin_section) / 100;
     twopass->modified_error_max =
-        (avg_error * oxcf->two_pass_cfg.vbrmax_section) / 100;
+        (avg_error * oxcf->rc_cfg.vbrmax_section) / 100;
     while (s < twopass->stats_buf_ctx->stats_in_end) {
       modified_error_total +=
           calculate_modified_err(frame_info, twopass, oxcf, s);
diff --git a/av1/encoder/ratectrl.c b/av1/encoder/ratectrl.c
index 04f51ab..9757a27 100644
--- a/av1/encoder/ratectrl.c
+++ b/av1/encoder/ratectrl.c
@@ -1981,7 +1981,7 @@
   rc->avg_frame_bandwidth =
       (int)(oxcf->rc_cfg.target_bandwidth / cpi->framerate);
   rc->min_frame_bandwidth =
-      (int)(rc->avg_frame_bandwidth * oxcf->two_pass_cfg.vbrmin_section / 100);
+      (int)(rc->avg_frame_bandwidth * oxcf->rc_cfg.vbrmin_section / 100);
 
   rc->min_frame_bandwidth =
       AOMMAX(rc->min_frame_bandwidth, FRAME_OVERHEAD_BITS);
@@ -1993,9 +1993,9 @@
   // a very high rate is given on the command line or the the rate cannnot
   // be acheived because of a user specificed max q (e.g. when the user
   // specifies lossless encode.
-  vbr_max_bits = (int)(((int64_t)rc->avg_frame_bandwidth *
-                        oxcf->two_pass_cfg.vbrmax_section) /
-                       100);
+  vbr_max_bits =
+      (int)(((int64_t)rc->avg_frame_bandwidth * oxcf->rc_cfg.vbrmax_section) /
+            100);
   rc->max_frame_bandwidth =
       AOMMAX(AOMMAX((MBs * MAX_MB_RATE), MAXRATE_1080P), vbr_max_bits);
 
diff --git a/doc/dev_guide/av1_encoder.dox b/doc/dev_guide/av1_encoder.dox
index 2d42480..5619242 100644
--- a/doc/dev_guide/av1_encoder.dox
+++ b/doc/dev_guide/av1_encoder.dox
@@ -137,6 +137,9 @@
     - \ref RateControlCfg.maximum_buffer_size_ms
     - \ref RateControlCfg.starting_buffer_level_ms
     - \ref RateControlCfg.optimal_buffer_level_ms
+    - \ref RateControlCfg.vbrbias
+    - \ref RateControlCfg.vbrmin_section
+    - \ref RateControlCfg.vbrmax_section
 
 - \ref RATE_CONTROL (Rate control status)
     - \ref RATE_CONTROL.intervals_till_gf_calculate_due
@@ -145,10 +148,7 @@
     - \ref RATE_CONTROL.frames_till_gf_update_due
     - \ref RATE_CONTROL.frames_to_key
 
-- \ref TwoPassCfg (Two pass specific rate control configuration)
-    - \ref TwoPassCfg.vbrbias
-    - \ref TwoPassCfg.vbrmin_section
-    - \ref TwoPassCfg.vbrmax_section
+- \ref TwoPassCfg (VBR pass specific rate control configuration)
 
 - \ref TWO_PASS (Two pass status and control data)
 
@@ -471,11 +471,11 @@
 - <b>--undershoot-pct</b> (\ref RateControlCfg.under_shoot_pct)
 - <b>--overshoot-pct</b> (\ref RateControlCfg.over_shoot_pct)
 
-The following control aspects of 2 pass vbr encoding
+The following control aspects of vbr encoding
 
-- <b>--bias-pct</b> (\ref TwoPassCfg.vbrbias)
-- <b>--minsection-pct</b> ((\ref TwoPassCfg.vbrmin_section)
-- <b>--maxsection-pct</b> ((\ref TwoPassCfg.vbrmax_section)
+- <b>--bias-pct</b> (\ref RateControlCfg.vbrbias)
+- <b>--minsection-pct</b> ((\ref RateControlCfg.vbrmin_section)
+- <b>--maxsection-pct</b> ((\ref RateControlCfg.vbrmax_section)
 
 The following relate to buffer and delay management in one pass low delay and
 real time coding