ref: 5de798f2b26fce3e82f0c28219fe13c3cf88dde7
parent: 86e340c76e73c5336b2a39142ab858431d441d6b
author: Marco <marpan@google.com>
date: Wed Dec 14 09:08:09 EST 2016
vp9: Fix to usage of flag USE_ALTREF_FOR_ONE_PASS The flag USE_ALTREF_FOR_ONE_PASS allows for alt-ref lookahead in 1 pass vbr (from https://chromium-review.googlesource.com/#/c/365498). This change is to make sure this macro flag only has effect if the config flag cpi->oxcf.enable_auto_altef is also on. No change in ytlive encoding, as USE_ALTREF_FOR_ONE_PASS is not yet enabled. Change-Id: I1a69681e4a15c5244581a3dab4587fca08f02e0f
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -45,7 +45,7 @@
#define FRAME_OVERHEAD_BITS 200
-// Use this macro to turn on/off use of alt-refs in one-pass mode.
+// Use this macro to turn on/off use of alt-refs in one-pass vbr mode.
#define USE_ALTREF_FOR_ONE_PASS 0
#if CONFIG_VP9_HIGHBITDEPTH
@@ -566,9 +566,9 @@
VPXMAX(cpi->rc.q_1_frame, cpi->rc.q_2_frame));
}
#if USE_ALTREF_FOR_ONE_PASS
- if (cpi->oxcf.pass == 0 && cpi->oxcf.rc_mode == VPX_VBR &&
- cpi->oxcf.lag_in_frames > 0 && cpi->rc.is_src_frame_alt_ref &&
- !cpi->rc.alt_ref_gf_group) {
+ if (cpi->oxcf.enable_auto_arf && cpi->oxcf.pass == 0 &&
+ cpi->oxcf.rc_mode == VPX_VBR && cpi->oxcf.lag_in_frames > 0 &&
+ cpi->rc.is_src_frame_alt_ref && !cpi->rc.alt_ref_gf_group) {
q = VPXMIN(q, (q + cpi->rc.last_boosted_qindex) >> 1);
}
#endif
@@ -1528,8 +1528,14 @@
adjust_gfint_frame_constraint(cpi, rc->frames_to_key);
rc->frames_till_gf_update_due = rc->baseline_gf_interval;
cpi->refresh_golden_frame = 1;
- rc->source_alt_ref_pending = USE_ALTREF_FOR_ONE_PASS;
- rc->alt_ref_gf_group = USE_ALTREF_FOR_ONE_PASS;
+ rc->source_alt_ref_pending = 0;
+ rc->alt_ref_gf_group = 0;
+#if USE_ALTREF_FOR_ONE_PASS
+ if (cpi->oxcf.enable_auto_arf) {
+ rc->source_alt_ref_pending = 1;
+ rc->alt_ref_gf_group = 1;
+ }
+#endif
}
if (cm->frame_type == KEY_FRAME)
target = calc_iframe_target_size_one_pass_vbr(cpi);
@@ -2140,20 +2146,22 @@
rc->gfu_boost = DEFAULT_GF_BOOST >> 2;
}
#if USE_ALTREF_FOR_ONE_PASS
- // Don't use alt-ref if there is a scene cut within the group,
- // or content is not low.
- if ((rc->high_source_sad_lagindex > 0 &&
- rc->high_source_sad_lagindex <= rc->frames_till_gf_update_due) ||
- (avg_source_sad_lag > 3 * sad_thresh1 >> 3)) {
- rc->source_alt_ref_pending = 0;
- rc->alt_ref_gf_group = 0;
- } else {
- rc->source_alt_ref_pending = 1;
- rc->alt_ref_gf_group = 1;
- // If alt-ref is used for this gf group, limit the interval.
- if (rc->baseline_gf_interval > 10 &&
- rc->baseline_gf_interval < rc->frames_to_key)
- rc->baseline_gf_interval = 10;
+ if (cpi->oxcf.enable_auto_arf) {
+ // Don't use alt-ref if there is a scene cut within the group,
+ // or content is not low.
+ if ((rc->high_source_sad_lagindex > 0 &&
+ rc->high_source_sad_lagindex <= rc->frames_till_gf_update_due) ||
+ (avg_source_sad_lag > 3 * sad_thresh1 >> 3)) {
+ rc->source_alt_ref_pending = 0;
+ rc->alt_ref_gf_group = 0;
+ } else {
+ rc->source_alt_ref_pending = 1;
+ rc->alt_ref_gf_group = 1;
+ // If alt-ref is used for this gf group, limit the interval.
+ if (rc->baseline_gf_interval > 10 &&
+ rc->baseline_gf_interval < rc->frames_to_key)
+ rc->baseline_gf_interval = 10;
+ }
}
#endif
target = calc_pframe_target_size_one_pass_vbr(cpi);
@@ -2284,7 +2292,10 @@
cpi->ext_refresh_frame_flags_pending == 0) {
int target;
cpi->refresh_golden_frame = 1;
- rc->source_alt_ref_pending = USE_ALTREF_FOR_ONE_PASS;
+ rc->source_alt_ref_pending = 0;
+#if USE_ALTREF_FOR_ONE_PASS
+ if (cpi->oxcf.enable_auto_arf) rc->source_alt_ref_pending = 1;
+#endif
rc->gfu_boost = DEFAULT_GF_BOOST >> 1;
rc->baseline_gf_interval =
VPXMIN(20, VPXMAX(10, rc->baseline_gf_interval));