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
270 RANGE_CHECK(cfg, gf_max_total_boost.den, 1, 1000);270 RANGE_CHECK(cfg, gf_max_total_boost.den, 1, 1000);
271 RANGE_CHECK(cfg, gf_frame_max_boost.den, 1, 1000);271 RANGE_CHECK(cfg, gf_frame_max_boost.den, 1, 1000);
272 RANGE_CHECK(cfg, zm_factor.den, 1, 1000);272 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);
273 276
274 return VPX_CODEC_OK;277 return VPX_CODEC_OK;
275}278}
@@ -1316,6 +1319,9 @@ static vpx_codec_enc_cfg_map_t vp8e_usage_cfg_map[] = { · 1040 unmodified lines
1316 { 0, 1 }, /* gf_max_total_boost */1319 { 0, 1 }, /* gf_max_total_boost */
1317 { 0, 1 }, /* gf_frame_max_boost */1320 { 0, 1 }, /* gf_frame_max_boost */
1318 { 0, 1 }, /* zm_factor */1321 { 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 */
1319 } },1325 } },
1320};1326};
1321 1327
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
202void vp9_init_rd_parameters(VP9_COMP *cpi) {202void vp9_init_rd_parameters(VP9_COMP *cpi) {
203 RD_CONTROL *const rdc = &cpi->rd_ctrl;203 RD_CONTROL *const rdc = &cpi->rd_ctrl;
204 204
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
205 // Make sure this function is floating point safe.212 // Make sure this function is floating point safe.
206 vpx_clear_system_state();213 vpx_clear_system_state();
207 214
208 rdc->rd_mult_arf_qp_fac = 1.0; // Default: No Vizier values yet215 rdc->rd_mult_inter_qp_fac = 1.0;
209 216 rdc->rd_mult_arf_qp_fac = 1.0;
210 // These hard wired estimates for the Vizier values will be removed later217 rdc->rd_mult_key_qp_fac = 1.0;
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 }
239}218}
240 219
241// Returns the default rd multiplier for inter frames for a given qindex.220// 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
362 RANGE_CHECK(cfg, gf_max_total_boost.den, 1, 1000);362 RANGE_CHECK(cfg, gf_max_total_boost.den, 1, 1000);
363 RANGE_CHECK(cfg, gf_frame_max_boost.den, 1, 1000);363 RANGE_CHECK(cfg, gf_frame_max_boost.den, 1, 1000);
364 RANGE_CHECK(cfg, zm_factor.den, 1, 1000);364 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);
365 368
366 return VPX_CODEC_OK;369 return VPX_CODEC_OK;
367}370}
@@ -686,6 +689,12 @@ static vpx_codec_err_t set_twopass_params_from_config( · 318 unmodified lines
686 (double)cfg->gf_frame_max_boost.num / (double)cfg->gf_frame_max_boost.den;689 (double)cfg->gf_frame_max_boost.num / (double)cfg->gf_frame_max_boost.den;
687 cpi->twopass.zm_factor =690 cpi->twopass.zm_factor =
688 (double)cfg->zm_factor.num / (double)cfg->zm_factor.den;691 (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;
689 698
690 return VPX_CODEC_OK;699 return VPX_CODEC_OK;
691}700}
@@ -1959,6 +1968,9 @@ static vpx_codec_enc_cfg_map_t encoder_usage_cfg_map[] = { · 1267 unmodified lines
1959 { 0, 1 }, // gf_max_total_boost1968 { 0, 1 }, // gf_max_total_boost
1960 { 0, 1 }, // gf_frame_max_boost1969 { 0, 1 }, // gf_frame_max_boost
1961 { 0, 1 }, // zm_factor1970 { 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
1962 } },1974 } },
1963};1975};
1964 1976
vpx/vpx_encoder.h+30−0
@@ -807,6 +807,36 @@ typedef struct vpx_codec_enc_cfg { · 806 unmodified lines
807 *807 *
808 */808 */
809 vpx_rational_t zm_factor;809 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;
810} vpx_codec_enc_cfg_t; /**< alias for struct vpx_codec_enc_cfg */840} vpx_codec_enc_cfg_t; /**< alias for struct vpx_codec_enc_cfg */
811 841
812/*!\brief vp9 svc extra configure parameters842/*!\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
314 ARG_DEF(NULL, "gf-frame-max-boost", 1, "Golden frame max boost");314 ARG_DEF(NULL, "gf-frame-max-boost", 1, "Golden frame max boost");
315static const arg_def_t zm_factor =315static const arg_def_t zm_factor =
316 ARG_DEF(NULL, "zm-factor", 1, "Zero motion power factor");316 ARG_DEF(NULL, "zm-factor", 1, "Zero motion power factor");
317static const arg_def_t rd_mult_inter_qp_fac =
318 ARG_DEF(NULL, "rd-mult-inter-qp-fac", 1, "RD multiplier for inter frames");
319static 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");
321static const arg_def_t rd_mult_key_qp_fac =
322 ARG_DEF(NULL, "rd-mult-key-qp-fac", 1, "RD multiplier for key frames");
317static const arg_def_t *vizier_rc_args[] = { &use_vizier_rc_params,323static const arg_def_t *vizier_rc_args[] = { &use_vizier_rc_params,
318 &active_wq_factor,324 &active_wq_factor,
319 &base_err_per_mb,325 &base_err_per_mb,
@@ -327,6 +333,9 @@ static const arg_def_t *vizier_rc_args[] = { &use_vizier_rc_params, · 7 unmodified lines
327 &gf_max_total_boost,333 &gf_max_total_boost,
328 &gf_frame_max_boost,334 &gf_frame_max_boost,
329 &zm_factor,335 &zm_factor,
336 &rd_mult_inter_qp_fac,
337 &rd_mult_arf_qp_fac,
338 &rd_mult_key_qp_fac,
330 NULL };339 NULL };
331#endif340#endif
332 341
@@ -1055,6 +1064,12 @@ static int parse_stream_params(struct VpxEncoderConfig *global, · 722 unmodified lines
1055 config->cfg.gf_frame_max_boost = arg_parse_rational(&arg);1064 config->cfg.gf_frame_max_boost = arg_parse_rational(&arg);
1056 } else if (arg_match(&arg, &zm_factor, argi)) {1065 } else if (arg_match(&arg, &zm_factor, argi)) {
1057 config->cfg.zm_factor = arg_parse_rational(&arg);1066 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);
1058#endif1073#endif
1059#if CONFIG_VP9_HIGHBITDEPTH1074#if CONFIG_VP9_HIGHBITDEPTH
1060 } else if (arg_match(&arg, &test16bitinternalarg, argi)) {1075 } 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