RC: Add flag indicating whether to use delta q RC library only calculates delta q for key, golden and regular ARF. To avoid apply delta q data from RC for intermediate ARF, a flag is added to avoid freeing / reallocating memory for delta q repeatedly. This flag will be set by RC Change-Id: I63d0315ff34dec4e2756227cff39b684c4732b76
diff --git a/aom/aom_ext_ratectrl.h b/aom/aom_ext_ratectrl.h index dfc9c53..88598a3 100644 --- a/aom/aom_ext_ratectrl.h +++ b/aom/aom_ext_ratectrl.h
@@ -159,6 +159,11 @@ typedef struct aom_rc_encodeframe_decision { int q_index; /**< Required: Quantizer step index [0..255]*/ int rdmult; /**< Required: Frame level Lagrangian multiplier*/ + // Whether per-superblock delta Q should be used. + // The rate control model should set the value pointed to by this member + // to 1 if per-superblock delta-Q is used for this frame, or 0 otherwise. + // This is a pointer to the flag in cpi->ext_ratectrl. + int *use_delta_q; /*! * Optional: Superblock quantization parameters * It is zero initialized by default. It will be set for key and ARF frames
diff --git a/av1/encoder/av1_ext_ratectrl.h b/av1/encoder/av1_ext_ratectrl.h index 4cab2f0..bf7c4a9 100644 --- a/av1/encoder/av1_ext_ratectrl.h +++ b/av1/encoder/av1_ext_ratectrl.h
@@ -20,6 +20,11 @@ typedef struct AOM_EXT_RATECTRL { int ready; int ext_rdmult; + // Whether per-superblock delta Q should be used. This is set on frame basis. + // Key, golden and regular ARF frames use delta Q. All other frames do not. + // This flag is added so the sb_params_list array doesn't have to be freed + // and allocated repeatedly. + int use_delta_q; aom_rc_model_t model; aom_rc_funcs_t funcs; aom_rc_config_t ratectrl_config;
diff --git a/av1/encoder/encodeframe.c b/av1/encoder/encodeframe.c index 76c73ac..5846e03 100644 --- a/av1/encoder/encodeframe.c +++ b/av1/encoder/encodeframe.c
@@ -321,9 +321,11 @@ (cpi->ext_ratectrl.funcs.rc_type & AOM_RC_QP) != 0 && cpi->ext_ratectrl.funcs.get_encodeframe_decision != NULL && cpi->ext_ratectrl.sb_params_list != NULL) { - const int q_index = cpi->ext_ratectrl.sb_params_list[sb_index].q_index; - if (q_index != AOM_DEFAULT_Q) { - current_qindex = q_index; + if (cpi->ext_ratectrl.use_delta_q) { + const int q_index = cpi->ext_ratectrl.sb_params_list[sb_index].q_index; + if (q_index != AOM_DEFAULT_Q) { + current_qindex = q_index; + } } } else if (cpi->oxcf.q_cfg.deltaq_mode == DELTA_Q_PERCEPTUAL) { if (DELTA_Q_PERCEPTUAL_MODULATION == 1) {
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c index b1c02e4..85895ad 100644 --- a/av1/encoder/encoder.c +++ b/av1/encoder/encoder.c
@@ -3460,6 +3460,7 @@ sb_rows * sb_cols, sizeof(*cpi->ext_ratectrl.sb_params_list))); } encode_frame_decision.sb_params_list = cpi->ext_ratectrl.sb_params_list; + encode_frame_decision.use_delta_q = &cpi->ext_ratectrl.use_delta_q; codec_status = av1_extrc_get_encodeframe_decision( &cpi->ext_ratectrl, cpi->gf_frame_index, &encode_frame_decision); if (codec_status != AOM_CODEC_OK) {