Use round for RC calcutions in cyclic_refresh
This fixes the mismatch found in test behavior
between mac pro arm and linux x86_64.
Bug:aomedia:3579
Change-Id: I9ad2fc0c43edae4b9505d7a46336820a72ff6442
(cherry picked from commit 96958d1ecc073f7deb84c99e675437a7a6457566)
diff --git a/av1/encoder/aq_cyclicrefresh.c b/av1/encoder/aq_cyclicrefresh.c
index 1aa8dde..2ef6cba 100644
--- a/av1/encoder/aq_cyclicrefresh.c
+++ b/av1/encoder/aq_cyclicrefresh.c
@@ -103,15 +103,15 @@
weight_segment2 = 0;
}
// Take segment weighted average for estimated bits.
- const int estimated_bits =
- (int)((1.0 - weight_segment1 - weight_segment2) *
- av1_estimate_bits_at_q(cpi, base_qindex, correction_factor) +
- weight_segment1 *
- av1_estimate_bits_at_q(cpi, base_qindex + cr->qindex_delta[1],
- correction_factor) +
- weight_segment2 *
- av1_estimate_bits_at_q(cpi, base_qindex + cr->qindex_delta[2],
- correction_factor));
+ const int estimated_bits = (int)round(
+ (1.0 - weight_segment1 - weight_segment2) *
+ av1_estimate_bits_at_q(cpi, base_qindex, correction_factor) +
+ weight_segment1 *
+ av1_estimate_bits_at_q(cpi, base_qindex + cr->qindex_delta[1],
+ correction_factor) +
+ weight_segment2 *
+ av1_estimate_bits_at_q(cpi, base_qindex + cr->qindex_delta[2],
+ correction_factor));
return estimated_bits;
}
@@ -139,13 +139,13 @@
int deltaq = compute_deltaq(cpi, i, cr->rate_ratio_qdelta);
const int accurate_estimate = cpi->sf.hl_sf.accurate_bit_estimate;
// Take segment weighted average for bits per mb.
- bits_per_mb =
- (int)((1.0 - weight_segment) *
- av1_rc_bits_per_mb(cpi, cm->current_frame.frame_type, i,
- correction_factor, accurate_estimate) +
- weight_segment * av1_rc_bits_per_mb(
- cpi, cm->current_frame.frame_type, i + deltaq,
- correction_factor, accurate_estimate));
+ bits_per_mb = (int)round(
+ (1.0 - weight_segment) *
+ av1_rc_bits_per_mb(cpi, cm->current_frame.frame_type, i,
+ correction_factor, accurate_estimate) +
+ weight_segment * av1_rc_bits_per_mb(cpi, cm->current_frame.frame_type,
+ i + deltaq, correction_factor,
+ accurate_estimate));
return bits_per_mb;
}