History

Set vizier rc parameters

If pass --use-vizier-rc-params=1, the rc parameters are overwittern by pass in values. It --use-vizier-rc-params=0, the rc parameters remain the default values.

Cheng Chen committed 5 years ago

Commit 1b07aae1 parent 1c792f26 files · +72 −103Browse files

Unified · Split

6 files
  1. vp8/vp8_cx_iface.c +2 −0
  2. vp9/encoder/vp9_firstpass.c +24 −101
  3. vp9/encoder/vp9_firstpass.h +4 −0
  4. vp9/vp9_cx_iface.c +4 −0
  5. vpx/vpx_encoder.h +30 −0
  6. vpxenc.c +8 −2
vp8/vp8_cx_iface.c+2−0
@@ -258,6 +258,7 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, · 257 unmodified lines
258258 #endif
259259
260260 // The range below shall be further tuned.
261+ RANGE_CHECK(cfg, use_vizier_rc_params, 0, 1);
261262 RANGE_CHECK(cfg, active_wq_factor.den, 1, 1000);
262263 RANGE_CHECK(cfg, base_err_per_mb.den, 1, 1000);
263264 RANGE_CHECK(cfg, sr_default_decay_limit.den, 1, 1000);
@@ -1302,6 +1303,7 @@ static vpx_codec_enc_cfg_map_t vp8e_usage_cfg_map[] = { · 1038 unmodified lines
13021303 { 0 }, /* ts_layer_id */
13031304 { 0 }, /* layer_target_bitrate */
13041305 0, /* temporal_layering_mode */
1306+ 0, /* use_vizier_rc_params */
13051307 { 0, 1 }, /* active_wq_factor */
13061308 { 0, 1 }, /* base_err_per_mb */
13071309 { 0, 1 }, /* sr_default_decay_limit */
vp9/encoder/vp9_firstpass.c+24−101
@@ -3493,109 +3493,32 @@ static int is_skippable_frame(const VP9_COMP *cpi) { · 3492 unmodified lines
34933493 // Configure image size specific vizier parameters.
34943494 // Later these will be set via additional command line options
34953495 static void init_vizier_params(TWO_PASS *const twopass, int screen_area) {
3496− if (1) {
3497− // Force defaults for now
3498− twopass->active_wq_factor = AV_WQ_FACTOR;
3499− twopass->base_err_per_mb = BASELINE_ERR_PER_MB;
3500− twopass->sr_default_decay_limit = DEFAULT_DECAY_LIMIT;
3501− twopass->sr_diff_factor = 1.0;
3502− twopass->gf_frame_max_boost = GF_MAX_FRAME_BOOST;
3503− twopass->gf_max_total_boost = MAX_GF_BOOST;
3504− if (screen_area < 1280 * 720) {
3505− twopass->kf_err_per_mb = 2000.0;
3506− } else if (screen_area < 1920 * 1080) {
3507− twopass->kf_err_per_mb = 500.0;
3508− } else {
3509− twopass->kf_err_per_mb = 250.0;
3510− }
3511− twopass->kf_frame_min_boost = KF_MIN_FRAME_BOOST;
3512− twopass->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST;
3513− twopass->kf_frame_max_boost_subs = twopass->kf_frame_max_boost_first;
3514− twopass->kf_max_total_boost = MAX_KF_TOT_BOOST;
3515− twopass->zm_factor = 1.0;
3496+ // When |use_vizier_rc_params| is 1, we expect the rc parameters have been
3497+ // initialized by the pass in values.
3498+ // Be careful that parameters below are only initialized to 0, if we do not
3499+ // pass values to them. It is desired to take care of each parameter when
3500+ // using |use_vizier_rc_params|.
3501+ if (twopass->use_vizier_rc_params) return;
3502+
3503+ // When |use_vizier_rc_params| is 0, use defaults for now.
3504+ twopass->active_wq_factor = AV_WQ_FACTOR;
3505+ twopass->base_err_per_mb = BASELINE_ERR_PER_MB;
3506+ twopass->sr_default_decay_limit = DEFAULT_DECAY_LIMIT;
3507+ twopass->sr_diff_factor = 1.0;
3508+ twopass->gf_frame_max_boost = GF_MAX_FRAME_BOOST;
3509+ twopass->gf_max_total_boost = MAX_GF_BOOST;
3510+ if (screen_area < 1280 * 720) {
3511+ twopass->kf_err_per_mb = 2000.0;
3512+ } else if (screen_area < 1920 * 1080) {
3513+ twopass->kf_err_per_mb = 500.0;
35163514 } else {
3517− // Vizer experimental parameters from training.
3518− // Later these will be set via the command line.
3519− if (screen_area <= 176 * 144) {
3520− twopass->active_wq_factor = 46.0;
3521− twopass->base_err_per_mb = 37597.399760969536;
3522− twopass->sr_default_decay_limit = 0.3905639800962774;
3523− twopass->sr_diff_factor = 6.4;
3524− twopass->gf_frame_max_boost = 87.27362648627846;
3525− twopass->gf_max_total_boost = MAX_GF_BOOST;
3526− twopass->kf_err_per_mb = 1854.8255436877148;
3527− twopass->kf_frame_min_boost = KF_MIN_FRAME_BOOST;
3528− twopass->kf_frame_max_boost_first = 25.5;
3529− twopass->kf_frame_max_boost_subs = twopass->kf_frame_max_boost_first;
3530− twopass->kf_max_total_boost = MAX_KF_TOT_BOOST;
3531− twopass->zm_factor = 1.0;
3532− } else if (screen_area <= 320 * 240) {
3533− twopass->active_wq_factor = 55.0;
3534− twopass->base_err_per_mb = 34525.33177195309;
3535− twopass->sr_default_decay_limit = 0.23901360046804604;
3536− twopass->sr_diff_factor = 5.73;
3537− twopass->gf_frame_max_boost = 127.34978204980285;
3538− twopass->gf_max_total_boost = MAX_GF_BOOST;
3539− twopass->kf_err_per_mb = 723.8337508755031;
3540− twopass->kf_frame_min_boost = KF_MIN_FRAME_BOOST;
3541− twopass->kf_frame_max_boost_first = 185.0;
3542− twopass->kf_frame_max_boost_subs = twopass->kf_frame_max_boost_first;
3543− twopass->kf_max_total_boost = MAX_KF_TOT_BOOST;
3544− twopass->zm_factor = 1.0;
3545− } else if (screen_area <= 640 * 360) {
3546− twopass->active_wq_factor = 12.5;
3547− twopass->base_err_per_mb = 18823.978018028298;
3548− twopass->sr_default_decay_limit = 0.6043527690301296;
3549− twopass->sr_diff_factor = 2.28;
3550− twopass->gf_frame_max_boost = 75.17672317013668;
3551− twopass->gf_max_total_boost = MAX_GF_BOOST;
3552− twopass->kf_err_per_mb = 422.2871502380377;
3553− twopass->kf_frame_min_boost = KF_MIN_FRAME_BOOST;
3554− twopass->kf_frame_max_boost_first = 224.5;
3555− twopass->kf_frame_max_boost_subs = twopass->kf_frame_max_boost_first;
3556− twopass->kf_max_total_boost = MAX_KF_TOT_BOOST;
3557− twopass->zm_factor = 1.0;
3558− } else if (screen_area <= 854 * 480) {
3559− twopass->active_wq_factor = 51.5;
3560− twopass->base_err_per_mb = 33718.98307662595;
3561− twopass->sr_default_decay_limit = 0.33633414970713393;
3562− twopass->sr_diff_factor = 5.8;
3563− twopass->gf_frame_max_boost = 85.2868528581522;
3564− twopass->gf_max_total_boost = MAX_GF_BOOST;
3565− twopass->kf_err_per_mb = 1513.4883914008383;
3566− twopass->kf_frame_min_boost = KF_MIN_FRAME_BOOST;
3567− twopass->kf_frame_max_boost_first = 28.0;
3568− twopass->kf_frame_max_boost_subs = twopass->kf_frame_max_boost_first;
3569− twopass->kf_max_total_boost = MAX_KF_TOT_BOOST;
3570− twopass->zm_factor = 1.0;
3571− } else if (screen_area <= 1280 * 720) {
3572− twopass->active_wq_factor = 41.5;
3573− twopass->base_err_per_mb = 29527.46375825401;
3574− twopass->sr_default_decay_limit = 0.5009117586299728;
3575− twopass->sr_diff_factor = 3.33;
3576− twopass->gf_frame_max_boost = 81.00472969483079;
3577− twopass->gf_max_total_boost = MAX_GF_BOOST;
3578− twopass->kf_err_per_mb = 998.6342911785146;
3579− twopass->kf_frame_min_boost = KF_MIN_FRAME_BOOST;
3580− twopass->kf_frame_max_boost_first = 53.0;
3581− twopass->kf_frame_max_boost_subs = twopass->kf_frame_max_boost_first;
3582− twopass->kf_max_total_boost = MAX_KF_TOT_BOOST;
3583− twopass->zm_factor = 1.0;
3584− } else {
3585− twopass->active_wq_factor = 31.0;
3586− twopass->base_err_per_mb = 34474.723463367416;
3587− twopass->sr_default_decay_limit = 0.23346886902707745;
3588− twopass->sr_diff_factor = 7.6;
3589− twopass->gf_frame_max_boost = 213.2940230360479;
3590− twopass->gf_max_total_boost = MAX_GF_BOOST;
3591− twopass->kf_err_per_mb = 35931.25734431429;
3592− twopass->kf_frame_min_boost = KF_MIN_FRAME_BOOST;
3593− twopass->kf_frame_max_boost_first = 419.5;
3594− twopass->kf_frame_max_boost_subs = twopass->kf_frame_max_boost_first;
3595− twopass->kf_max_total_boost = MAX_KF_TOT_BOOST;
3596− twopass->zm_factor = 1.0;
3597− }
3515+ twopass->kf_err_per_mb = 250.0;
35983516 }
3517+ twopass->kf_frame_min_boost = KF_MIN_FRAME_BOOST;
3518+ twopass->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST;
3519+ twopass->kf_frame_max_boost_subs = twopass->kf_frame_max_boost_first;
3520+ twopass->kf_max_total_boost = MAX_KF_TOT_BOOST;
3521+ twopass->zm_factor = 1.0;
35993522 }
36003523
36013524 void vp9_rc_get_second_pass_params(VP9_COMP *cpi) {
vp9/encoder/vp9_firstpass.h+4−0
@@ -223,6 +223,10 @@ typedef struct { · 222 unmodified lines
223223 GF_GROUP gf_group;
224224
225225 // Vizeir project experimental two pass rate control parameters.
226+ // When |use_vizier_rc_params| is 1, the following parameters will
227+ // be overwritten by pass in values. Otherwise, they are initialized
228+ // by default values.
229+ int use_vizier_rc_params;
226230 double active_wq_factor;
227231 double base_err_per_mb;
228232 double sr_default_decay_limit;
vp9/vp9_cx_iface.c+4−0
@@ -350,6 +350,7 @@ static vpx_codec_err_t validate_config(vpx_codec_alg_priv_t *ctx, · 349 unmodified lines
350350 RANGE_CHECK(extra_cfg, color_range, VPX_CR_STUDIO_RANGE, VPX_CR_FULL_RANGE);
351351
352352 // The range below shall be further tuned.
353+ RANGE_CHECK(cfg, use_vizier_rc_params, 0, 1);
353354 RANGE_CHECK(cfg, active_wq_factor.den, 1, 1000);
354355 RANGE_CHECK(cfg, base_err_per_mb.den, 1, 1000);
355356 RANGE_CHECK(cfg, sr_default_decay_limit.den, 1, 1000);
@@ -654,8 +655,10 @@ static vpx_codec_err_t set_encoder_config( · 298 unmodified lines
654655
655656 static vpx_codec_err_t set_twopass_params_from_config(
656657 const vpx_codec_enc_cfg_t *const cfg, struct VP9_COMP *cpi) {
658+ if (!cfg->use_vizier_rc_params) return VPX_CODEC_OK;
657659 if (cpi == NULL) return VPX_CODEC_ERROR;
658660
661+ cpi->twopass.use_vizier_rc_params = cfg->use_vizier_rc_params;
659662 cpi->twopass.active_wq_factor =
660663 (double)cfg->active_wq_factor.num / (double)cfg->active_wq_factor.den;
661664 cpi->twopass.base_err_per_mb =
@@ -1943,6 +1946,7 @@ static vpx_codec_enc_cfg_map_t encoder_usage_cfg_map[] = { · 1281 unmodified lines
19431946 { 0 }, // ts_layer_id
19441947 { 0 }, // layer_taget_bitrate
19451948 0, // temporal_layering_mode
1949+ 0, // use_vizier_rc_params
19461950 { 0, 1 }, // active_wq_factor
19471951 { 0, 1 }, // base_err_per_mb
19481952 { 0, 1 }, // sr_default_decay_limit
vpx/vpx_encoder.h+30−0
@@ -694,9 +694,17 @@ typedef struct vpx_codec_enc_cfg { · 693 unmodified lines
694694 */
695695 int temporal_layering_mode;
696696
697+ /*!\brief A flag indicating whether to use external rate control parameters.
698+ * By default is 0. If set to 1, the following parameters will be used in the
699+ * rate control system.
700+ */
701+ int use_vizier_rc_params;
702+
697703 /*!\brief Active worst quality factor.
698704 *
699705 * Rate control parameters, set from external experiment results.
706+ * Only when |use_vizier_rc_params| is set to 1, the pass in value will be
707+ * used. Otherwise, the default value is used.
700708 *
701709 */
702710 vpx_rational_t active_wq_factor;
@@ -704,6 +712,8 @@ typedef struct vpx_codec_enc_cfg { · 1 unmodified line
704712 /*!\brief Base error per macroblock.
705713 *
706714 * Rate control parameters, set from external experiment results.
715+ * Only when |use_vizier_rc_params| is set to 1, the pass in value will be
716+ * used. Otherwise, the default value is used.
707717 *
708718 */
709719 vpx_rational_t base_err_per_mb;
@@ -711,6 +721,8 @@ typedef struct vpx_codec_enc_cfg { · 1 unmodified line
711721 /*!\brief Second reference default decay limit.
712722 *
713723 * Rate control parameters, set from external experiment results.
724+ * Only when |use_vizier_rc_params| is set to 1, the pass in value will be
725+ * used. Otherwise, the default value is used.
714726 *
715727 */
716728 vpx_rational_t sr_default_decay_limit;
@@ -718,6 +730,8 @@ typedef struct vpx_codec_enc_cfg { · 1 unmodified line
718730 /*!\brief Second reference difference factor.
719731 *
720732 * Rate control parameters, set from external experiment results.
733+ * Only when |use_vizier_rc_params| is set to 1, the pass in value will be
734+ * used. Otherwise, the default value is used.
721735 *
722736 */
723737 vpx_rational_t sr_diff_factor;
@@ -725,6 +739,8 @@ typedef struct vpx_codec_enc_cfg { · 1 unmodified line
725739 /*!\brief Keyframe error per macroblock.
726740 *
727741 * Rate control parameters, set from external experiment results.
742+ * Only when |use_vizier_rc_params| is set to 1, the pass in value will be
743+ * used. Otherwise, the default value is used.
728744 *
729745 */
730746 vpx_rational_t kf_err_per_mb;
@@ -732,6 +748,8 @@ typedef struct vpx_codec_enc_cfg { · 1 unmodified line
732748 /*!\brief Keyframe minimum boost.
733749 *
734750 * Rate control parameters, set from external experiment results.
751+ * Only when |use_vizier_rc_params| is set to 1, the pass in value will be
752+ * used. Otherwise, the default value is used.
735753 *
736754 */
737755 vpx_rational_t kf_frame_min_boost;
@@ -739,6 +757,8 @@ typedef struct vpx_codec_enc_cfg { · 1 unmodified line
739757 /*!\brief Keyframe maximum boost, for the first keyframe in a chunk.
740758 *
741759 * Rate control parameters, set from external experiment results.
760+ * Only when |use_vizier_rc_params| is set to 1, the pass in value will be
761+ * used. Otherwise, the default value is used.
742762 *
743763 */
744764 vpx_rational_t kf_frame_max_boost_first;
@@ -746,6 +766,8 @@ typedef struct vpx_codec_enc_cfg { · 1 unmodified line
746766 /*!\brief Keyframe maximum boost, for subsequent keyframes.
747767 *
748768 * Rate control parameters, set from external experiment results.
769+ * Only when |use_vizier_rc_params| is set to 1, the pass in value will be
770+ * used. Otherwise, the default value is used.
749771 *
750772 */
751773 vpx_rational_t kf_frame_max_boost_subs;
@@ -753,6 +775,8 @@ typedef struct vpx_codec_enc_cfg { · 1 unmodified line
753775 /*!\brief Keyframe maximum total boost.
754776 *
755777 * Rate control parameters, set from external experiment results.
778+ * Only when |use_vizier_rc_params| is set to 1, the pass in value will be
779+ * used. Otherwise, the default value is used.
756780 *
757781 */
758782 vpx_rational_t kf_max_total_boost;
@@ -760,6 +784,8 @@ typedef struct vpx_codec_enc_cfg { · 1 unmodified line
760784 /*!\brief Golden frame maximum total boost.
761785 *
762786 * Rate control parameters, set from external experiment results.
787+ * Only when |use_vizier_rc_params| is set to 1, the pass in value will be
788+ * used. Otherwise, the default value is used.
763789 *
764790 */
765791 vpx_rational_t gf_max_total_boost;
@@ -767,6 +793,8 @@ typedef struct vpx_codec_enc_cfg { · 1 unmodified line
767793 /*!\brief Golden frame maximum boost.
768794 *
769795 * Rate control parameters, set from external experiment results.
796+ * Only when |use_vizier_rc_params| is set to 1, the pass in value will be
797+ * used. Otherwise, the default value is used.
770798 *
771799 */
772800 vpx_rational_t gf_frame_max_boost;
@@ -774,6 +802,8 @@ typedef struct vpx_codec_enc_cfg { · 1 unmodified line
774802 /*!\brief Zero motion power factor.
775803 *
776804 * Rate control parameters, set from external experiment results.
805+ * Only when |use_vizier_rc_params| is set to 1, the pass in value will be
806+ * used. Otherwise, the default value is used.
777807 *
778808 */
779809 vpx_rational_t zm_factor;
vpxenc.c+8−2
@@ -288,6 +288,8 @@ static const arg_def_t *rc_args[] = { · 287 unmodified lines
288288 };
289289
290290 #if CONFIG_VP9_ENCODER
291+static const arg_def_t use_vizier_rc_params =
292+ ARG_DEF(NULL, "use-vizier-rc-params", 1, "Use vizier rc params");
291293 static const arg_def_t active_wq_factor =
292294 ARG_DEF(NULL, "active-wq-factor", 1, "Active worst quality factor");
293295 static const arg_def_t base_err_per_mb =
@@ -311,8 +313,9 @@ static const arg_def_t gf_max_total_boost = · 17 unmodified lines
311313 static const arg_def_t gf_frame_max_boost =
312314 ARG_DEF(NULL, "gf-frame-max-boost", 1, "Golden frame max boost");
313315 static const arg_def_t zm_factor =
314− ARG_DEF(NULL, "zm-power-factor", 1, "Zero motion power factor");
315−static const arg_def_t *vizier_rc_args[] = { &active_wq_factor,
316+ ARG_DEF(NULL, "zm-factor", 1, "Zero motion power factor");
317+static const arg_def_t *vizier_rc_args[] = { &use_vizier_rc_params,
318+ &active_wq_factor,
316319 &base_err_per_mb,
317320 &sr_default_decay_limit,
318321 &sr_diff_factor,
@@ -1026,6 +1029,8 @@ static int parse_stream_params(struct VpxEncoderConfig *global, · 707 unmodified lines
10261029 } else if (arg_match(&arg, &kf_disabled, argi)) {
10271030 config->cfg.kf_mode = VPX_KF_DISABLED;
10281031 #if CONFIG_VP9_ENCODER
1032+ } else if (arg_match(&arg, &use_vizier_rc_params, argi)) {
1033+ config->cfg.use_vizier_rc_params = arg_parse_int(&arg);
10291034 } else if (arg_match(&arg, &active_wq_factor, argi)) {
10301035 config->cfg.active_wq_factor = arg_parse_rational(&arg);
10311036 } else if (arg_match(&arg, &base_err_per_mb, argi)) {
@@ -1246,6 +1251,7 @@ static void show_stream_config(struct stream_state *stream, · 214 unmodified lines
12461251 SHOW(kf_min_dist);
12471252 SHOW(kf_max_dist);
12481253 // Temporary use for debug
1254+ SHOW(use_vizier_rc_params);
12491255 SHOW(active_wq_factor.num);
12501256 SHOW(active_wq_factor.den);
12511257 }

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