Pass cpi as const to av1_rc_pick_q_and_bounds
Add RATE_CONTROL parameter.
The interface change will guarantee that av1_rc_pick_q_and_bounds
will only change things within RATE_CONTROL
Change-Id: If8eaa478242195bb233b1d22c7a65e362a7e3dbd
diff --git a/av1/encoder/encoder.c b/av1/encoder/encoder.c
index 7ce8392..4a186e4 100644
--- a/av1/encoder/encoder.c
+++ b/av1/encoder/encoder.c
@@ -3998,8 +3998,8 @@
}
// Decide q and q bounds.
- *q = av1_rc_pick_q_and_bounds(cpi, cm->width, cm->height, cpi->gf_group.index,
- bottom_index, top_index);
+ *q = av1_rc_pick_q_and_bounds(cpi, &cpi->rc, cm->width, cm->height,
+ cpi->gf_group.index, bottom_index, top_index);
if (!frame_is_intra_only(cm)) {
const int use_hp = cpi->common.cur_frame_force_integer_mv
@@ -4346,7 +4346,7 @@
// 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, cpi->gf_group.index,
+ cpi, &cpi->rc, cpi->oxcf.width, cpi->oxcf.height, cpi->gf_group.index,
&bottom_index, &top_index);
const int qthresh = (frame_is_intra_only(&cpi->common))
@@ -4368,7 +4368,7 @@
// 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, cpi->gf_group.index,
+ cpi, &cpi->rc, cpi->oxcf.width, cpi->oxcf.height, cpi->gf_group.index,
&bottom_index, &top_index);
const int qthresh = 128;
diff --git a/av1/encoder/ratectrl.c b/av1/encoder/ratectrl.c
index eb10ab1..d87e5ce 100644
--- a/av1/encoder/ratectrl.c
+++ b/av1/encoder/ratectrl.c
@@ -1367,12 +1367,13 @@
return q;
}
-int av1_rc_pick_q_and_bounds(AV1_COMP *cpi, int width, int height, int gf_index,
- int *bottom_index, int *top_index) {
+int av1_rc_pick_q_and_bounds(const AV1_COMP *cpi, RATE_CONTROL *rc, 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;
+ const GF_GROUP *gf_group = &cpi->gf_group;
if ((cpi->oxcf.rc_mode != AOM_Q ||
gf_group->update_type[gf_index] == ARF_UPDATE) &&
cpi->oxcf.pass == 0) {
@@ -1393,7 +1394,7 @@
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_index] == ARF_UPDATE) cpi->rc.arf_q = q;
+ if (gf_group->update_type[gf_index] == ARF_UPDATE) rc->arf_q = q;
return q;
}
diff --git a/av1/encoder/ratectrl.h b/av1/encoder/ratectrl.h
index c5541d3..83a72be 100644
--- a/av1/encoder/ratectrl.h
+++ b/av1/encoder/ratectrl.h
@@ -222,8 +222,9 @@
int *frame_over_shoot_limit);
// 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 gf_index, int *bottom_index, int *top_index);
+int av1_rc_pick_q_and_bounds(const struct AV1_COMP *cpi, RATE_CONTROL *rc,
+ int width, int height, 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,
diff --git a/av1/encoder/tpl_model.c b/av1/encoder/tpl_model.c
index d1910de..a2833e0 100644
--- a/av1/encoder/tpl_model.c
+++ b/av1/encoder/tpl_model.c
@@ -792,8 +792,9 @@
cpi->refresh_bwd_ref_frame = this_frame_params.refresh_bwd_ref_frame;
cpi->refresh_alt_ref_frame = this_frame_params.refresh_alt_ref_frame;
- gf_group->q_val[gf_index] = av1_rc_pick_q_and_bounds(
- cpi, cm->width, cm->height, gf_index, &bottom_index, &top_index);
+ gf_group->q_val[gf_index] =
+ av1_rc_pick_q_and_bounds(cpi, &cpi->rc, cm->width, cm->height, gf_index,
+ &bottom_index, &top_index);
cm->current_frame.frame_type = INTER_FRAME;
}