Enable flex-refs by default when altref2 is on
Compared against baseline with default enabled tools (except for
ext-tx and global-motion for speed concern):
altref2 -> altref2 + flex-refs
lowres: avg_psnr -0.395% -> -0.460%
midres: avg_psnr -0.418% -> -0.478%
In particular, flex-refs improves the coding performance for the
following 3 clips while no impact on all other clips:
bowing_cif.y4m: avg_psnr 0.023% -> -1.022%
pamphlet_cif.y4m: avg_psnr 0.454% -> -1.111%
snow_mnt_480p.y4m: avg_psnr -0.162% -> -1.948%
Change-Id: I612c1ae5feb1f07d8bd5aaf67e21a076445e10b9
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c
index 8e8cb3c..f7432e0 100644
--- a/av1/encoder/encodeframe.c
+++ b/av1/encoder/encodeframe.c
@@ -1491,9 +1491,9 @@
if ((rd_cost->rate != INT_MAX) && (aq_mode == COMPLEXITY_AQ) &&
(bsize >= BLOCK_16X16) &&
(cm->frame_type == KEY_FRAME || cpi->refresh_alt_ref_frame ||
-#if CONFIG_EXT_REFS && CONFIG_ALTREF2
+#if CONFIG_ALTREF2
cpi->refresh_alt2_ref_frame ||
-#endif // CONFIG_EXT_REFS && CONFIG_ALTREF2
+#endif // CONFIG_ALTREF2
(cpi->refresh_golden_frame && !cpi->rc.is_src_frame_alt_ref))) {
av1_caq_select_segment(cpi, x, bsize, mi_row, mi_col, rd_cost->rate);
}
@@ -4717,9 +4717,9 @@
#endif
return ALTREF_FRAME;
else if (cpi->refresh_golden_frame ||
-#if CONFIG_EXT_REFS && CONFIG_ALTREF2
+#if CONFIG_ALTREF2
cpi->refresh_alt2_ref_frame ||
-#endif // CONFIG_EXT_REFS && CONFIG_ALTREF2
+#endif // CONFIG_ALTREF2
cpi->refresh_alt_ref_frame)
return GOLDEN_FRAME;
else
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 1faa0ec..6fa0264 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -5450,10 +5450,10 @@
(gf_group->update_type[gf_group->index] == INTNL_OVERLAY_UPDATE) ||
#endif // CONFIG_EXT_REFS
(gf_group->update_type[gf_group->index] == OVERLAY_UPDATE);
-#if CONFIG_EXT_REFS && CONFIG_ALTREF2
+#if CONFIG_ALTREF2
rc->is_src_frame_ext_arf =
gf_group->update_type[gf_group->index] == INTNL_OVERLAY_UPDATE;
-#endif // CONFIG_EXT_REFS && CONFIG_ALTREF2
+#endif // CONFIG_ALTREF2
} else {
rc->is_src_frame_alt_ref =
cpi->alt_ref_source && (source == cpi->alt_ref_source);
@@ -5463,20 +5463,20 @@
// Current frame is an ARF overlay frame.
cpi->alt_ref_source = NULL;
-#if CONFIG_EXT_REFS && CONFIG_ALTREF2
+#if CONFIG_ALTREF2
if (rc->is_src_frame_ext_arf && !cpi->common.show_existing_frame) {
// For INTNL_OVERLAY, when show_existing_frame == 0, they do need to
// refresh the LAST_FRAME, i.e. LAST3 gets retired, LAST2 becomes LAST3,
// LAST becomes LAST2, and INTNL_OVERLAY becomes LAST.
cpi->refresh_last_frame = 1;
} else {
-#endif // CONFIG_EXT_REFS && CONFIG_ALTREF2
+#endif // CONFIG_ALTREF2
// Don't refresh the last buffer for an ARF overlay frame. It will
// become the GF so preserve last as an alternative prediction option.
cpi->refresh_last_frame = 0;
-#if CONFIG_EXT_REFS && CONFIG_ALTREF2
+#if CONFIG_ALTREF2
}
-#endif // CONFIG_EXT_REFS && CONFIG_ALTREF2
+#endif // CONFIG_ALTREF2
}
}
diff --git a/av1/encoder/firstpass.c b/av1/encoder/firstpass.c
index 12d8799..8b4c304 100644
--- a/av1/encoder/firstpass.c
+++ b/av1/encoder/firstpass.c
@@ -2922,9 +2922,9 @@
// If this is an arf frame then we dont want to read the stats file or
// advance the input pointer as we already have what we need.
if (gf_group->update_type[gf_group->index] == ARF_UPDATE
-#if CONFIG_EXT_REFS && CONFIG_ALTREF2
+#if CONFIG_ALTREF2
|| gf_group->update_type[gf_group->index] == INTNL_ARF_UPDATE
-#endif // CONFIG_EXT_REFS && CONFIG_ALTREF2
+#endif // CONFIG_ALTREF2
) {
configure_buffer_updates(cpi);
target_rate = gf_group->bit_allocation[gf_group->index];
diff --git a/av1/encoder/ratectrl.c b/av1/encoder/ratectrl.c
index a1f53b7..6e4be09 100644
--- a/av1/encoder/ratectrl.c
+++ b/av1/encoder/ratectrl.c
@@ -580,9 +580,9 @@
curr_frame == 0 ? rc->worst_quality : rc->last_q[KEY_FRAME] * 2;
} else {
if (!rc->is_src_frame_alt_ref && (cpi->refresh_golden_frame ||
-#if CONFIG_EXT_REFS && CONFIG_ALTREF2
+#if CONFIG_ALTREF2
cpi->refresh_alt2_ref_frame ||
-#endif // CONFIG_EXT_REFS && CONFIG_ALTREF2
+#endif // CONFIG_ALTREF2
cpi->refresh_alt_ref_frame)) {
active_worst_quality = curr_frame == 1 ? rc->last_q[KEY_FRAME] * 5 / 4
: rc->last_q[INTER_FRAME];
@@ -1009,9 +1009,9 @@
av1_compute_qdelta(rc, q_val, q_val * q_adj_factor, cm->bit_depth);
}
} else if (!rc->is_src_frame_alt_ref && (cpi->refresh_golden_frame ||
-#if CONFIG_EXT_REFS && CONFIG_ALTREF2
+#if CONFIG_ALTREF2
cpi->refresh_alt2_ref_frame ||
-#endif // CONFIG_EXT_REFS && CONFIG_ALTREF2
+#endif // CONFIG_ALTREF2
cpi->refresh_alt_ref_frame)) {
// Use the lower of active_worst_quality and recent
// average Q as basis for GF/ARF best Q limit unless last frame was
@@ -1032,11 +1032,11 @@
active_best_quality = active_best_quality * 15 / 16;
} else if (oxcf->rc_mode == AOM_Q) {
-#if CONFIG_EXT_REFS && CONFIG_ALTREF2
+#if CONFIG_ALTREF2
if (!cpi->refresh_alt_ref_frame && !cpi->refresh_alt2_ref_frame) {
#else
if (!cpi->refresh_alt_ref_frame) {
-#endif // CONFIG_EXT_REFS && CONFIG_ALTREF2
+#endif // CONFIG_ALTREF2
active_best_quality = cq_level;
} else {
active_best_quality = get_gf_active_quality(rc, q, cm->bit_depth);
@@ -1069,9 +1069,9 @@
(cpi->twopass.gf_zeromotion_pct < VLOW_MOTION_THRESHOLD)) {
if (frame_is_intra_only(cm) ||
(!rc->is_src_frame_alt_ref && (cpi->refresh_golden_frame ||
-#if CONFIG_EXT_REFS && CONFIG_ALTREF2
+#if CONFIG_ALTREF2
cpi->refresh_alt2_ref_frame ||
-#endif // CONFIG_EXT_REFS && CONFIG_ALTREF2
+#endif // CONFIG_ALTREF2
cpi->refresh_alt_ref_frame))) {
active_best_quality -=
(cpi->twopass.extend_minq + cpi->twopass.extend_minq_fast);
@@ -1232,11 +1232,11 @@
// Decrement count down till next gf
if (rc->frames_till_gf_update_due > 0) rc->frames_till_gf_update_due--;
-#if CONFIG_EXT_REFS && CONFIG_ALTREF2
+#if CONFIG_ALTREF2
} else if (!cpi->refresh_alt_ref_frame && !cpi->refresh_alt2_ref_frame) {
#else
} else if (!cpi->refresh_alt_ref_frame) {
-#endif // CONFIG_EXT_REFS && CONFIG_ALTREF2
+#endif // CONFIG_ALTREF2
// Decrement count down till next gf
if (rc->frames_till_gf_update_due > 0) rc->frames_till_gf_update_due--;
@@ -1267,9 +1267,9 @@
} else {
if (!rc->is_src_frame_alt_ref &&
!(cpi->refresh_golden_frame ||
-#if CONFIG_EXT_REFS && CONFIG_ALTREF2
+#if CONFIG_ALTREF2
cpi->refresh_alt2_ref_frame ||
-#endif // CONFIG_EXT_REFS && CONFIG_ALTREF2
+#endif // CONFIG_ALTREF2
cpi->refresh_alt_ref_frame)) {
rc->last_q[INTER_FRAME] = qindex;
rc->avg_frame_qindex[INTER_FRAME] =
@@ -1292,9 +1292,9 @@
if ((qindex < rc->last_boosted_qindex) || (cm->frame_type == KEY_FRAME) ||
(!rc->constrained_gf_group &&
(cpi->refresh_alt_ref_frame ||
-#if CONFIG_EXT_REFS && CONFIG_ALTREF2
+#if CONFIG_ALTREF2
cpi->refresh_alt2_ref_frame ||
-#endif // CONFIG_EXT_REFS && CONFIG_ALTREF2
+#endif // CONFIG_ALTREF2
(cpi->refresh_golden_frame && !rc->is_src_frame_alt_ref)))) {
rc->last_boosted_qindex = qindex;
}
diff --git a/configure b/configure
index 157168f..a647f8c 100755
--- a/configure
+++ b/configure
@@ -559,6 +559,7 @@
enabled ext_comp_refs && enable_feature var_refs
enabled ext_comp_refs && disable_feature one_sided_compound
enabled altref2 && enable_feature ext_refs
+ enabled altref2 && enable_feature flex_refs
enabled rect_tx_ext && enable_feature rect_tx
enabled cfl && enable_feature smooth_hv