Commit e9fb970a authored by Dmitry Kovalev's avatar Dmitry Kovalev Committed by Gerrit Code Review
Browse files

Merge "Moving init_rate_control() to vp9_ratectrl.{c, h}."

parents 56c2f41c e7e426b2
......@@ -748,57 +748,6 @@ static void set_tile_limits(VP9_COMP *cpi) {
cm->log2_tile_rows = cpi->oxcf.tile_rows;
}
static void init_rate_control(const VP9_CONFIG *oxcf, int pass,
RATE_CONTROL *rc) {
if (pass == 0 && oxcf->end_usage == USAGE_STREAM_FROM_SERVER) {
rc->avg_frame_qindex[0] = oxcf->worst_allowed_q;
rc->avg_frame_qindex[1] = oxcf->worst_allowed_q;
rc->avg_frame_qindex[2] = oxcf->worst_allowed_q;
} else {
rc->avg_frame_qindex[0] = (oxcf->worst_allowed_q +
oxcf->best_allowed_q) / 2;
rc->avg_frame_qindex[1] = (oxcf->worst_allowed_q +
oxcf->best_allowed_q) / 2;
rc->avg_frame_qindex[2] = (oxcf->worst_allowed_q +
oxcf->best_allowed_q) / 2;
}
rc->last_q[0] = oxcf->best_allowed_q;
rc->last_q[1] = oxcf->best_allowed_q;
rc->last_q[2] = oxcf->best_allowed_q;
rc->buffer_level = oxcf->starting_buffer_level;
rc->bits_off_target = oxcf->starting_buffer_level;
rc->rolling_target_bits = rc->av_per_frame_bandwidth;
rc->rolling_actual_bits = rc->av_per_frame_bandwidth;
rc->long_rolling_target_bits = rc->av_per_frame_bandwidth;
rc->long_rolling_actual_bits = rc->av_per_frame_bandwidth;
rc->total_actual_bits = 0;
rc->total_target_vs_actual = 0;
rc->baseline_gf_interval = DEFAULT_GF_INTERVAL;
rc->frames_since_key = 8; // Sensible default for first frame.
rc->this_key_frame_forced = 0;
rc->next_key_frame_forced = 0;
rc->source_alt_ref_pending = 0;
rc->source_alt_ref_active = 0;
rc->frames_till_gf_update_due = 0;
rc->ni_av_qi = oxcf->worst_allowed_q;
rc->ni_tot_qi = 0;
rc->ni_frames = 0;
rc->tot_q = 0.0;
rc->avg_q = vp9_convert_qindex_to_q(oxcf->worst_allowed_q);
rc->rate_correction_factor = 1.0;
rc->key_frame_rate_correction_factor = 1.0;
rc->gf_rate_correction_factor = 1.0;
}
static void init_config(struct VP9_COMP *cpi, VP9_CONFIG *oxcf) {
VP9_COMMON *const cm = &cpi->common;
int i;
......@@ -1195,7 +1144,7 @@ VP9_COMP *vp9_create_compressor(VP9_CONFIG *oxcf) {
cpi->use_svc = 0;
init_config(cpi, oxcf);
init_rate_control(&cpi->oxcf, cpi->pass, &cpi->rc);
vp9_rc_init(&cpi->oxcf, cpi->pass, &cpi->rc);
init_pick_mode_context(cpi);
cm->current_video_frame = 0;
......
......@@ -185,7 +185,7 @@ typedef enum {
AQ_MODE_COUNT // This should always be the last member of the enum
} AQ_MODE;
typedef struct {
typedef struct VP9_CONFIG {
int version; // 4 versions of bitstream defined:
// 0 - best quality/slowest decode,
// 3 - lowest quality/fastest decode
......
......@@ -184,6 +184,56 @@ static void update_buffer_level(VP9_COMP *cpi, int encoded_frame_size) {
}
}
void vp9_rc_init(const VP9_CONFIG *oxcf, int pass, RATE_CONTROL *rc) {
if (pass == 0 && oxcf->end_usage == USAGE_STREAM_FROM_SERVER) {
rc->avg_frame_qindex[0] = oxcf->worst_allowed_q;
rc->avg_frame_qindex[1] = oxcf->worst_allowed_q;
rc->avg_frame_qindex[2] = oxcf->worst_allowed_q;
} else {
rc->avg_frame_qindex[0] = (oxcf->worst_allowed_q +
oxcf->best_allowed_q) / 2;
rc->avg_frame_qindex[1] = (oxcf->worst_allowed_q +
oxcf->best_allowed_q) / 2;
rc->avg_frame_qindex[2] = (oxcf->worst_allowed_q +
oxcf->best_allowed_q) / 2;
}
rc->last_q[0] = oxcf->best_allowed_q;
rc->last_q[1] = oxcf->best_allowed_q;
rc->last_q[2] = oxcf->best_allowed_q;
rc->buffer_level = oxcf->starting_buffer_level;
rc->bits_off_target = oxcf->starting_buffer_level;
rc->rolling_target_bits = rc->av_per_frame_bandwidth;
rc->rolling_actual_bits = rc->av_per_frame_bandwidth;
rc->long_rolling_target_bits = rc->av_per_frame_bandwidth;
rc->long_rolling_actual_bits = rc->av_per_frame_bandwidth;
rc->total_actual_bits = 0;
rc->total_target_vs_actual = 0;
rc->baseline_gf_interval = DEFAULT_GF_INTERVAL;
rc->frames_since_key = 8; // Sensible default for first frame.
rc->this_key_frame_forced = 0;
rc->next_key_frame_forced = 0;
rc->source_alt_ref_pending = 0;
rc->source_alt_ref_active = 0;
rc->frames_till_gf_update_due = 0;
rc->ni_av_qi = oxcf->worst_allowed_q;
rc->ni_tot_qi = 0;
rc->ni_frames = 0;
rc->tot_q = 0.0;
rc->avg_q = vp9_convert_qindex_to_q(oxcf->worst_allowed_q);
rc->rate_correction_factor = 1.0;
rc->key_frame_rate_correction_factor = 1.0;
rc->gf_rate_correction_factor = 1.0;
}
int vp9_rc_drop_frame(VP9_COMP *cpi) {
const VP9_CONFIG *oxcf = &cpi->oxcf;
RATE_CONTROL *const rc = &cpi->rc;
......
......@@ -87,6 +87,9 @@ typedef struct {
} RATE_CONTROL;
struct VP9_COMP;
struct VP9_CONFIG;
void vp9_rc_init(const struct VP9_CONFIG *oxcf, int pass, RATE_CONTROL *rc);
double vp9_convert_qindex_to_q(int qindex);
......
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