Remove compile guards for CONFIG_EXT_REFS
This experiment has been adopted, we can simplify the code
by dropping the associated preprocessor conditionals.
Change-Id: I4705652ac8231ee25f960e8096dc97c2aeed1d20
diff --git a/av1/encoder/ratectrl.c b/av1/encoder/ratectrl.c
index a90cb88..c431f65 100644
--- a/av1/encoder/ratectrl.c
+++ b/av1/encoder/ratectrl.c
@@ -196,12 +196,8 @@
const AV1EncoderConfig *oxcf = &cpi->oxcf;
const int min_frame_target =
AOMMAX(rc->min_frame_bandwidth, rc->avg_frame_bandwidth >> 5);
-// Clip the frame target to the minimum setup value.
-#if CONFIG_EXT_REFS
+ // Clip the frame target to the minimum setup value.
if (cpi->rc.is_src_frame_alt_ref) {
-#else
- if (cpi->refresh_golden_frame && rc->is_src_frame_alt_ref) {
-#endif // CONFIG_EXT_REFS
// If there is an active ARF at this location use the minimum
// bits on this frame even if it is a constructed arf.
// The active maximum quantizer insures that an appropriate
@@ -239,14 +235,10 @@
const AV1_COMMON *const cm = &cpi->common;
RATE_CONTROL *const rc = &cpi->rc;
-// Non-viewable frames are a special case and are treated as pure overhead.
-#if CONFIG_EXT_REFS
+ // Non-viewable frames are a special case and are treated as pure overhead.
// TODO(zoeliu): To further explore whether we should treat BWDREF_FRAME
// differently, since it is a no-show frame.
if (!cm->show_frame && !rc->is_bwd_ref_frame)
-#else
- if (!cm->show_frame)
-#endif // CONFIG_EXT_REFS
rc->bits_off_target -= encoded_frame_size;
else
rc->bits_off_target += rc->avg_frame_bandwidth - encoded_frame_size;
@@ -590,11 +582,9 @@
active_worst_quality =
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
- cpi->refresh_alt2_ref_frame ||
-#endif // CONFIG_EXT_REFS
- cpi->refresh_alt_ref_frame)) {
+ if (!rc->is_src_frame_alt_ref &&
+ (cpi->refresh_golden_frame || cpi->refresh_alt2_ref_frame ||
+ cpi->refresh_alt_ref_frame)) {
active_worst_quality = curr_frame == 1 ? rc->last_q[KEY_FRAME] * 5 / 4
: rc->last_q[INTER_FRAME];
} else {
@@ -933,24 +923,15 @@
int av1_frame_type_qdelta(const AV1_COMP *cpi, int rf_level, int q) {
static const double rate_factor_deltas[RATE_FACTOR_LEVELS] = {
1.00, // INTER_NORMAL
-#if CONFIG_EXT_REFS
0.80, // INTER_LOW
1.50, // INTER_HIGH
1.25, // GF_ARF_LOW
-#else
- 1.00, // INTER_HIGH
- 1.50, // GF_ARF_LOW
-#endif // CONFIG_EXT_REFS
2.00, // GF_ARF_STD
2.00, // KF_STD
};
- static const FRAME_TYPE frame_type[RATE_FACTOR_LEVELS] =
-#if CONFIG_EXT_REFS
- { INTER_FRAME, INTER_FRAME, INTER_FRAME,
- INTER_FRAME, INTER_FRAME, KEY_FRAME };
-#else
- { INTER_FRAME, INTER_FRAME, INTER_FRAME, INTER_FRAME, KEY_FRAME };
-#endif // CONFIG_EXT_REFS
+ static const FRAME_TYPE frame_type[RATE_FACTOR_LEVELS] = {
+ INTER_FRAME, INTER_FRAME, INTER_FRAME, INTER_FRAME, INTER_FRAME, KEY_FRAME
+ };
const AV1_COMMON *const cm = &cpi->common;
int qdelta =
av1_compute_qdelta_by_rate(&cpi->rc, frame_type[rf_level], q,
@@ -1020,11 +1001,9 @@
active_best_quality +=
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
- cpi->refresh_alt2_ref_frame ||
-#endif // CONFIG_EXT_REFS
- cpi->refresh_alt_ref_frame)) {
+ } else if (!rc->is_src_frame_alt_ref &&
+ (cpi->refresh_golden_frame || cpi->refresh_alt2_ref_frame ||
+ 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
// a key frame.
@@ -1044,11 +1023,7 @@
active_best_quality = active_best_quality * 15 / 16;
} else if (oxcf->rc_mode == AOM_Q) {
-#if CONFIG_EXT_REFS
if (!cpi->refresh_alt_ref_frame && !cpi->refresh_alt2_ref_frame) {
-#else
- if (!cpi->refresh_alt_ref_frame) {
-#endif // CONFIG_EXT_REFS
active_best_quality = cq_level;
} else {
active_best_quality = get_gf_active_quality(rc, q, cm->bit_depth);
@@ -1080,11 +1055,9 @@
if ((cpi->oxcf.rc_mode != AOM_Q) &&
(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
- cpi->refresh_alt2_ref_frame ||
-#endif // CONFIG_EXT_REFS
- cpi->refresh_alt_ref_frame))) {
+ (!rc->is_src_frame_alt_ref &&
+ (cpi->refresh_golden_frame || cpi->refresh_alt2_ref_frame ||
+ cpi->refresh_alt_ref_frame))) {
active_best_quality -=
(cpi->twopass.extend_minq + cpi->twopass.extend_minq_fast);
active_worst_quality += (cpi->twopass.extend_maxq / 2);
@@ -1217,21 +1190,13 @@
static void update_golden_frame_stats(AV1_COMP *cpi) {
RATE_CONTROL *const rc = &cpi->rc;
-#if CONFIG_EXT_REFS
// Update the Golden frame usage counts.
// NOTE(weitinglin): If we use show_existing_frame for an OVERLAY frame,
// only the virtual indices for the reference frame will be
// updated and cpi->refresh_golden_frame will still be zero.
if (cpi->refresh_golden_frame || rc->is_src_frame_alt_ref) {
-#else // !CONFIG_EXT_REFS
- // Update the Golden frame usage counts.
- if (cpi->refresh_golden_frame) {
-#endif // CONFIG_EXT_REFS
-
-#if CONFIG_EXT_REFS
// We will not use internal overlay frames to replace the golden frame
if (!rc->is_src_frame_ext_arf)
-#endif // CONFIG_EXT_REFS
// this frame refreshes means next frames don't unless specified by user
rc->frames_since_golden = 0;
@@ -1248,11 +1213,7 @@
// Decrement count down till next gf
if (rc->frames_till_gf_update_due > 0) rc->frames_till_gf_update_due--;
-#if CONFIG_EXT_REFS
} else if (!cpi->refresh_alt_ref_frame && !cpi->refresh_alt2_ref_frame) {
-#else
- } else if (!cpi->refresh_alt_ref_frame) {
-#endif // CONFIG_EXT_REFS
// Decrement count down till next gf
if (rc->frames_till_gf_update_due > 0) rc->frames_till_gf_update_due--;
@@ -1282,10 +1243,7 @@
ROUND_POWER_OF_TWO(3 * rc->avg_frame_qindex[KEY_FRAME] + qindex, 2);
} else {
if (!rc->is_src_frame_alt_ref &&
- !(cpi->refresh_golden_frame ||
-#if CONFIG_EXT_REFS
- cpi->refresh_alt2_ref_frame ||
-#endif // CONFIG_EXT_REFS
+ !(cpi->refresh_golden_frame || cpi->refresh_alt2_ref_frame ||
cpi->refresh_alt_ref_frame)) {
rc->last_q[INTER_FRAME] = qindex;
rc->avg_frame_qindex[INTER_FRAME] =
@@ -1307,10 +1265,7 @@
// This is used to help set quality in forced key frames to reduce popping
if ((qindex < rc->last_boosted_qindex) || (cm->frame_type == KEY_FRAME) ||
(!rc->constrained_gf_group &&
- (cpi->refresh_alt_ref_frame ||
-#if CONFIG_EXT_REFS
- cpi->refresh_alt2_ref_frame ||
-#endif // CONFIG_EXT_REFS
+ (cpi->refresh_alt_ref_frame || cpi->refresh_alt2_ref_frame ||
(cpi->refresh_golden_frame && !rc->is_src_frame_alt_ref)))) {
rc->last_boosted_qindex = qindex;
}
@@ -1337,14 +1292,10 @@
// Actual bits spent
rc->total_actual_bits += rc->projected_frame_size;
-#if CONFIG_EXT_REFS
// TODO(zoeliu): To investigate whether we should treat BWDREF_FRAME
// differently here for rc->avg_frame_bandwidth.
rc->total_target_bits +=
(cm->show_frame || rc->is_bwd_ref_frame) ? rc->avg_frame_bandwidth : 0;
-#else
- rc->total_target_bits += cm->show_frame ? rc->avg_frame_bandwidth : 0;
-#endif // CONFIG_EXT_REFS
rc->total_target_vs_actual = rc->total_actual_bits - rc->total_target_bits;
@@ -1358,13 +1309,9 @@
if (cm->frame_type == KEY_FRAME) rc->frames_since_key = 0;
-#if CONFIG_EXT_REFS
// TODO(zoeliu): To investigate whether we should treat BWDREF_FRAME
// differently here for rc->avg_frame_bandwidth.
if (cm->show_frame || rc->is_bwd_ref_frame) {
-#else
- if (cm->show_frame) {
-#endif // CONFIG_EXT_REFS
rc->frames_since_key++;
rc->frames_to_key--;
}