From ca40ca9bed87687eb0b534bf3974c95182dd29a1 Mon Sep 17 00:00:00 2001 From: Jerome Jiang Date: Wed, 8 Sep 2021 16:52:51 -0700 Subject: [PATCH] vp8 rc: always update correction factor Change-Id: Id40b9cb5a85a15fb313a2a93f14f6768259f7c15 --- vp8/encoder/onyx_if.c | 4 +++- vp8/encoder/onyx_int.h | 4 ++++ vp8/vp8_cx_iface.c | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c index 71ef057a4..57c94071b 100644 --- a/vp8/encoder/onyx_if.c +++ b/vp8/encoder/onyx_if.c @@ -1910,6 +1910,7 @@ struct VP8_COMP *vp8_create_compressor(VP8_CONFIG *oxcf) { cpi->force_maxqp = 0; cpi->frames_since_last_drop_overshoot = 0; + cpi->rt_always_update_correction_factor = 0; cpi->b_calculate_psnr = CONFIG_INTERNAL_STATS; #if CONFIG_INTERNAL_STATS @@ -4445,7 +4446,8 @@ static void encode_frame_to_data_rate(VP8_COMP *cpi, size_t *size, } } - if (!active_worst_qchanged) vp8_update_rate_correction_factors(cpi, 2); + if (cpi->rt_always_update_correction_factor || !active_worst_qchanged) + vp8_update_rate_correction_factors(cpi, 2); cpi->last_q[cm->frame_type] = cm->base_qindex; diff --git a/vp8/encoder/onyx_int.h b/vp8/encoder/onyx_int.h index b96f9b1dc..a29994a13 100644 --- a/vp8/encoder/onyx_int.h +++ b/vp8/encoder/onyx_int.h @@ -702,6 +702,10 @@ typedef struct VP8_COMP { int use_roi_static_threshold; int ext_refresh_frame_flags_pending; + + // Always update correction factor used for rate control after each frame for + // realtime encoding. + int rt_always_update_correction_factor; } VP8_COMP; void vp8_initialize_enc(void); diff --git a/vp8/vp8_cx_iface.c b/vp8/vp8_cx_iface.c index 20e18aee7..893b7a513 100644 --- a/vp8/vp8_cx_iface.c +++ b/vp8/vp8_cx_iface.c @@ -611,6 +611,7 @@ static vpx_codec_err_t ctrl_set_rtc_external_ratectrl(vpx_codec_alg_priv_t *ctx, const unsigned int data = CAST(VP8E_SET_GF_CBR_BOOST_PCT, args); if (data) { cpi->cyclic_refresh_mode_enabled = 0; + cpi->rt_always_update_correction_factor = 1; } return VPX_CODEC_OK; } -- 2.40.0