summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--vp9/encoder/vp9_firstpass.c7
-rw-r--r--vp9/encoder/vp9_onyx_if.c11
-rw-r--r--vp9/encoder/vp9_onyx_int.h2
-rw-r--r--vp9/encoder/vp9_ratectrl.c38
4 files changed, 22 insertions, 36 deletions
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index 16f5cb1b5..726b804ad 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -904,6 +904,7 @@ static int get_twopass_worst_quality(const VP9_COMP *cpi,
const FIRSTPASS_STATS *stats,
int section_target_bandwidth) {
const RATE_CONTROL *const rc = &cpi->rc;
+ const VP9_CONFIG *const oxcf = &cpi->oxcf;
if (section_target_bandwidth <= 0) {
return rc->worst_quality; // Highest value allowed
@@ -911,7 +912,7 @@ static int get_twopass_worst_quality(const VP9_COMP *cpi,
const int num_mbs = cpi->common.MBs;
const double section_err = stats->coded_error / stats->count;
const double err_per_mb = section_err / num_mbs;
- const double speed_term = 1.0 + 0.04 * cpi->oxcf.speed;
+ const double speed_term = 1.0 + 0.04 * oxcf->speed;
const int target_norm_bits_per_mb = ((uint64_t)section_target_bandwidth <<
BPER_MB_NORMBITS) / num_mbs;
int q;
@@ -928,8 +929,8 @@ static int get_twopass_worst_quality(const VP9_COMP *cpi,
}
// Restriction on active max q for constrained quality mode.
- if (cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY)
- q = MAX(q, cpi->cq_target_quality);
+ if (oxcf->end_usage == USAGE_CONSTRAINED_QUALITY)
+ q = MAX(q, oxcf->cq_level);
return q;
}
}
diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c
index e869e8fa2..42ed11d0a 100644
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -788,10 +788,6 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9_CONFIG *oxcf) {
rc->worst_quality = cpi->oxcf.worst_allowed_q;
rc->best_quality = cpi->oxcf.best_allowed_q;
- // active values should only be modified if out of new range
-
- cpi->cq_target_quality = cpi->oxcf.cq_level;
-
cm->interp_filter = DEFAULT_INTERP_FILTER;
cm->display_width = cpi->oxcf.width;
@@ -1695,6 +1691,7 @@ static int recode_loop_test(const VP9_COMP *cpi,
int q, int maxq, int minq) {
const VP9_COMMON *const cm = &cpi->common;
const RATE_CONTROL *const rc = &cpi->rc;
+ const VP9_CONFIG *const oxcf = &cpi->oxcf;
int force_recode = 0;
// Special case trap if maximum allowed frame size exceeded.
@@ -1712,10 +1709,10 @@ static int recode_loop_test(const VP9_COMP *cpi,
if ((rc->projected_frame_size > high_limit && q < maxq) ||
(rc->projected_frame_size < low_limit && q > minq)) {
force_recode = 1;
- } else if (cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY) {
+ } else if (oxcf->end_usage == USAGE_CONSTRAINED_QUALITY) {
// Deal with frame undershoot and whether or not we are
// below the automatically set cq level.
- if (q > cpi->cq_target_quality &&
+ if (q > oxcf->cq_level &&
rc->projected_frame_size < ((rc->this_frame_target * 7) >> 3)) {
force_recode = 1;
}
@@ -1890,7 +1887,7 @@ static void output_frame_level_debug_stats(VP9_COMP *cpi) {
(double)vp9_dc_quant(cm->base_qindex, 0) / 4.0,
cpi->rc.avg_q,
vp9_convert_qindex_to_q(cpi->rc.ni_av_qi),
- vp9_convert_qindex_to_q(cpi->cq_target_quality),
+ vp9_convert_qindex_to_q(cpi->oxcf.cq_level),
cpi->refresh_last_frame, cpi->refresh_golden_frame,
cpi->refresh_alt_ref_frame, cm->frame_type, cpi->rc.gfu_boost,
cpi->twopass.bits_left,
diff --git a/vp9/encoder/vp9_onyx_int.h b/vp9/encoder/vp9_onyx_int.h
index 423cf2f40..5f59f1dbb 100644
--- a/vp9/encoder/vp9_onyx_int.h
+++ b/vp9/encoder/vp9_onyx_int.h
@@ -394,8 +394,6 @@ typedef struct VP9_COMP {
RATE_CONTROL rc;
- int cq_target_quality;
-
vp9_coeff_count coef_counts[TX_SIZES][PLANE_TYPES];
vp9_coeff_probs_model frame_coef_probs[TX_SIZES][PLANE_TYPES];
diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c
index c073a034e..ae7713570 100644
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -613,6 +613,7 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi,
const VP9_COMMON *const cm = &cpi->common;
const RATE_CONTROL *const rc = &cpi->rc;
const VP9_CONFIG *const oxcf = &cpi->oxcf;
+ const int cq_level = oxcf->cq_level;
int active_best_quality;
int active_worst_quality = calc_active_worst_quality_one_pass_vbr(cpi);
int q;
@@ -671,8 +672,8 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi,
}
// For constrained quality dont allow Q less than the cq level
if (oxcf->end_usage == USAGE_CONSTRAINED_QUALITY) {
- if (q < cpi->cq_target_quality)
- q = cpi->cq_target_quality;
+ if (q < cq_level)
+ q = cq_level;
if (rc->frames_since_key > 1) {
active_best_quality = get_active_quality(q, rc->gfu_boost,
gf_low, gf_high,
@@ -689,7 +690,7 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi,
} else if (oxcf->end_usage == USAGE_CONSTANT_QUALITY) {
if (!cpi->refresh_alt_ref_frame) {
- active_best_quality = cpi->cq_target_quality;
+ active_best_quality = cq_level;
} else {
if (rc->frames_since_key > 1) {
active_best_quality = get_active_quality(
@@ -708,7 +709,7 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi,
}
} else {
if (oxcf->end_usage == USAGE_CONSTANT_QUALITY) {
- active_best_quality = cpi->cq_target_quality;
+ active_best_quality = cq_level;
} else {
// Use the lower of active_worst_quality and recent/average Q.
if (cm->current_video_frame > 1)
@@ -718,14 +719,8 @@ static int rc_pick_q_and_bounds_one_pass_vbr(const VP9_COMP *cpi,
// For the constrained quality mode we don't want
// q to fall below the cq level.
if ((oxcf->end_usage == USAGE_CONSTRAINED_QUALITY) &&
- (active_best_quality < cpi->cq_target_quality)) {
- // If we are strongly undershooting the target rate in the last
- // frames then use the user passed in cq value not the auto
- // cq value.
- if (rc->rolling_actual_bits < rc->min_frame_bandwidth)
- active_best_quality = oxcf->cq_level;
- else
- active_best_quality = cpi->cq_target_quality;
+ (active_best_quality < cq_level)) {
+ active_best_quality = cq_level;
}
}
}
@@ -807,6 +802,7 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi,
const VP9_COMMON *const cm = &cpi->common;
const RATE_CONTROL *const rc = &cpi->rc;
const VP9_CONFIG *const oxcf = &cpi->oxcf;
+ const int cq_level = oxcf->cq_level;
int active_best_quality;
int active_worst_quality = cpi->twopass.active_worst_quality;
int q;
@@ -867,8 +863,8 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi,
}
// For constrained quality dont allow Q less than the cq level
if (oxcf->end_usage == USAGE_CONSTRAINED_QUALITY) {
- if (q < cpi->cq_target_quality)
- q = cpi->cq_target_quality;
+ if (q < cq_level)
+ q = cq_level;
if (rc->frames_since_key > 1) {
active_best_quality = get_active_quality(q, rc->gfu_boost,
gf_low, gf_high,
@@ -885,7 +881,7 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi,
} else if (oxcf->end_usage == USAGE_CONSTANT_QUALITY) {
if (!cpi->refresh_alt_ref_frame) {
- active_best_quality = cpi->cq_target_quality;
+ active_best_quality = cq_level;
} else {
if (rc->frames_since_key > 1) {
active_best_quality = get_active_quality(
@@ -904,21 +900,15 @@ static int rc_pick_q_and_bounds_two_pass(const VP9_COMP *cpi,
}
} else {
if (oxcf->end_usage == USAGE_CONSTANT_QUALITY) {
- active_best_quality = cpi->cq_target_quality;
+ active_best_quality = cq_level;
} else {
active_best_quality = inter_minq[active_worst_quality];
// For the constrained quality mode we don't want
// q to fall below the cq level.
if ((oxcf->end_usage == USAGE_CONSTRAINED_QUALITY) &&
- (active_best_quality < cpi->cq_target_quality)) {
- // If we are strongly undershooting the target rate in the last
- // frames then use the user passed in cq value not the auto
- // cq value.
- if (rc->rolling_actual_bits < rc->min_frame_bandwidth)
- active_best_quality = oxcf->cq_level;
- else
- active_best_quality = cpi->cq_target_quality;
+ (active_best_quality < cq_level)) {
+ active_best_quality = cq_level;
}
}
}