Refactor av1_rc_pick_q_and_bounds()
Clean up unnecessary dependency on gf_group.index.
Change-Id: Ibd2fdfa8da6ebcf3f0d5e33400edc50588340cd4
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 469e6a8..aed8250 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -3688,8 +3688,8 @@
process_tpl_stats_frame(cpi);
// Decide q and q bounds.
- *q = av1_rc_pick_q_and_bounds(cpi, cm->width, cm->height, bottom_index,
- top_index);
+ *q = av1_rc_pick_q_and_bounds(cpi, cm->width, cm->height, cpi->gf_group.index,
+ bottom_index, top_index);
if (!frame_is_intra_only(cm)) {
set_high_precision_mv(cpi, (*q) < HIGH_PRECISION_MV_QTHRESH,
@@ -4034,7 +4034,8 @@
// Now decide the use of superres based on 'q'.
int bottom_index, top_index;
const int q = av1_rc_pick_q_and_bounds(
- cpi, cpi->oxcf.width, cpi->oxcf.height, &bottom_index, &top_index);
+ cpi, cpi->oxcf.width, cpi->oxcf.height, cpi->gf_group.index,
+ &bottom_index, &top_index);
const int qthresh = (frame_is_intra_only(&cpi->common))
? oxcf->superres_kf_qthresh
@@ -4055,7 +4056,8 @@
// Now decide the use of superres based on 'q'.
int bottom_index, top_index;
const int q = av1_rc_pick_q_and_bounds(
- cpi, cpi->oxcf.width, cpi->oxcf.height, &bottom_index, &top_index);
+ cpi, cpi->oxcf.width, cpi->oxcf.height, cpi->gf_group.index,
+ &bottom_index, &top_index);
const int qthresh = 128;
if (q <= qthresh) {
diff --git a/av1/encoder/ratectrl.c b/av1/encoder/ratectrl.c
index 4a8fd26..cd70e38 100644
--- a/av1/encoder/ratectrl.c
+++ b/av1/encoder/ratectrl.c
@@ -1322,8 +1322,9 @@
}
static int rc_pick_q_and_bounds_two_pass(const AV1_COMP *cpi, int width,
- int height, int *bottom_index,
- int *top_index, int *arf_q) {
+ int height, int gf_index,
+ int *bottom_index, int *top_index,
+ int *arf_q) {
const AV1_COMMON *const cm = &cpi->common;
const RATE_CONTROL *const rc = &cpi->rc;
const AV1EncoderConfig *const oxcf = &cpi->oxcf;
@@ -1338,7 +1339,7 @@
ASSIGN_MINQ_TABLE(bit_depth, inter_minq);
const int is_intrl_arf_boost =
- gf_group->update_type[gf_group->index] == INTNL_ARF_UPDATE;
+ gf_group->update_type[gf_index] == INTNL_ARF_UPDATE;
if (frame_is_intra_only(cm)) {
const int is_fwd_kf =
@@ -1367,7 +1368,7 @@
// Constrained quality use slightly lower active best.
active_best_quality = active_best_quality * 15 / 16;
- if (gf_group->update_type[gf_group->index] == ARF_UPDATE) {
+ if (gf_group->update_type[gf_index] == ARF_UPDATE) {
const int min_boost = get_gf_high_motion_quality(q, bit_depth);
const int boost = min_boost - active_best_quality;
@@ -1386,7 +1387,7 @@
if (!cpi->refresh_alt_ref_frame && !is_intrl_arf_boost) {
active_best_quality = cq_level;
} else {
- if (gf_group->update_type[gf_group->index] == ARF_UPDATE) {
+ if (gf_group->update_type[gf_index] == ARF_UPDATE) {
active_best_quality = get_gf_active_quality(rc, q, bit_depth);
const int min_boost = get_gf_high_motion_quality(q, bit_depth);
const int boost = min_boost - active_best_quality;
@@ -1446,14 +1447,14 @@
return q;
}
-int av1_rc_pick_q_and_bounds(AV1_COMP *cpi, int width, int height,
+int av1_rc_pick_q_and_bounds(AV1_COMP *cpi, int width, int height, int gf_index,
int *bottom_index, int *top_index) {
int q;
// TODO(sarahparker) merge onepass vbr and altref q computation
// with two pass
GF_GROUP *gf_group = &cpi->gf_group;
if ((cpi->oxcf.rc_mode != AOM_Q ||
- gf_group->update_type[gf_group->index] == ARF_UPDATE) &&
+ gf_group->update_type[gf_index] == ARF_UPDATE) &&
cpi->oxcf.pass == 0) {
if (cpi->oxcf.rc_mode == AOM_CBR)
q = rc_pick_q_and_bounds_one_pass_cbr(cpi, width, height, bottom_index,
@@ -1469,10 +1470,10 @@
} else {
int arf_q = -1; // Initialize to invalid value, for sanity check later.
- q = rc_pick_q_and_bounds_two_pass(cpi, width, height, bottom_index,
- top_index, &arf_q);
+ q = rc_pick_q_and_bounds_two_pass(cpi, width, height, gf_index,
+ bottom_index, top_index, &arf_q);
}
- if (gf_group->update_type[gf_group->index] == ARF_UPDATE) cpi->rc.arf_q = q;
+ if (gf_group->update_type[gf_index] == ARF_UPDATE) cpi->rc.arf_q = q;
return q;
}
diff --git a/av1/encoder/ratectrl.h b/av1/encoder/ratectrl.h
index 32edc00..55bbf74 100644
--- a/av1/encoder/ratectrl.h
+++ b/av1/encoder/ratectrl.h
@@ -224,7 +224,7 @@
// Picks q and q bounds given the target for bits
int av1_rc_pick_q_and_bounds(struct AV1_COMP *cpi, int width, int height,
- int *bottom_index, int *top_index);
+ int gf_index, int *bottom_index, int *top_index);
// Estimates q to achieve a target bits per frame
int av1_rc_regulate_q(const struct AV1_COMP *cpi, int target_bits_per_frame,