ref: e9fb970af11a249cf257e84cbc4f08be98081915
parent: 56c2f41ccbcc6115b39bbab62c3c3b4099acd6e9
parent: e7e426b2748e93d32be21457902cbcf97de350a9
author: Dmitry Kovalev <dkovalev@google.com>
date: Tue Apr 8 08:45:49 EDT 2014
Merge "Moving init_rate_control() to vp9_ratectrl.{c, h}."
--- a/vp9/encoder/vp9_onyx_if.c
+++ b/vp9/encoder/vp9_onyx_if.c
@@ -748,57 +748,6 @@
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 @@
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;
--- a/vp9/encoder/vp9_onyx_int.h
+++ b/vp9/encoder/vp9_onyx_int.h
@@ -185,7 +185,7 @@
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
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -184,6 +184,56 @@
}
}
+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;
--- a/vp9/encoder/vp9_ratectrl.h
+++ b/vp9/encoder/vp9_ratectrl.h
@@ -87,6 +87,9 @@
} 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);
--
⑨