History

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.

Cheng Chen committed 5 years ago

Commit 665cccf1 parent ba2bfcf5 files · +73 −31Browse files

Unified · Split

5 files
  1. vp8/vp8_cx_iface.c +6 −0
  2. vp9/encoder/vp9_rd.c +10 −31
  3. vp9/vp9_cx_iface.c +12 −0
  4. vpx/vpx_encoder.h +30 −0
  5. vpxenc.c +15 −0
vp8/vp8_cx_iface.c+6−0
@@ -270,6 +270,9 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, · 269 unmodified lines
270270 RANGE_CHECK(cfg, gf_max_total_boost.den, 1, 1000);
271271 RANGE_CHECK(cfg, gf_frame_max_boost.den, 1, 1000);
272272 RANGE_CHECK(cfg, zm_factor.den, 1, 1000);
273+ RANGE_CHECK(cfg, rd_mult_inter_qp_fac.den, 1, 1000);
274+ RANGE_CHECK(cfg, rd_mult_arf_qp_fac.den, 1, 1000);
275+ RANGE_CHECK(cfg, rd_mult_key_qp_fac.den, 1, 1000);
273276
274277 return VPX_CODEC_OK;
275278 }
@@ -1316,6 +1319,9 @@ static vpx_codec_enc_cfg_map_t vp8e_usage_cfg_map[] = { · 1040 unmodified lines
13161319 { 0, 1 }, /* gf_max_total_boost */
13171320 { 0, 1 }, /* gf_frame_max_boost */
13181321 { 0, 1 }, /* zm_factor */
1322+ { 1, 1 }, /* rd_mult_inter_qp_fac */
1323+ { 1, 1 }, /* rd_mult_arf_qp_fac */
1324+ { 1, 1 }, /* rd_mult_key_qp_fac */
13191325 } },
13201326 };
13211327
vp9/encoder/vp9_rd.c+10−31
@@ -202,40 +202,19 @@ static const int rd_frame_type_factor[FRAME_UPDATE_TYPES] = { 128, 144, 128, · 201 unmodified lines
202202 void vp9_init_rd_parameters(VP9_COMP *cpi) {
203203 RD_CONTROL *const rdc = &cpi->rd_ctrl;
204204
205+ // When |use_vizier_rc_params| is 1, we expect the rd parameters have been
206+ // initialized by the pass in values.
207+ // Be careful that parameters below are only initialized to 1, if we do not
208+ // pass values to them. It is desired to take care of each parameter when
209+ // using |use_vizier_rc_params|.
210+ if (cpi->twopass.use_vizier_rc_params) return;
211+
205212 // Make sure this function is floating point safe.
206213 vpx_clear_system_state();
207214
208− rdc->rd_mult_arf_qp_fac = 1.0; // Default: No Vizier values yet
209−
210− // These hard wired estimates for the Vizier values will be removed later
211− // as the per format factors will be set on the command line.
212− if (0) {
213− unsigned int screen_area = (cpi->common.width * cpi->common.height);
214−
215− if (screen_area <= 176 * 144) {
216− rdc->rd_mult_inter_qp_fac = 0.896;
217− rdc->rd_mult_key_qp_fac = 1.050;
218− } else if (screen_area <= 320 * 240) {
219− rdc->rd_mult_inter_qp_fac = 0.998;
220− rdc->rd_mult_key_qp_fac = 0.952;
221− } else if (screen_area <= 640 * 360) {
222− rdc->rd_mult_inter_qp_fac = 0.959;
223− rdc->rd_mult_key_qp_fac = 1.071;
224− } else if (screen_area <= 854 * 480) {
225− rdc->rd_mult_inter_qp_fac = 1.027;
226− rdc->rd_mult_key_qp_fac = 1.280;
227− } else if (screen_area <= 1280 * 720) {
228− rdc->rd_mult_inter_qp_fac = 1.004;
229− rdc->rd_mult_key_qp_fac = 1.193;
230− } else {
231− rdc->rd_mult_inter_qp_fac = 0.874;
232− rdc->rd_mult_key_qp_fac = 0.837;
233− }
234− } else {
235− // For now force defaults unless testing
236− rdc->rd_mult_inter_qp_fac = 1.0;
237− rdc->rd_mult_key_qp_fac = 1.0;
238− }
215+ rdc->rd_mult_inter_qp_fac = 1.0;
216+ rdc->rd_mult_arf_qp_fac = 1.0;
217+ rdc->rd_mult_key_qp_fac = 1.0;
239218 }
240219
241220 // Returns the default rd multiplier for inter frames for a given qindex.
vp9/vp9_cx_iface.c+12−0
@@ -362,6 +362,9 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, · 361 unmodified lines
362362 RANGE_CHECK(cfg, gf_max_total_boost.den, 1, 1000);
363363 RANGE_CHECK(cfg, gf_frame_max_boost.den, 1, 1000);
364364 RANGE_CHECK(cfg, zm_factor.den, 1, 1000);
365+ RANGE_CHECK(cfg, rd_mult_inter_qp_fac.den, 1, 1000);
366+ RANGE_CHECK(cfg, rd_mult_arf_qp_fac.den, 1, 1000);
367+ RANGE_CHECK(cfg, rd_mult_key_qp_fac.den, 1, 1000);
365368
366369 return VPX_CODEC_OK;
367370 }
@@ -686,6 +689,12 @@ static vpx_codec_err_t set_twopass_params_from_config( · 318 unmodified lines
686689 (double)cfg->gf_frame_max_boost.num / (double)cfg->gf_frame_max_boost.den;
687690 cpi->twopass.zm_factor =
688691 (double)cfg->zm_factor.num / (double)cfg->zm_factor.den;
692+ cpi->rd_ctrl.rd_mult_inter_qp_fac = (double)cfg->rd_mult_inter_qp_fac.num /
693+ (double)cfg->rd_mult_inter_qp_fac.den;
694+ cpi->rd_ctrl.rd_mult_arf_qp_fac =
695+ (double)cfg->rd_mult_arf_qp_fac.num / (double)cfg->rd_mult_arf_qp_fac.den;
696+ cpi->rd_ctrl.rd_mult_key_qp_fac =
697+ (double)cfg->rd_mult_key_qp_fac.num / (double)cfg->rd_mult_key_qp_fac.den;
689698
690699 return VPX_CODEC_OK;
691700 }
@@ -1959,6 +1968,9 @@ static vpx_codec_enc_cfg_map_t encoder_usage_cfg_map[] = { · 1267 unmodified lines
19591968 { 0, 1 }, // gf_max_total_boost
19601969 { 0, 1 }, // gf_frame_max_boost
19611970 { 0, 1 }, // zm_factor
1971+ { 1, 1 }, // rd_mult_inter_qp_fac
1972+ { 1, 1 }, // rd_mult_arf_qp_fac
1973+ { 1, 1 }, // rd_mult_key_qp_fac
19621974 } },
19631975 };
19641976
vpx/vpx_encoder.h+30−0
@@ -807,6 +807,36 @@ typedef struct vpx_codec_enc_cfg { · 806 unmodified lines
807807 *
808808 */
809809 vpx_rational_t zm_factor;
810+
811+ /*!\brief Rate-distortion multiplier for inter frames.
812+ * The multiplier is a crucial parameter in the calculation of rate distortion
813+ * cost. It is often related to the qp (qindex) value.
814+ * Rate control parameters, could be set from external experiment results.
815+ * Only when |use_vizier_rc_params| is set to 1, the pass in value will be
816+ * used. Otherwise, the default value is used.
817+ *
818+ */
819+ vpx_rational_t rd_mult_inter_qp_fac;
820+
821+ /*!\brief Rate-distortion multiplier for alt-ref frames.
822+ * The multiplier is a crucial parameter in the calculation of rate distortion
823+ * cost. It is often related to the qp (qindex) value.
824+ * Rate control parameters, could be set from external experiment results.
825+ * Only when |use_vizier_rc_params| is set to 1, the pass in value will be
826+ * used. Otherwise, the default value is used.
827+ *
828+ */
829+ vpx_rational_t rd_mult_arf_qp_fac;
830+
831+ /*!\brief Rate-distortion multiplier for key frames.
832+ * The multiplier is a crucial parameter in the calculation of rate distortion
833+ * cost. It is often related to the qp (qindex) value.
834+ * Rate control parameters, could be set from external experiment results.
835+ * Only when |use_vizier_rc_params| is set to 1, the pass in value will be
836+ * used. Otherwise, the default value is used.
837+ *
838+ */
839+ vpx_rational_t rd_mult_key_qp_fac;
810840 } vpx_codec_enc_cfg_t; /**< alias for struct vpx_codec_enc_cfg */
811841
812842 /*!\brief vp9 svc extra configure parameters
vpxenc.c+15−0
@@ -314,6 +314,12 @@ static const arg_def_t gf_frame_max_boost = · 313 unmodified lines
314314 ARG_DEF(NULL, "gf-frame-max-boost", 1, "Golden frame max boost");
315315 static const arg_def_t zm_factor =
316316 ARG_DEF(NULL, "zm-factor", 1, "Zero motion power factor");
317+static const arg_def_t rd_mult_inter_qp_fac =
318+ ARG_DEF(NULL, "rd-mult-inter-qp-fac", 1, "RD multiplier for inter frames");
319+static const arg_def_t rd_mult_arf_qp_fac =
320+ ARG_DEF(NULL, "rd-mult-arf-qp-fac", 1, "RD multiplier for alt-ref frames");
321+static const arg_def_t rd_mult_key_qp_fac =
322+ ARG_DEF(NULL, "rd-mult-key-qp-fac", 1, "RD multiplier for key frames");
317323 static const arg_def_t *vizier_rc_args[] = { &use_vizier_rc_params,
318324 &active_wq_factor,
319325 &base_err_per_mb,
@@ -327,6 +333,9 @@ static const arg_def_t *vizier_rc_args[] = { &use_vizier_rc_params, · 7 unmodified lines
327333 &gf_max_total_boost,
328334 &gf_frame_max_boost,
329335 &zm_factor,
336+ &rd_mult_inter_qp_fac,
337+ &rd_mult_arf_qp_fac,
338+ &rd_mult_key_qp_fac,
330339 NULL };
331340 #endif
332341
@@ -1055,6 +1064,12 @@ static int parse_stream_params(struct VpxEncoderConfig *global, · 722 unmodified lines
10551064 config->cfg.gf_frame_max_boost = arg_parse_rational(&arg);
10561065 } else if (arg_match(&arg, &zm_factor, argi)) {
10571066 config->cfg.zm_factor = arg_parse_rational(&arg);
1067+ } else if (arg_match(&arg, &rd_mult_inter_qp_fac, argi)) {
1068+ config->cfg.rd_mult_inter_qp_fac = arg_parse_rational(&arg);
1069+ } else if (arg_match(&arg, &rd_mult_arf_qp_fac, argi)) {
1070+ config->cfg.rd_mult_arf_qp_fac = arg_parse_rational(&arg);
1071+ } else if (arg_match(&arg, &rd_mult_key_qp_fac, argi)) {
1072+ config->cfg.rd_mult_key_qp_fac = arg_parse_rational(&arg);
10581073 #endif
10591074 #if CONFIG_VP9_HIGHBITDEPTH
10601075 } else if (arg_match(&arg, &test16bitinternalarg, argi)) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t