summaryrefslogtreecommitdiff
path: root/vp9/encoder/vp9_ratectrl.c
diff options
context:
space:
mode:
authorGuillaume Martres <smarter3@gmail.com>2014-07-04 17:57:44 +0200
committerGuillaume Martres <smarter3@gmail.com>2014-07-06 18:49:46 +0200
commit44666b7ce38122b3d20520a177291e960a02058f (patch)
treed2e2ec9a15d1a4f7203257181cd6a8e64c2fd076 /vp9/encoder/vp9_ratectrl.c
parent14f570f6c361c626d0e369eaa93a38f820a2c46d (diff)
downloadlibvpx-44666b7ce38122b3d20520a177291e960a02058f.tar
libvpx-44666b7ce38122b3d20520a177291e960a02058f.tar.gz
libvpx-44666b7ce38122b3d20520a177291e960a02058f.tar.bz2
libvpx-44666b7ce38122b3d20520a177291e960a02058f.zip
vp9_ratectrl.c: refactor get_active_quality usage
Change-Id: I53db06acf5bc434f9584136b848322f5870300b3
Diffstat (limited to 'vp9/encoder/vp9_ratectrl.c')
-rw-r--r--vp9/encoder/vp9_ratectrl.c60
1 files changed, 22 insertions, 38 deletions
diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c
index e1109838c..c0b0e0fd6 100644
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -424,6 +424,16 @@ static int get_active_quality(int q, int gfu_boost, int low, int high,
}
}
+static int get_kf_active_quality(const RATE_CONTROL *const rc, int q) {
+ return get_active_quality(q, rc->kf_boost, kf_low, kf_high,
+ kf_low_motion_minq, kf_high_motion_minq);
+}
+
+static int get_gf_active_quality(const RATE_CONTROL *const rc, int q) {
+ return get_active_quality(q, rc->gfu_boost, gf_low, gf_high,
+ arfgf_low_motion_minq, arfgf_high_motion_minq);
+}
+
static int calc_active_worst_quality_one_pass_vbr(const VP9_COMP *cpi) {
const RATE_CONTROL *const rc = &cpi->rc;
const unsigned int curr_frame = cpi->common.current_video_frame;
@@ -523,11 +533,8 @@ static int rc_pick_q_and_bounds_one_pass_cbr(const VP9_COMP *cpi,
double q_adj_factor = 1.0;
double q_val;
- active_best_quality = get_active_quality(rc->avg_frame_qindex[KEY_FRAME],
- rc->kf_boost,
- kf_low, kf_high,
- kf_low_motion_minq,
- kf_high_motion_minq);
+ active_best_quality =
+ get_kf_active_quality(rc, rc->avg_frame_qindex[KEY_FRAME]);
// Allow somewhat lower kf minq with small image formats.
if ((cm->width * cm->height) <= (352 * 288)) {
@@ -552,9 +559,7 @@ static int rc_pick_q_and_bounds_one_pass_cbr(const VP9_COMP *cpi,
} else {
q = active_worst_quality;
}
- active_best_quality = get_active_quality(
- q, rc->gfu_boost, gf_low, gf_high,
- arfgf_low_motion_minq, arfgf_high_motion_minq);
+ active_best_quality = get_gf_active_quality(rc, q);
} else {
// Use the lower of active_worst_quality and recent/average Q.
if (cm->current_video_frame > 1) {
@@ -657,11 +662,8 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi,
double q_adj_factor = 1.0;
double q_val;
- active_best_quality = get_active_quality(rc->avg_frame_qindex[KEY_FRAME],
- rc->kf_boost,
- kf_low, kf_high,
- kf_low_motion_minq,
- kf_high_motion_minq);
+ active_best_quality =
+ get_kf_active_quality(rc, rc->avg_frame_qindex[KEY_FRAME]);
// Allow somewhat lower kf minq with small image formats.
if ((cm->width * cm->height) <= (352 * 288)) {
@@ -690,10 +692,7 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi,
if (q < cq_level)
q = cq_level;
- active_best_quality = get_active_quality(q, rc->gfu_boost,
- gf_low, gf_high,
- arfgf_low_motion_minq,
- arfgf_high_motion_minq);
+ active_best_quality = get_gf_active_quality(rc, q);
// Constrained quality use slightly lower active best.
active_best_quality = active_best_quality * 15 / 16;
@@ -702,14 +701,10 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi,
if (!cpi->refresh_alt_ref_frame) {
active_best_quality = cq_level;
} else {
- active_best_quality = get_active_quality(
- q, rc->gfu_boost, gf_low, gf_high,
- arfgf_low_motion_minq, arfgf_high_motion_minq);
+ active_best_quality = get_gf_active_quality(rc, q);
}
} else {
- active_best_quality = get_active_quality(
- q, rc->gfu_boost, gf_low, gf_high,
- arfgf_low_motion_minq, arfgf_high_motion_minq);
+ active_best_quality = get_gf_active_quality(rc, q);
}
} else {
if (oxcf->rc_mode == VPX_Q) {
@@ -810,11 +805,7 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi,
double q_adj_factor = 1.0;
double q_val;
// Baseline value derived from cpi->active_worst_quality and kf boost.
- active_best_quality = get_active_quality(active_worst_quality,
- rc->kf_boost,
- kf_low, kf_high,
- kf_low_motion_minq,
- kf_high_motion_minq);
+ active_best_quality = get_kf_active_quality(rc, active_worst_quality);
// Allow somewhat lower kf minq with small image formats.
if ((cm->width * cm->height) <= (352 * 288)) {
@@ -846,10 +837,7 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi,
if (q < cq_level)
q = cq_level;
- active_best_quality = get_active_quality(q, rc->gfu_boost,
- gf_low, gf_high,
- arfgf_low_motion_minq,
- arfgf_high_motion_minq);
+ active_best_quality = get_gf_active_quality(rc, q);
// Constrained quality use slightly lower active best.
active_best_quality = active_best_quality * 15 / 16;
@@ -858,14 +846,10 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi,
if (!cpi->refresh_alt_ref_frame) {
active_best_quality = cq_level;
} else {
- active_best_quality = get_active_quality(
- q, rc->gfu_boost, gf_low, gf_high,
- arfgf_low_motion_minq, arfgf_high_motion_minq);
+ active_best_quality = get_gf_active_quality(rc, q);
}
} else {
- active_best_quality = get_active_quality(
- q, rc->gfu_boost, gf_low, gf_high,
- arfgf_low_motion_minq, arfgf_high_motion_minq);
+ active_best_quality = get_gf_active_quality(rc, q);
}
} else {
if (oxcf->rc_mode == VPX_Q) {