ref: 665cccfd6ccbc1be2db7d550b68388679b573410
parent: ba2bfcf2ebb41d8c50c6c567a27cc193d8a19d3f
author: Cheng Chen <chengchen@google.com>
date: Wed Apr 14 18:15:54 EDT 2021
Pass vizier rd parameter values Add command line options for three rd parameters. They are controlled by --use_vizier_rc_params, together with other rc parameters. If not set from command line, current default values will be used. Change-Id: Ie1b9a98a50326551cc1d5940c4b637cb01a61aa0
--- a/vp8/vp8_cx_iface.c
+++ b/vp8/vp8_cx_iface.c
@@ -270,6 +270,9 @@
RANGE_CHECK(cfg, gf_max_total_boost.den, 1, 1000);
RANGE_CHECK(cfg, gf_frame_max_boost.den, 1, 1000);
RANGE_CHECK(cfg, zm_factor.den, 1, 1000);
+ RANGE_CHECK(cfg, rd_mult_inter_qp_fac.den, 1, 1000);
+ RANGE_CHECK(cfg, rd_mult_arf_qp_fac.den, 1, 1000);
+ RANGE_CHECK(cfg, rd_mult_key_qp_fac.den, 1, 1000);
return VPX_CODEC_OK;
}
@@ -1316,6 +1319,9 @@
{ 0, 1 }, /* gf_max_total_boost */
{ 0, 1 }, /* gf_frame_max_boost */
{ 0, 1 }, /* zm_factor */
+ { 1, 1 }, /* rd_mult_inter_qp_fac */
+ { 1, 1 }, /* rd_mult_arf_qp_fac */
+ { 1, 1 }, /* rd_mult_key_qp_fac */
} },
};
--- a/vp9/encoder/vp9_rd.c
+++ b/vp9/encoder/vp9_rd.c
@@ -202,40 +202,19 @@
void vp9_init_rd_parameters(VP9_COMP *cpi) {
RD_CONTROL *const rdc = &cpi->rd_ctrl;
+ // When |use_vizier_rc_params| is 1, we expect the rd parameters have been
+ // initialized by the pass in values.
+ // Be careful that parameters below are only initialized to 1, if we do not
+ // pass values to them. It is desired to take care of each parameter when
+ // using |use_vizier_rc_params|.
+ if (cpi->twopass.use_vizier_rc_params) return;
+
// Make sure this function is floating point safe.
vpx_clear_system_state();
- rdc->rd_mult_arf_qp_fac = 1.0; // Default: No Vizier values yet
-
- // These hard wired estimates for the Vizier values will be removed later
- // as the per format factors will be set on the command line.
- if (0) {
- unsigned int screen_area = (cpi->common.width * cpi->common.height);
-
- if (screen_area <= 176 * 144) {
- rdc->rd_mult_inter_qp_fac = 0.896;
- rdc->rd_mult_key_qp_fac = 1.050;
- } else if (screen_area <= 320 * 240) {
- rdc->rd_mult_inter_qp_fac = 0.998;
- rdc->rd_mult_key_qp_fac = 0.952;
- } else if (screen_area <= 640 * 360) {
- rdc->rd_mult_inter_qp_fac = 0.959;
- rdc->rd_mult_key_qp_fac = 1.071;
- } else if (screen_area <= 854 * 480) {
- rdc->rd_mult_inter_qp_fac = 1.027;
- rdc->rd_mult_key_qp_fac = 1.280;
- } else if (screen_area <= 1280 * 720) {
- rdc->rd_mult_inter_qp_fac = 1.004;
- rdc->rd_mult_key_qp_fac = 1.193;
- } else {
- rdc->rd_mult_inter_qp_fac = 0.874;
- rdc->rd_mult_key_qp_fac = 0.837;
- }
- } else {
- // For now force defaults unless testing
- rdc->rd_mult_inter_qp_fac = 1.0;
- rdc->rd_mult_key_qp_fac = 1.0;
- }
+ rdc->rd_mult_inter_qp_fac = 1.0;
+ rdc->rd_mult_arf_qp_fac = 1.0;
+ rdc->rd_mult_key_qp_fac = 1.0;
}
// Returns the default rd multiplier for inter frames for a given qindex.
--- a/vp9/vp9_cx_iface.c
+++ b/vp9/vp9_cx_iface.c
@@ -362,6 +362,9 @@
RANGE_CHECK(cfg, gf_max_total_boost.den, 1, 1000);
RANGE_CHECK(cfg, gf_frame_max_boost.den, 1, 1000);
RANGE_CHECK(cfg, zm_factor.den, 1, 1000);
+ RANGE_CHECK(cfg, rd_mult_inter_qp_fac.den, 1, 1000);
+ RANGE_CHECK(cfg, rd_mult_arf_qp_fac.den, 1, 1000);
+ RANGE_CHECK(cfg, rd_mult_key_qp_fac.den, 1, 1000);
return VPX_CODEC_OK;
}
@@ -686,6 +689,12 @@
(double)cfg->gf_frame_max_boost.num / (double)cfg->gf_frame_max_boost.den;
cpi->twopass.zm_factor =
(double)cfg->zm_factor.num / (double)cfg->zm_factor.den;
+ cpi->rd_ctrl.rd_mult_inter_qp_fac = (double)cfg->rd_mult_inter_qp_fac.num /
+ (double)cfg->rd_mult_inter_qp_fac.den;
+ cpi->rd_ctrl.rd_mult_arf_qp_fac =
+ (double)cfg->rd_mult_arf_qp_fac.num / (double)cfg->rd_mult_arf_qp_fac.den;
+ cpi->rd_ctrl.rd_mult_key_qp_fac =
+ (double)cfg->rd_mult_key_qp_fac.num / (double)cfg->rd_mult_key_qp_fac.den;
return VPX_CODEC_OK;
}
@@ -1959,6 +1968,9 @@
{ 0, 1 }, // gf_max_total_boost
{ 0, 1 }, // gf_frame_max_boost
{ 0, 1 }, // zm_factor
+ { 1, 1 }, // rd_mult_inter_qp_fac
+ { 1, 1 }, // rd_mult_arf_qp_fac
+ { 1, 1 }, // rd_mult_key_qp_fac
} },
};
--- a/vpx/vpx_encoder.h
+++ b/vpx/vpx_encoder.h
@@ -807,6 +807,36 @@
*
*/
vpx_rational_t zm_factor;
+
+ /*!\brief Rate-distortion multiplier for inter frames.
+ * The multiplier is a crucial parameter in the calculation of rate distortion
+ * cost. It is often related to the qp (qindex) value.
+ * Rate control parameters, could be set from external experiment results.
+ * Only when |use_vizier_rc_params| is set to 1, the pass in value will be
+ * used. Otherwise, the default value is used.
+ *
+ */
+ vpx_rational_t rd_mult_inter_qp_fac;
+
+ /*!\brief Rate-distortion multiplier for alt-ref frames.
+ * The multiplier is a crucial parameter in the calculation of rate distortion
+ * cost. It is often related to the qp (qindex) value.
+ * Rate control parameters, could be set from external experiment results.
+ * Only when |use_vizier_rc_params| is set to 1, the pass in value will be
+ * used. Otherwise, the default value is used.
+ *
+ */
+ vpx_rational_t rd_mult_arf_qp_fac;
+
+ /*!\brief Rate-distortion multiplier for key frames.
+ * The multiplier is a crucial parameter in the calculation of rate distortion
+ * cost. It is often related to the qp (qindex) value.
+ * Rate control parameters, could be set from external experiment results.
+ * Only when |use_vizier_rc_params| is set to 1, the pass in value will be
+ * used. Otherwise, the default value is used.
+ *
+ */
+ vpx_rational_t rd_mult_key_qp_fac;
} vpx_codec_enc_cfg_t; /**< alias for struct vpx_codec_enc_cfg */
/*!\brief vp9 svc extra configure parameters
--- a/vpxenc.c
+++ b/vpxenc.c
@@ -314,6 +314,12 @@
ARG_DEF(NULL, "gf-frame-max-boost", 1, "Golden frame max boost");
static const arg_def_t zm_factor =
ARG_DEF(NULL, "zm-factor", 1, "Zero motion power factor");
+static const arg_def_t rd_mult_inter_qp_fac =
+ ARG_DEF(NULL, "rd-mult-inter-qp-fac", 1, "RD multiplier for inter frames");
+static const arg_def_t rd_mult_arf_qp_fac =
+ ARG_DEF(NULL, "rd-mult-arf-qp-fac", 1, "RD multiplier for alt-ref frames");
+static const arg_def_t rd_mult_key_qp_fac =
+ ARG_DEF(NULL, "rd-mult-key-qp-fac", 1, "RD multiplier for key frames");
static const arg_def_t *vizier_rc_args[] = { &use_vizier_rc_params,
&active_wq_factor,
&base_err_per_mb,
@@ -327,6 +333,9 @@
&gf_max_total_boost,
&gf_frame_max_boost,
&zm_factor,
+ &rd_mult_inter_qp_fac,
+ &rd_mult_arf_qp_fac,
+ &rd_mult_key_qp_fac,
NULL };
#endif
@@ -1055,6 +1064,12 @@
config->cfg.gf_frame_max_boost = arg_parse_rational(&arg);
} else if (arg_match(&arg, &zm_factor, argi)) {
config->cfg.zm_factor = arg_parse_rational(&arg);
+ } else if (arg_match(&arg, &rd_mult_inter_qp_fac, argi)) {
+ config->cfg.rd_mult_inter_qp_fac = arg_parse_rational(&arg);
+ } else if (arg_match(&arg, &rd_mult_arf_qp_fac, argi)) {
+ config->cfg.rd_mult_arf_qp_fac = arg_parse_rational(&arg);
+ } else if (arg_match(&arg, &rd_mult_key_qp_fac, argi)) {
+ config->cfg.rd_mult_key_qp_fac = arg_parse_rational(&arg);
#endif
#if CONFIG_VP9_HIGHBITDEPTH
} else if (arg_match(&arg, &test16bitinternalarg, argi)) {