ref: 3c715863da0afdc42fb44c9f6d04e983d25a8de7
parent: 550707b9e1f7184523a4b574a0c536fc444b569b
parent: b660f723b4ffe597338e5a6b747f9ce25ebaae8a
author: Marco <[email protected]>
date: Tue Nov 18 06:22:18 EST 2014
Merge "Modify active_worst_quality setting for one pass CBR."
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -563,18 +563,23 @@
const VP9_COMMON *const cm = &cpi->common;
const RATE_CONTROL *rc = &cpi->rc;
// Buffer level below which we push active_worst to worst_quality.
- int64_t critical_level = rc->optimal_buffer_level >> 2;
+ int64_t critical_level = rc->optimal_buffer_level >> 3;
int64_t buff_lvl_step = 0;
int adjustment = 0;
int active_worst_quality;
+ int ambient_qp;
if (cm->frame_type == KEY_FRAME)
- return rc->worst_quality * 4 / 5;
- if (cm->current_video_frame > 1)
- active_worst_quality = MIN(rc->worst_quality,
- rc->avg_frame_qindex[INTER_FRAME] * 5 / 4);
- else
- active_worst_quality = MIN(rc->worst_quality,
- rc->avg_frame_qindex[KEY_FRAME] * 3 / 2);
+ return rc->worst_quality;
+ // For ambient_qp we use minimum of avg_frame_qindex[KEY_FRAME/INTER_FRAME]
+ // for the first few frames following key frame. These are both initialized
+ // to worst_quality and updated with (3/4, 1/4) average in postencode_update.
+ // So for first few frames following key, the qp of that key frame is weighted
+ // into the active_worst_quality setting.
+ ambient_qp = (cm->current_video_frame < 5) ?
+ MIN(rc->avg_frame_qindex[INTER_FRAME], rc->avg_frame_qindex[KEY_FRAME]) :
+ rc->avg_frame_qindex[INTER_FRAME];
+ active_worst_quality = MIN(rc->worst_quality,
+ ambient_qp * 5 / 4);
if (rc->buffer_level > rc->optimal_buffer_level) {
// Adjust down.
// Maximum limit for down adjustment, ~30%.
@@ -592,12 +597,11 @@
if (critical_level) {
buff_lvl_step = (rc->optimal_buffer_level - critical_level);
if (buff_lvl_step) {
- adjustment =
- (int)((rc->worst_quality - rc->avg_frame_qindex[INTER_FRAME]) *
- (rc->optimal_buffer_level - rc->buffer_level) /
- buff_lvl_step);
+ adjustment = (int)((rc->worst_quality - ambient_qp) *
+ (rc->optimal_buffer_level - rc->buffer_level) /
+ buff_lvl_step);
}
- active_worst_quality = rc->avg_frame_qindex[INTER_FRAME] + adjustment;
+ active_worst_quality = ambient_qp + adjustment;
}
} else {
// Set to worst_quality if buffer is below critical level.
--- a/vp9/encoder/vp9_svc_layercontext.c
+++ b/vp9/encoder/vp9_svc_layercontext.c
@@ -77,6 +77,7 @@
lc->target_bandwidth = oxcf->ts_target_bitrate[layer];
lrc->last_q[INTER_FRAME] = oxcf->worst_allowed_q;
lrc->avg_frame_qindex[INTER_FRAME] = oxcf->worst_allowed_q;
+ lrc->avg_frame_qindex[KEY_FRAME] = oxcf->worst_allowed_q;
} else {
lc->target_bandwidth = oxcf->ss_target_bitrate[layer];
lrc->last_q[KEY_FRAME] = oxcf->best_allowed_q;