History

Merge "Further integration for Vizier."

Paul Wilkins committed 5 years ago

Commit fb98bdb2 parents 56b1a19 f27c62c3 files · +191 −179Browse files

Unified · Split

3 files
  1. vp9/encoder/vp9_firstpass.c +176 −164
  2. vp9/encoder/vp9_firstpass.h +15 −2
  3. vp9/encoder/vp9_ratectrl.h +0 −13
vp9/encoder/vp9_firstpass.c+176−164
@@ -77,7 +77,6 @@ · 76 unmodified lines
7777 #define MINQ_ADJ_LIMIT_CQ 20
7878 #define HIGH_UNDERSHOOT_RATIO 2
7979 #define AV_WQ_FACTOR 4.0
80−#define DEF_EPMB_LOW 2000.0
8180
8281 #define DOUBLE_DIVIDE_CHECK(x) ((x) < 0 ? (x)-0.000001 : (x) + 0.000001)
8382
@@ -1833,6 +1832,7 @@ void vp9_init_second_pass(VP9_COMP *cpi) { · 1749 unmodified lines
18331832 }
18341833
18351834 static double get_sr_decay_rate(const FRAME_INFO *frame_info,
1835+ const TWO_PASS *const twopass,
18361836 const FIRSTPASS_STATS *frame) {
18371837 double sr_diff = (frame->sr_coded_error - frame->coded_error);
18381838 double sr_decay = 1.0;
@@ -1854,28 +1854,31 @@ static double get_sr_decay_rate(const FRAME_INFO *frame_info, · 15 unmodified lines
18541854
18551855 if ((sr_diff > LOW_SR_DIFF_TRHESH)) {
18561856 sr_diff = VPXMIN(sr_diff, SR_DIFF_MAX);
1857− sr_decay = 1.0 - (SR_DIFF_PART * sr_diff) - motion_amplitude_part -
1857+ sr_decay = 1.0 - (twopass->sr_diff_part * sr_diff) - motion_amplitude_part -
18581858 (INTRA_PART * modified_pcnt_intra);
18591859 }
1860− return VPXMAX(sr_decay, DEFAULT_DECAY_LIMIT);
1860+ return VPXMAX(sr_decay, twopass->sr_default_decay_limit);
18611861 }
18621862
18631863 // This function gives an estimate of how badly we believe the prediction
18641864 // quality is decaying from frame to frame.
18651865 static double get_zero_motion_factor(const FRAME_INFO *frame_info,
1866+ const TWO_PASS *const twopass,
18661867 const FIRSTPASS_STATS *frame_stats) {
18671868 const double zero_motion_pct =
18681869 frame_stats->pcnt_inter - frame_stats->pcnt_motion;
1869− double sr_decay = get_sr_decay_rate(frame_info, frame_stats);
1870+ double sr_decay = get_sr_decay_rate(frame_info, twopass, frame_stats);
18701871 return VPXMIN(sr_decay, zero_motion_pct);
18711872 }
18721873
18731874 static double get_prediction_decay_rate(const FRAME_INFO *frame_info,
1875+ const TWO_PASS *const twopass,
18741876 const FIRSTPASS_STATS *frame_stats) {
1875− const double sr_decay_rate = get_sr_decay_rate(frame_info, frame_stats);
1877+ const double sr_decay_rate =
1878+ get_sr_decay_rate(frame_info, twopass, frame_stats);
18761879 const double zero_motion_factor =
18771880 (0.95 * pow((frame_stats->pcnt_inter - frame_stats->pcnt_motion),
1878− ZM_POWER_FACTOR));
1881+ twopass->zm_power_factor));
18791882
18801883 return VPXMAX(zero_motion_factor,
18811884 (sr_decay_rate + ((1.0 - sr_decay_rate) * zero_motion_factor)));
@@ -1959,6 +1962,7 @@ static void accumulate_frame_motion_stats(const FIRSTPASS_STATS *stats, · 77 unmodified lines
19591962
19601963 static double calc_frame_boost(const FRAME_INFO *frame_info,
19611964 const FIRSTPASS_STATS *this_frame,
1965+ const TWO_PASS *const twopass,
19621966 int avg_frame_qindex,
19631967 double this_frame_mv_in_out) {
19641968 double frame_boost;
@@ -1968,7 +1972,7 @@ static double calc_frame_boost(const FRAME_INFO *frame_info, · 3 unmodified lines
19681972 const double active_area = calculate_active_area(frame_info, this_frame);
19691973
19701974 // Underlying boost factor is based on inter error ratio.
1971− frame_boost = (BASELINE_ERR_PER_MB * active_area) /
1975+ frame_boost = (twopass->base_err_per_mb * active_area) /
19721976 DOUBLE_DIVIDE_CHECK(this_frame->coded_error);
19731977
19741978 // Small adjustment for cases where there is a zoom out
@@ -1978,37 +1982,25 @@ static double calc_frame_boost(const FRAME_INFO *frame_info, · 3 unmodified lines
19781982 // Q correction and scalling
19791983 frame_boost = frame_boost * boost_q_correction;
19801984
1981− return VPXMIN(frame_boost, GF_MAX_FRAME_BOOST * boost_q_correction);
1982−}
1983−
1984−static double kf_err_per_mb(VP9_COMP *cpi) {
1985− const VP9_COMMON *const cm = &cpi->common;
1986− unsigned int screen_area = (cm->width * cm->height);
1987−
1988− // Use a different error per mb factor for calculating boost for
1989− // different formats.
1990− if (screen_area < 1280 * 720) {
1991− return 2000.0;
1992− } else if (screen_area < 1920 * 1080) {
1993− return 500.0;
1994− }
1995− return 250.0;
1985+ return VPXMIN(frame_boost, twopass->gf_frame_max_boost * boost_q_correction);
19961986 }
19971987
19981988 static double calc_kf_frame_boost(VP9_COMP *cpi,
19991989 const FIRSTPASS_STATS *this_frame,
20001990 double *sr_accumulator,
20011991 double this_frame_mv_in_out,
2002− double max_boost) {
1992+ double zm_factor) {
1993+ TWO_PASS *const twopass = &cpi->twopass;
20031994 double frame_boost;
20041995 const double lq = vp9_convert_qindex_to_q(
20051996 cpi->rc.avg_frame_qindex[INTER_FRAME], cpi->common.bit_depth);
20061997 const double boost_q_correction = VPXMIN((0.50 + (lq * 0.015)), 2.00);
20071998 const double active_area =
20081999 calculate_active_area(&cpi->frame_info, this_frame);
2000+ double max_boost;
20092001
20102002 // Underlying boost factor is based on inter error ratio.
2011− frame_boost = (kf_err_per_mb(cpi) * active_area) /
2003+ frame_boost = (twopass->kf_err_per_mb * active_area) /
20122004 DOUBLE_DIVIDE_CHECK(this_frame->coded_error + *sr_accumulator);
20132005
20142006 // Update the accumulator for second ref error difference.
@@ -2027,13 +2019,20 @@ static double calc_kf_frame_boost(VP9_COMP *cpi, · 12 unmodified lines
20272019 // boost calculation.
20282020 frame_boost = ((frame_boost + 40.0) * boost_q_correction);
20292021
2030− return VPXMIN(frame_boost, max_boost * boost_q_correction);
2022+ // Maximum allowed boost this frame. May be different for first vs subsequent
2023+ // key frames.
2024+ max_boost = (cpi->common.current_video_frame == 0)
2025+ ? twopass->kf_frame_max_boost_first
2026+ : twopass->kf_frame_max_boost_subs;
2027+ max_boost *= zm_factor * boost_q_correction;
2028+
2029+ return VPXMIN(frame_boost, max_boost);
20312030 }
20322031
20332032 static int compute_arf_boost(const FRAME_INFO *frame_info,
2034− const FIRST_PASS_INFO *first_pass_info,
2035− int arf_show_idx, int f_frames, int b_frames,
2036− int avg_frame_qindex) {
2033+ TWO_PASS *const twopass, int arf_show_idx,
2034+ int f_frames, int b_frames, int avg_frame_qindex) {
2035+ const FIRST_PASS_INFO *first_pass_info = &twopass->first_pass_info;
20372036 int i;
20382037 double boost_score = 0.0;
20392038 double mv_ratio_accumulator = 0.0;
@@ -2064,14 +2063,15 @@ static int compute_arf_boost(const FRAME_INFO *frame_info, · 24 unmodified lines
20642063
20652064 // Accumulate the effect of prediction quality decay.
20662065 if (!flash_detected) {
2067− decay_accumulator *= get_prediction_decay_rate(frame_info, this_frame);
2066+ decay_accumulator *=
2067+ get_prediction_decay_rate(frame_info, twopass, this_frame);
20682068 decay_accumulator = decay_accumulator < MIN_DECAY_FACTOR
20692069 ? MIN_DECAY_FACTOR
20702070 : decay_accumulator;
20712071 }
2072− boost_score += decay_accumulator * calc_frame_boost(frame_info, this_frame,
2073− avg_frame_qindex,
2074− this_frame_mv_in_out);
2072+ boost_score += decay_accumulator *
2073+ calc_frame_boost(frame_info, this_frame, twopass,
2074+ avg_frame_qindex, this_frame_mv_in_out);
20752075 }
20762076
20772077 arf_boost = (int)boost_score;
@@ -2104,14 +2104,15 @@ static int compute_arf_boost(const FRAME_INFO *frame_info, · 26 unmodified lines
21042104
21052105 // Cumulative effect of prediction quality decay.
21062106 if (!flash_detected) {
2107− decay_accumulator *= get_prediction_decay_rate(frame_info, this_frame);
2107+ decay_accumulator *=
2108+ get_prediction_decay_rate(frame_info, twopass, this_frame);
21082109 decay_accumulator = decay_accumulator < MIN_DECAY_FACTOR
21092110 ? MIN_DECAY_FACTOR
21102111 : decay_accumulator;
21112112 }
2112− boost_score += decay_accumulator * calc_frame_boost(frame_info, this_frame,
2113− avg_frame_qindex,
2114− this_frame_mv_in_out);
2113+ boost_score += decay_accumulator *
2114+ calc_frame_boost(frame_info, this_frame, twopass,
2115+ avg_frame_qindex, this_frame_mv_in_out);
21152116 }
21162117 arf_boost += (int)boost_score;
21172118
@@ -2127,8 +2128,8 @@ static int calc_arf_boost(VP9_COMP *cpi, int f_frames, int b_frames) { · 9 unmodified lines
21272128 TWO_PASS *const twopass = &cpi->twopass;
21282129 const int avg_inter_frame_qindex = cpi->rc.avg_frame_qindex[INTER_FRAME];
21292130 int arf_show_idx = get_show_idx(twopass);
2130− return compute_arf_boost(frame_info, &twopass->first_pass_info, arf_show_idx,
2131− f_frames, b_frames, avg_inter_frame_qindex);
2131+ return compute_arf_boost(frame_info, twopass, arf_show_idx, f_frames,
2132+ b_frames, avg_inter_frame_qindex);
21322133 }
21332134
21342135 // Calculate a section intra ratio used in setting max loop filter.
@@ -2557,10 +2558,11 @@ typedef struct RANGE { · 422 unmodified lines
25572558 * structs.
25582559 */
25592560 static int get_gop_coding_frame_num(
2560− int *use_alt_ref, const FRAME_INFO *frame_info,
2561− const FIRST_PASS_INFO *first_pass_info, const RATE_CONTROL *rc,
2562− int gf_start_show_idx, const RANGE *active_gf_interval,
2563− double gop_intra_factor, int lag_in_frames) {
2561+ int *use_alt_ref, const FRAME_INFO *frame_info, TWO_PASS *const twopass,
2562+ const RATE_CONTROL *rc, int gf_start_show_idx,
2563+ const RANGE *active_gf_interval, double gop_intra_factor,
2564+ int lag_in_frames) {
2565+ const FIRST_PASS_INFO *first_pass_info = &twopass->first_pass_info;
25642566 double loop_decay_rate = 1.00;
25652567 double mv_ratio_accumulator = 0.0;
25662568 double this_frame_mv_in_out = 0.0;
@@ -2603,13 +2605,14 @@ static int get_gop_coding_frame_num( · 36 unmodified lines
26032605 if ((rc->frames_since_key + gop_coding_frames - 1) > 1) {
26042606 zero_motion_accumulator =
26052607 VPXMIN(zero_motion_accumulator,
2606− get_zero_motion_factor(frame_info, next_frame));
2608+ get_zero_motion_factor(frame_info, twopass, next_frame));
26072609 }
26082610
26092611 // Accumulate the effect of prediction quality decay.
26102612 if (!flash_detected) {
26112613 double last_loop_decay_rate = loop_decay_rate;
2612− loop_decay_rate = get_prediction_decay_rate(frame_info, next_frame);
2614+ loop_decay_rate =
2615+ get_prediction_decay_rate(frame_info, twopass, next_frame);
26132616
26142617 // Break clause to detect very still sections after motion. For example,
26152618 // a static image after a fade or other transition.
@@ -2807,14 +2810,14 @@ static void define_gf_group(VP9_COMP *cpi, int gf_start_show_idx) { · 191 unmodified lines
28072810 use_alt_ref = gop_command->use_alt_ref;
28082811 } else {
28092812 gop_coding_frames = get_gop_coding_frame_num(
2810− &use_alt_ref, frame_info, first_pass_info, rc, gf_start_show_idx,
2813+ &use_alt_ref, frame_info, twopass, rc, gf_start_show_idx,
28112814 &active_gf_interval, gop_intra_factor, cpi->oxcf.lag_in_frames);
28122815 use_alt_ref &= allow_alt_ref;
28132816 }
28142817 }
28152818 #else
28162819 gop_coding_frames = get_gop_coding_frame_num(
2817− &use_alt_ref, frame_info, first_pass_info, rc, gf_start_show_idx,
2820+ &use_alt_ref, frame_info, twopass, rc, gf_start_show_idx,
28182821 &active_gf_interval, gop_intra_factor, cpi->oxcf.lag_in_frames);
28192822 use_alt_ref &= allow_alt_ref;
28202823 #endif
@@ -2836,8 +2839,8 @@ static void define_gf_group(VP9_COMP *cpi, int gf_start_show_idx) { · 15 unmodified lines
28362839
28372840 // Calculate the boost for alt ref.
28382841 rc->gfu_boost =
2839− compute_arf_boost(frame_info, first_pass_info, arf_show_idx, f_frames,
2840− b_frames, avg_inter_frame_qindex);
2842+ compute_arf_boost(frame_info, twopass, arf_show_idx, f_frames, b_frames,
2843+ avg_inter_frame_qindex);
28412844 rc->source_alt_ref_pending = 1;
28422845 } else {
28432846 const int f_frames = gop_coding_frames - 1;
@@ -2847,9 +2850,9 @@ static void define_gf_group(VP9_COMP *cpi, int gf_start_show_idx) { · 3 unmodified lines
28472850 const int gld_show_idx =
28482851 VPXMIN(gf_start_show_idx + 1, fps_get_num_frames(first_pass_info));
28492852 const int arf_boost =
2850− compute_arf_boost(frame_info, first_pass_info, gld_show_idx, f_frames,
2851− b_frames, avg_inter_frame_qindex);
2852− rc->gfu_boost = VPXMIN(MAX_GF_BOOST, arf_boost);
2853+ compute_arf_boost(frame_info, twopass, gld_show_idx, f_frames, b_frames,
2854+ avg_inter_frame_qindex);
2855+ rc->gfu_boost = VPXMIN(twopass->gf_max_total_boost, arf_boost);
28532856 rc->source_alt_ref_pending = 0;
28542857 }
28552858
@@ -2952,7 +2955,9 @@ static void define_gf_group(VP9_COMP *cpi, int gf_start_show_idx) { · 96 unmodified lines
29522955 cpi, group_av_err, (group_av_skip_pct + group_av_inactive_zone),
29532956 group_av_noise, vbr_group_bits_per_frame);
29542957 twopass->active_worst_quality =
2955− (tmp_q + (twopass->active_worst_quality * 3)) >> 2;
2958+ (int)((tmp_q + (twopass->active_worst_quality *
2959+ (twopass->active_wq_factor - 1))) /
2960+ twopass->active_wq_factor);
29562961
29572962 #if CONFIG_ALWAYS_ADJUST_BPM
29582963 // Reset rolling actual and target bits counters for ARF groups.
@@ -3174,8 +3179,9 @@ static int test_candidate_kf(const FIRST_PASS_INFO *first_pass_info, · 215 unmodified lines
31743179
31753180 int vp9_get_frames_to_next_key(const VP9EncoderConfig *oxcf,
31763181 const FRAME_INFO *frame_info,
3177− const FIRST_PASS_INFO *first_pass_info,
3178− int kf_show_idx, int min_gf_interval) {
3182+ const TWO_PASS *const twopass, int kf_show_idx,
3183+ int min_gf_interval) {
3184+ const FIRST_PASS_INFO *first_pass_info = &twopass->first_pass_info;
31793185 double recent_loop_decay[FRAMES_TO_CHECK_DECAY];
31803186 int j;
31813187 int frames_to_key;
@@ -3202,7 +3208,8 @@ int vp9_get_frames_to_next_key(const VP9EncoderConfig *oxcf, · 20 unmodified lines
32023208 break;
32033209
32043210 // How fast is the prediction quality decaying?
3205− loop_decay_rate = get_prediction_decay_rate(frame_info, next_frame);
3211+ loop_decay_rate =
3212+ get_prediction_decay_rate(frame_info, twopass, next_frame);
32063213
32073214 // We want to know something about the recent past... rather than
32083215 // as used elsewhere where we are concerned with decay in prediction
@@ -3289,7 +3296,7 @@ static void find_next_key_frame(VP9_COMP *cpi, int kf_show_idx) { · 80 unmodified lines
32893296 mean_mod_score, av_err);
32903297
32913298 rc->frames_to_key = vp9_get_frames_to_next_key(
3292− oxcf, frame_info, first_pass_info, kf_show_idx, rc->min_gf_interval);
3299+ oxcf, frame_info, twopass, kf_show_idx, rc->min_gf_interval);
32933300
32943301 // If there is a max kf interval set by the user we must obey it.
32953302 // We already breakout of the loop above at 2x max.
@@ -3369,9 +3376,9 @@ static void find_next_key_frame(VP9_COMP *cpi, int kf_show_idx) { · 73 unmodified lines
33693376 // Monitor for static sections.
33703377 // First frame in kf group the second ref indicator is invalid.
33713378 if (i > 0) {
3372− zero_motion_accumulator =
3373− VPXMIN(zero_motion_accumulator,
3374− get_zero_motion_factor(&cpi->frame_info, &next_frame));
3379+ zero_motion_accumulator = VPXMIN(
3380+ zero_motion_accumulator,
3381+ get_zero_motion_factor(&cpi->frame_info, twopass, &next_frame));
33753382 } else {
33763383 zero_motion_accumulator =
33773384 next_frame.pcnt_inter - next_frame.pcnt_motion;
@@ -3385,8 +3392,8 @@ static void find_next_key_frame(VP9_COMP *cpi, int kf_show_idx) { · 7 unmodified lines
33853392 // the first key frame or it points to a refernce before the new key
33863393 // frame.
33873394 if (i < 2) sr_accumulator = 0.0;
3388− frame_boost = calc_kf_frame_boost(cpi, &next_frame, &sr_accumulator, 0,
3389− KF_MAX_FRAME_BOOST * zm_factor);
3395+ frame_boost =
3396+ calc_kf_frame_boost(cpi, &next_frame, &sr_accumulator, 0, zm_factor);
33903397
33913398 boost_score += frame_boost;
33923399
@@ -3415,12 +3422,12 @@ static void find_next_key_frame(VP9_COMP *cpi, int kf_show_idx) { · 22 unmodified lines
34153422 // Special case for static / slide show content but dont apply
34163423 // if the kf group is very short.
34173424 if ((zero_motion_accumulator > 0.99) && (rc->frames_to_key > 8)) {
3418− rc->kf_boost = MAX_KF_TOT_BOOST;
3425+ rc->kf_boost = twopass->kf_max_total_boost;
34193426 } else {
3420− // Apply various clamps for min and max boost
3427+ // Apply various clamps for min and max oost
34213428 rc->kf_boost = VPXMAX((int)boost_score, (rc->frames_to_key * 3));
34223429 rc->kf_boost = VPXMAX(rc->kf_boost, MIN_KF_TOT_BOOST);
3423− rc->kf_boost = VPXMIN(rc->kf_boost, MAX_KF_TOT_BOOST);
3430+ rc->kf_boost = VPXMIN(rc->kf_boost, twopass->kf_max_total_boost);
34243431 }
34253432
34263433 // Work out how many bits to allocate for the key frame itself.
@@ -3477,107 +3484,113 @@ static int is_skippable_frame(const VP9_COMP *cpi) { · 50 unmodified lines
34773484
34783485 // Configure image size specific vizier parameters.
34793486 // Later these will be set via additional command line options
3480−static void init_vizier_params(RATE_CONTROL *const rc, int screen_area) {
3487+static void init_vizier_params(TWO_PASS *const twopass, int screen_area) {
34813488 if (1) {
34823489 // Force defaults for now
3483− rc->active_wq_factor = AV_WQ_FACTOR;
3484− rc->base_err_per_mb = BASELINE_ERR_PER_MB;
3485− rc->sr_default_decay_limit = DEFAULT_DECAY_LIMIT;
3486− rc->sr_diff_part = SR_DIFF_PART;
3487− rc->gf_frame_max_boost = GF_MAX_FRAME_BOOST;
3488− rc->gf_max_total_boost = MAX_GF_BOOST;
3489− rc->kf_err_per_mb = DEF_EPMB_LOW;
3490− rc->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST; // Max for first kf.
3491− rc->kf_frame_max_boost_subs = KF_MAX_FRAME_BOOST / 2; // Max for other kfs.
3492− rc->kf_max_total_boost = MAX_KF_TOT_BOOST;
3493− rc->zm_power_factor = ZM_POWER_FACTOR;
3490+ twopass->active_wq_factor = AV_WQ_FACTOR;
3491+ twopass->base_err_per_mb = BASELINE_ERR_PER_MB;
3492+ twopass->sr_default_decay_limit = DEFAULT_DECAY_LIMIT;
3493+ twopass->sr_diff_part = SR_DIFF_PART;
3494+ twopass->gf_frame_max_boost = GF_MAX_FRAME_BOOST;
3495+ twopass->gf_max_total_boost = MAX_GF_BOOST;
3496+ if (screen_area < 1280 * 720) {
3497+ twopass->kf_err_per_mb = 2000.0;
3498+ } else if (screen_area < 1920 * 1080) {
3499+ twopass->kf_err_per_mb = 500.0;
3500+ } else {
3501+ twopass->kf_err_per_mb = 250.0;
3502+ }
3503+ twopass->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST;
3504+ twopass->kf_frame_max_boost_subs = twopass->kf_frame_max_boost_first;
3505+ twopass->kf_max_total_boost = MAX_KF_TOT_BOOST;
3506+ twopass->zm_power_factor = ZM_POWER_FACTOR;
34943507 } else {
34953508 // Vizer experimental parameters from training.
34963509 // Later these will be set via the command line.
34973510 if (screen_area <= 176 * 144) {
3498− rc->active_wq_factor = 46.0;
3499− rc->base_err_per_mb = 37597.399760969536;
3500− rc->sr_default_decay_limit = 0.3905639800962774;
3501− rc->sr_diff_part = 0.009599023654146284;
3502− rc->gf_frame_max_boost = 87.27362648627846;
3503− rc->gf_max_total_boost = MAX_GF_BOOST;
3504− rc->kf_err_per_mb = 1854.8255436877148;
3505− rc->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST;
3506− rc->kf_frame_max_boost_subs = rc->kf_frame_max_boost_first / 2;
3507− rc->kf_max_total_boost = MAX_KF_TOT_BOOST;
3508− rc->zm_power_factor = 2.93715229184991;
3511+ twopass->active_wq_factor = 46.0;
3512+ twopass->base_err_per_mb = 37597.399760969536;
3513+ twopass->sr_default_decay_limit = 0.3905639800962774;
3514+ twopass->sr_diff_part = 0.009599023654146284;
3515+ twopass->gf_frame_max_boost = 87.27362648627846;
3516+ twopass->gf_max_total_boost = MAX_GF_BOOST;
3517+ twopass->kf_err_per_mb = 1854.8255436877148;
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_power_factor = 2.93715229184991;
35093522 } else if (screen_area <= 320 * 240) {
3510− rc->active_wq_factor = 55.0;
3511− rc->base_err_per_mb = 34525.33177195309;
3512− rc->sr_default_decay_limit = 0.23901360046804604;
3513− rc->sr_diff_part = 0.008581014394766773;
3514− rc->gf_frame_max_boost = 127.34978204980285;
3515− rc->gf_max_total_boost = MAX_GF_BOOST;
3516− rc->kf_err_per_mb = 723.8337508755031;
3517− rc->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST;
3518− rc->kf_frame_max_boost_subs = rc->kf_frame_max_boost_first / 2;
3519− rc->kf_max_total_boost = MAX_KF_TOT_BOOST;
3520− rc->zm_power_factor = 3.5299221493593413;
3523+ twopass->active_wq_factor = 55.0;
3524+ twopass->base_err_per_mb = 34525.33177195309;
3525+ twopass->sr_default_decay_limit = 0.23901360046804604;
3526+ twopass->sr_diff_part = 0.008581014394766773;
3527+ twopass->gf_frame_max_boost = 127.34978204980285;
3528+ twopass->gf_max_total_boost = MAX_GF_BOOST;
3529+ twopass->kf_err_per_mb = 723.8337508755031;
3530+ twopass->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST;
3531+ twopass->kf_frame_max_boost_subs = twopass->kf_frame_max_boost_first;
3532+ twopass->kf_max_total_boost = MAX_KF_TOT_BOOST;
3533+ twopass->zm_power_factor = 3.5299221493593413;
35213534 } else if (screen_area <= 640 * 360) {
3522− rc->active_wq_factor = 12.5;
3523− rc->base_err_per_mb = 18823.978018028298;
3524− rc->sr_default_decay_limit = 0.6043527690301296;
3525− rc->sr_diff_part = 0.00343296783885544;
3526− rc->gf_frame_max_boost = 75.17672317013668;
3527− rc->gf_max_total_boost = MAX_GF_BOOST;
3528− rc->kf_err_per_mb = 422.2871502380377;
3529− rc->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST;
3530− rc->kf_frame_max_boost_subs = rc->kf_frame_max_boost_first / 2;
3531− rc->kf_max_total_boost = MAX_KF_TOT_BOOST;
3532− rc->zm_power_factor = 2.265742666649307;
3535+ twopass->active_wq_factor = 12.5;
3536+ twopass->base_err_per_mb = 18823.978018028298;
3537+ twopass->sr_default_decay_limit = 0.6043527690301296;
3538+ twopass->sr_diff_part = 0.00343296783885544;
3539+ twopass->gf_frame_max_boost = 75.17672317013668;
3540+ twopass->gf_max_total_boost = MAX_GF_BOOST;
3541+ twopass->kf_err_per_mb = 422.2871502380377;
3542+ twopass->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST;
3543+ twopass->kf_frame_max_boost_subs = twopass->kf_frame_max_boost_first;
3544+ twopass->kf_max_total_boost = MAX_KF_TOT_BOOST;
3545+ twopass->zm_power_factor = 2.265742666649307;
35333546 } else if (screen_area <= 854 * 480) {
3534− rc->active_wq_factor = 51.5;
3535− rc->base_err_per_mb = 33718.98307662595;
3536− rc->sr_default_decay_limit = 0.33633414970713393;
3537− rc->sr_diff_part = 0.00868988716928333;
3538− rc->gf_frame_max_boost = 85.2868528581522;
3539− rc->gf_max_total_boost = MAX_GF_BOOST;
3540− rc->kf_err_per_mb = 1513.4883914008383;
3541− rc->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST;
3542− rc->kf_frame_max_boost_subs = rc->kf_frame_max_boost_first / 2;
3543− rc->kf_max_total_boost = MAX_KF_TOT_BOOST;
3544− rc->zm_power_factor = 3.552278528517416;
3547+ twopass->active_wq_factor = 51.5;
3548+ twopass->base_err_per_mb = 33718.98307662595;
3549+ twopass->sr_default_decay_limit = 0.33633414970713393;
3550+ twopass->sr_diff_part = 0.00868988716928333;
3551+ twopass->gf_frame_max_boost = 85.2868528581522;
3552+ twopass->gf_max_total_boost = MAX_GF_BOOST;
3553+ twopass->kf_err_per_mb = 1513.4883914008383;
3554+ twopass->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST;
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_power_factor = 3.552278528517416;
35453558 } else if (screen_area <= 1280 * 720) {
3546− rc->active_wq_factor = 41.5;
3547− rc->base_err_per_mb = 29527.46375825401;
3548− rc->sr_default_decay_limit = 0.5009117586299728;
3549− rc->sr_diff_part = 0.005007364627260114;
3550− rc->gf_frame_max_boost = GF_MAX_FRAME_BOOST;
3551− rc->gf_max_total_boost = MAX_GF_BOOST;
3552− rc->kf_err_per_mb = 998.6342911785146;
3553− rc->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST;
3554− rc->kf_frame_max_boost_subs = rc->kf_frame_max_boost_first / 2;
3555− rc->kf_max_total_boost = MAX_KF_TOT_BOOST;
3556− rc->zm_power_factor = 2.568627575572356;
3559+ twopass->active_wq_factor = 41.5;
3560+ twopass->base_err_per_mb = 29527.46375825401;
3561+ twopass->sr_default_decay_limit = 0.5009117586299728;
3562+ twopass->sr_diff_part = 0.005007364627260114;
3563+ twopass->gf_frame_max_boost = GF_MAX_FRAME_BOOST;
3564+ twopass->gf_max_total_boost = MAX_GF_BOOST;
3565+ twopass->kf_err_per_mb = 998.6342911785146;
3566+ twopass->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST;
3567+ twopass->kf_frame_max_boost_subs = twopass->kf_frame_max_boost_first;
3568+ twopass->kf_max_total_boost = MAX_KF_TOT_BOOST;
3569+ twopass->zm_power_factor = 2.568627575572356;
35573570 } else if (screen_area <= 1920 * 1080) {
3558− rc->active_wq_factor = 31.0;
3559− rc->base_err_per_mb = 34474.723463367416;
3560− rc->sr_default_decay_limit = 0.23346886902707745;
3561− rc->sr_diff_part = 0.011431716637966029;
3562− rc->gf_frame_max_boost = 81.00472969483079;
3563− rc->gf_max_total_boost = MAX_GF_BOOST;
3564− rc->kf_err_per_mb = 35931.25734431429;
3565− rc->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST;
3566− rc->kf_frame_max_boost_subs = rc->kf_frame_max_boost_first / 2;
3567− rc->kf_max_total_boost = MAX_KF_TOT_BOOST;
3568− rc->zm_power_factor = 5.5776463538431935;
3571+ twopass->active_wq_factor = 31.0;
3572+ twopass->base_err_per_mb = 34474.723463367416;
3573+ twopass->sr_default_decay_limit = 0.23346886902707745;
3574+ twopass->sr_diff_part = 0.011431716637966029;
3575+ twopass->gf_frame_max_boost = 81.00472969483079;
3576+ twopass->gf_max_total_boost = MAX_GF_BOOST;
3577+ twopass->kf_err_per_mb = 35931.25734431429;
3578+ twopass->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST;
3579+ twopass->kf_frame_max_boost_subs = twopass->kf_frame_max_boost_first;
3580+ twopass->kf_max_total_boost = MAX_KF_TOT_BOOST;
3581+ twopass->zm_power_factor = 5.5776463538431935;
35693582 } else {
3570− rc->active_wq_factor = AV_WQ_FACTOR;
3571− rc->base_err_per_mb = BASELINE_ERR_PER_MB;
3572− rc->sr_default_decay_limit = DEFAULT_DECAY_LIMIT;
3573− rc->sr_diff_part = SR_DIFF_PART;
3574− rc->gf_frame_max_boost = GF_MAX_FRAME_BOOST;
3575− rc->gf_max_total_boost = MAX_GF_BOOST;
3576− rc->kf_err_per_mb = DEF_EPMB_LOW;
3577− rc->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST;
3578− rc->kf_frame_max_boost_subs = rc->kf_frame_max_boost_first / 2;
3579− rc->kf_max_total_boost = MAX_KF_TOT_BOOST;
3580− rc->zm_power_factor = ZM_POWER_FACTOR;
3583+ twopass->active_wq_factor = AV_WQ_FACTOR;
3584+ twopass->base_err_per_mb = BASELINE_ERR_PER_MB;
3585+ twopass->sr_default_decay_limit = DEFAULT_DECAY_LIMIT;
3586+ twopass->sr_diff_part = SR_DIFF_PART;
3587+ twopass->gf_frame_max_boost = GF_MAX_FRAME_BOOST;
3588+ twopass->gf_max_total_boost = MAX_GF_BOOST;
3589+ twopass->kf_err_per_mb = 250.0;
3590+ twopass->kf_frame_max_boost_first = KF_MAX_FRAME_BOOST;
3591+ twopass->kf_frame_max_boost_subs = twopass->kf_frame_max_boost_first;
3592+ twopass->kf_max_total_boost = MAX_KF_TOT_BOOST;
3593+ twopass->zm_power_factor = ZM_POWER_FACTOR;
35813594 }
35823595 }
35833596 }
@@ -3596,7 +3609,7 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) { · 12 unmodified lines
35963609 if (cm->current_video_frame == 0) {
35973610 unsigned int screen_area = (cm->width * cm->height);
35983611
3599− init_vizier_params(rc, screen_area);
3612+ init_vizier_params(twopass, screen_area);
36003613 }
36013614
36023615 // If this is an arf frame then we dont want to read the stats file or
@@ -3862,9 +3875,9 @@ void vp9_get_next_group_of_picture(const VP9_COMP *cpi, int *first_is_key_frame, · 259 unmodified lines
38623875
38633876 *first_is_key_frame = 0;
38643877 if (rc.frames_to_key == 0) {
3865− rc.frames_to_key = vp9_get_frames_to_next_key(
3866− &cpi->oxcf, &cpi->frame_info, &cpi->twopass.first_pass_info,
3867− *first_show_idx, rc.min_gf_interval);
3878+ rc.frames_to_key =
3879+ vp9_get_frames_to_next_key(&cpi->oxcf, &cpi->frame_info, twopass,
3880+ *first_show_idx, rc.min_gf_interval);
38683881 rc.frames_since_key = 0;
38693882 *first_is_key_frame = 1;
38703883 }
@@ -3903,9 +3916,9 @@ int vp9_get_gop_coding_frame_count(const VP9EncoderConfig *oxcf, · 32 unmodified lines
39033916 gop_intra_factor = 1.0;
39043917 }
39053918
3906− frame_count = get_gop_coding_frame_num(
3907− use_alt_ref, frame_info, first_pass_info, rc, show_idx,
3908− &active_gf_interval, gop_intra_factor, oxcf->lag_in_frames);
3919+ frame_count = get_gop_coding_frame_num(use_alt_ref, frame_info, twopass, rc,
3920+ show_idx, &active_gf_interval,
3921+ gop_intra_factor, oxcf->lag_in_frames);
39093922 *use_alt_ref &= allow_alt_ref;
39103923 return frame_count;
39113924 }
@@ -3929,7 +3942,7 @@ int vp9_get_coding_frame_num(const VP9EncoderConfig *oxcf, · 17 unmodified lines
39293942 int first_is_key_frame = 0;
39303943 if (rc.frames_to_key == 0) {
39313944 rc.frames_to_key = vp9_get_frames_to_next_key(
3932− oxcf, frame_info, first_pass_info, show_idx, rc.min_gf_interval);
3945+ oxcf, frame_info, twopass, show_idx, rc.min_gf_interval);
39333946 rc.frames_since_key = 0;
39343947 first_is_key_frame = 1;
39353948 }
@@ -3951,8 +3964,7 @@ int vp9_get_coding_frame_num(const VP9EncoderConfig *oxcf, · 15 unmodified lines
39513964
39523965 void vp9_get_key_frame_map(const VP9EncoderConfig *oxcf,
39533966 const FRAME_INFO *frame_info,
3954− const FIRST_PASS_INFO *first_pass_info,
3955− int *key_frame_map) {
3967+ const TWO_PASS *const twopass, int *key_frame_map) {
39563968 int show_idx = 0;
39573969 RATE_CONTROL rc;
39583970 vp9_rc_init(oxcf, 1, &rc);
@@ -3966,7 +3978,7 @@ void vp9_get_key_frame_map(const VP9EncoderConfig *oxcf, · 7 unmodified lines
39663978 int key_frame_group_size;
39673979 key_frame_map[show_idx] = 1;
39683980 key_frame_group_size = vp9_get_frames_to_next_key(
3969− oxcf, frame_info, first_pass_info, show_idx, rc.min_gf_interval);
3981+ oxcf, frame_info, twopass, show_idx, rc.min_gf_interval);
39703982 assert(key_frame_group_size > 0);
39713983 show_idx += key_frame_group_size;
39723984 }
vp9/encoder/vp9_firstpass.h+15−2
@@ -221,6 +221,19 @@ typedef struct { · 220 unmodified lines
221221 int last_qindex_of_arf_layer[MAX_ARF_LAYERS];
222222
223223 GF_GROUP gf_group;
224+
225+ // Vizeir project experimental two pass rate control parameters.
226+ double active_wq_factor;
227+ double base_err_per_mb;
228+ double sr_default_decay_limit;
229+ double sr_diff_part;
230+ double kf_err_per_mb;
231+ double kf_frame_max_boost_first; // Max for first kf in a chunk.
232+ double kf_frame_max_boost_subs; // Max for subsequent mid chunk kfs.
233+ int kf_max_total_boost;
234+ int gf_max_total_boost;
235+ double gf_frame_max_boost;
236+ double zm_power_factor;
224237 } TWO_PASS;
225238
226239 struct VP9_COMP;
@@ -249,8 +262,8 @@ void calculate_coded_size(struct VP9_COMP *cpi, int *scaled_frame_width, · 22 unmodified lines
249262 struct VP9EncoderConfig;
250263 int vp9_get_frames_to_next_key(const struct VP9EncoderConfig *oxcf,
251264 const FRAME_INFO *frame_info,
252− const FIRST_PASS_INFO *first_pass_info,
253− int kf_show_idx, int min_gf_interval);
265+ const TWO_PASS *const twopass, int kf_show_idx,
266+ int min_gf_interval);
254267 #if CONFIG_RATE_CTRL
255268 /* Call this function to get info about the next group of pictures.
256269 * This function should be called after vp9_create_compressor() when encoding
vp9/encoder/vp9_ratectrl.h+0−13
@@ -204,19 +204,6 @@ typedef struct { · 203 unmodified lines
204204 int preserve_arf_as_gld;
205205 int preserve_next_arf_as_gld;
206206 int show_arf_as_gld;
207−
208− // Vizeir project experimental rate control parameters.
209− double active_wq_factor;
210− double base_err_per_mb;
211− double sr_default_decay_limit;
212− double sr_diff_part;
213− double kf_frame_max_boost_first; // Max for first kf in a chunk.
214− double kf_frame_max_boost_subs; // Max for subsequent mid chunk kfs.
215− double kf_max_total_boost;
216− double kf_err_per_mb;
217− double gf_frame_max_boost;
218− double gf_max_total_boost;
219− double zm_power_factor;
220207 } RATE_CONTROL;
221208
222209 struct VP9_COMP;

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