Commit d23e3392 authored by Deb Mukherjee's avatar Deb Mukherjee

Removes active_worst_quality feedback

Removes certain cases of feedback of active_worst_quality,
and removes it from the RATE_CONTROL structure. Now active
worst quality is expected to be computed locally in the
q picking function during the encode.
Making temporal filter strength depend on avg_frame_qindex
rather than on active_worst_quality actually improves
performance esp. for yt.
derf: +0.038%
yt: +0.359%

Change-Id: I1fe5a343034b55af9322289165321f00ac0827b1
parent 992500b8
......@@ -2275,15 +2275,14 @@ void vp9_rc_get_second_pass_params(VP9_COMP *cpi) {
vp9_clear_system_state();
if (cpi->oxcf.end_usage == USAGE_CONSTANT_QUALITY) {
rc->active_worst_quality = cpi->oxcf.cq_level;
twopass->active_worst_quality = cpi->oxcf.cq_level;
} else if (cm->current_video_frame == 0) {
// Special case code for first frame.
const int section_target_bandwidth = (int)(twopass->bits_left /
frames_left);
const int tmp_q = vp9_twopass_worst_quality(cpi, &twopass->total_left_stats,
section_target_bandwidth);
rc->active_worst_quality = tmp_q;
twopass->active_worst_quality = tmp_q;
rc->ni_av_qi = tmp_q;
rc->avg_q = vp9_convert_qindex_to_q(tmp_q);
......
......@@ -76,6 +76,8 @@ struct twopass_rc {
int kf_zeromotion_pct;
int gf_zeromotion_pct;
int active_worst_quality;
};
struct VP9_COMP;
......
......@@ -1155,10 +1155,9 @@ static void init_layer_context(VP9_COMP *const cpi) {
++temporal_layer) {
LAYER_CONTEXT *const lc = &cpi->svc.layer_context[temporal_layer];
RATE_CONTROL *const lrc = &lc->rc;
lrc->active_worst_quality = q_trans[oxcf->worst_allowed_q];
lrc->avg_frame_qindex[INTER_FRAME] = lrc->active_worst_quality;
lrc->last_q[INTER_FRAME] = lrc->active_worst_quality;
lrc->ni_av_qi = lrc->active_worst_quality;
lrc->avg_frame_qindex[INTER_FRAME] = q_trans[oxcf->worst_allowed_q];
lrc->last_q[INTER_FRAME] = q_trans[oxcf->worst_allowed_q];
lrc->ni_av_qi = q_trans[oxcf->worst_allowed_q];
lrc->total_actual_bits = 0;
lrc->total_target_vs_actual = 0;
lrc->ni_tot_qi = 0;
......@@ -1203,7 +1202,6 @@ static void update_layer_context_change_config(VP9_COMP *const cpi,
// Update qp-related quantities.
lrc->worst_quality = rc->worst_quality;
lrc->best_quality = rc->best_quality;
lrc->active_worst_quality = rc->active_worst_quality;
}
}
......@@ -1302,8 +1300,6 @@ static void init_config(VP9_PTR ptr, VP9_CONFIG *oxcf) {
vp9_change_config(ptr, oxcf);
// Initialize active best and worst q and average q values.
cpi->rc.active_worst_quality = cpi->oxcf.worst_allowed_q;
if (cpi->pass == 0 && cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) {
cpi->rc.avg_frame_qindex[0] = cpi->oxcf.worst_allowed_q;
cpi->rc.avg_frame_qindex[1] = cpi->oxcf.worst_allowed_q;
......@@ -1449,9 +1445,6 @@ void vp9_change_config(VP9_PTR ptr, VP9_CONFIG *oxcf) {
cpi->rc.best_quality = cpi->oxcf.best_allowed_q;
// active values should only be modified if out of new range
cpi->rc.active_worst_quality = clamp(cpi->rc.active_worst_quality,
cpi->rc.best_quality,
cpi->rc.worst_quality);
cpi->cq_target_quality = cpi->oxcf.cq_level;
......@@ -2727,7 +2720,7 @@ static void output_frame_level_debug_stats(VP9_COMP *cpi) {
if (cpi->twopass.total_left_stats.coded_error != 0.0)
fprintf(f, "%10u %10d %10d %10d %10d %10d "
"%10"PRId64" %10"PRId64" %10d "
"%7.2lf %7.2lf %7.2lf %7.2lf %7.2lf %7.2lf"
"%7.2lf %7.2lf %7.2lf %7.2lf %7.2lf"
"%6d %6d %5d %5d %5d "
"%10"PRId64" %10.3lf"
"%10lf %8u %10d %10d %10d\n",
......@@ -2740,7 +2733,7 @@ static void output_frame_level_debug_stats(VP9_COMP *cpi) {
cpi->rc.total_actual_bits, cm->base_qindex,
vp9_convert_qindex_to_q(cm->base_qindex),
(double)vp9_dc_quant(cm->base_qindex, 0) / 4.0,
vp9_convert_qindex_to_q(cpi->rc.active_worst_quality), cpi->rc.avg_q,
cpi->rc.avg_q,
vp9_convert_qindex_to_q(cpi->rc.ni_av_qi),
vp9_convert_qindex_to_q(cpi->cq_target_quality),
cpi->refresh_last_frame, cpi->refresh_golden_frame,
......@@ -3209,9 +3202,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
#endif
// Decide q and q bounds.
q = vp9_rc_pick_q_and_adjust_q_bounds(cpi,
&bottom_index,
&top_index);
q = vp9_rc_pick_q_and_bounds(cpi, &bottom_index, &top_index);
if (!frame_is_intra_only(cm)) {
cm->interp_filter = DEFAULT_INTERP_FILTER;
......
This diff is collapsed.
......@@ -73,7 +73,6 @@ typedef struct {
int total_target_vs_actual; // debug stats
int worst_quality;
int active_worst_quality;
int best_quality;
// int active_best_quality;
} RATE_CONTROL;
......@@ -141,9 +140,9 @@ void vp9_rc_compute_frame_size_bounds(const struct VP9_COMP *cpi,
int *frame_over_shoot_limit);
// Picks q and q bounds given the target for bits
int vp9_rc_pick_q_and_adjust_q_bounds(const struct VP9_COMP *cpi,
int *bottom_index,
int *top_index);
int vp9_rc_pick_q_and_bounds(const struct VP9_COMP *cpi,
int *bottom_index,
int *top_index);
// Estimates q to achieve a target bits per frame
int vp9_rc_regulate_q(const struct VP9_COMP *cpi, int target_bits_per_frame,
......
......@@ -520,11 +520,16 @@ void vp9_configure_arnr_filter(VP9_COMP *cpi,
cpi->active_arnr_frames = frames_bwd + 1 + frames_fwd;
// Adjust the strength based on active max q
q = ((int)vp9_convert_qindex_to_q(cpi->rc.active_worst_quality) >> 1);
if (q > 8) {
if (cpi->common.current_video_frame > 1)
q = ((int)vp9_convert_qindex_to_q(
cpi->rc.avg_frame_qindex[INTER_FRAME]));
else
q = ((int)vp9_convert_qindex_to_q(
cpi->rc.avg_frame_qindex[KEY_FRAME]));
if (q > 16) {
cpi->active_arnr_strength = cpi->oxcf.arnr_strength;
} else {
cpi->active_arnr_strength = cpi->oxcf.arnr_strength - (8 - q);
cpi->active_arnr_strength = cpi->oxcf.arnr_strength - ((16 - q) / 2);
if (cpi->active_arnr_strength < 0)
cpi->active_arnr_strength = 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment