Refactoring to facilitate rate control change Change-Id: I0ccc128c653fe2c8709a163493c6f6c6dea6eaaa
diff --git a/av1/encoder/aq_cyclicrefresh.c b/av1/encoder/aq_cyclicrefresh.c index f263f38..b3f8247 100644 --- a/av1/encoder/aq_cyclicrefresh.c +++ b/av1/encoder/aq_cyclicrefresh.c
@@ -88,9 +88,7 @@ int av1_cyclic_refresh_estimate_bits_at_q(const AV1_COMP *cpi, double correction_factor) { const AV1_COMMON *const cm = &cpi->common; - const FRAME_TYPE frame_type = cm->current_frame.frame_type; const int base_qindex = cm->quant_params.base_qindex; - const int bit_depth = cm->seq_params->bit_depth; const CYCLIC_REFRESH *const cr = cpi->cyclic_refresh; const int mbs = cm->mi_params.MBs; const int num4x4bl = mbs << 4; @@ -107,17 +105,13 @@ // Take segment weighted average for estimated bits. const int estimated_bits = (int)((1.0 - weight_segment1 - weight_segment2) * - av1_estimate_bits_at_q(frame_type, base_qindex, mbs, - correction_factor, bit_depth, - cpi->is_screen_content_type) + - weight_segment1 * av1_estimate_bits_at_q( - frame_type, base_qindex + cr->qindex_delta[1], - mbs, correction_factor, bit_depth, - cpi->is_screen_content_type) + - weight_segment2 * av1_estimate_bits_at_q( - frame_type, base_qindex + cr->qindex_delta[2], - mbs, correction_factor, bit_depth, - cpi->is_screen_content_type)); + 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; }
diff --git a/av1/encoder/ratectrl.c b/av1/encoder/ratectrl.c index a455bd2..b735cf9 100644 --- a/av1/encoder/ratectrl.c +++ b/av1/encoder/ratectrl.c
@@ -175,9 +175,13 @@ return (int)(enumerator * correction_factor / q); } -int av1_estimate_bits_at_q(FRAME_TYPE frame_type, int q, int mbs, - double correction_factor, aom_bit_depth_t bit_depth, - const int is_screen_content_type) { +int av1_estimate_bits_at_q(const AV1_COMP *cpi, int q, + double correction_factor) { + const AV1_COMMON *const cm = &cpi->common; + const FRAME_TYPE frame_type = cm->current_frame.frame_type; + const aom_bit_depth_t bit_depth = cm->seq_params->bit_depth; + const int mbs = cm->mi_params.MBs; + const int is_screen_content_type = cpi->is_screen_content_type; const int bpm = (int)(av1_rc_bits_per_mb(frame_type, q, correction_factor, bit_depth, is_screen_content_type)); return AOMMAX(FRAME_OVERHEAD_BITS, @@ -658,7 +662,6 @@ double rate_correction_factor = get_rate_correction_factor(cpi, width, height); double adjustment_limit; - const int MBs = av1_get_MBs(width, height); int projected_size_based_on_q = 0; int cyclic_refresh_active = cpi->oxcf.q_cfg.aq_mode == CYCLIC_REFRESH_AQ && cpi->common.seg.enabled; @@ -676,9 +679,7 @@ av1_cyclic_refresh_estimate_bits_at_q(cpi, rate_correction_factor); } else { projected_size_based_on_q = av1_estimate_bits_at_q( - cm->current_frame.frame_type, cm->quant_params.base_qindex, MBs, - rate_correction_factor, cm->seq_params->bit_depth, - cpi->is_screen_content_type); + cpi, cm->quant_params.base_qindex, rate_correction_factor); } // Work out a size correction factor. if (projected_size_based_on_q > FRAME_OVERHEAD_BITS)
diff --git a/av1/encoder/ratectrl.h b/av1/encoder/ratectrl.h index 5f8b7bd..ffe9b8c 100644 --- a/av1/encoder/ratectrl.h +++ b/av1/encoder/ratectrl.h
@@ -555,9 +555,8 @@ void av1_rc_init(const struct AV1EncoderConfig *oxcf, RATE_CONTROL *rc); -int av1_estimate_bits_at_q(FRAME_TYPE frame_kind, int q, int mbs, - double correction_factor, aom_bit_depth_t bit_depth, - const int is_screen_content_type); +int av1_estimate_bits_at_q(const struct AV1_COMP *cpi, int q, + double correction_factor); double av1_convert_qindex_to_q(int qindex, aom_bit_depth_t bit_depth);