diff options
author | Dmitry Kovalev <dkovalev@google.com> | 2014-03-24 14:17:23 -0700 |
---|---|---|
committer | Gerrit Code Review <gerrit@gerrit.golo.chromium.org> | 2014-03-24 14:17:23 -0700 |
commit | 65259f2110ad2e6e72bd5f2ad2d0b827a7c2feec (patch) | |
tree | 8132d78f495861d82253c6d8669ffb8cf9327314 | |
parent | 2128f714aa15ee6fd7415829b33e3ba0a06ab4cb (diff) | |
parent | 6202406ebcedba2a9ca61825631b6c2064504674 (diff) | |
download | libvpx-65259f2110ad2e6e72bd5f2ad2d0b827a7c2feec.tar libvpx-65259f2110ad2e6e72bd5f2ad2d0b827a7c2feec.tar.gz libvpx-65259f2110ad2e6e72bd5f2ad2d0b827a7c2feec.tar.bz2 libvpx-65259f2110ad2e6e72bd5f2ad2d0b827a7c2feec.zip |
Merge "Adding init_rate_control() function + cleanup."
-rw-r--r-- | vp9/encoder/vp9_onyx_if.c | 70 | ||||
-rw-r--r-- | vp9/encoder/vp9_onyx_int.h | 2 |
2 files changed, 35 insertions, 37 deletions
diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c index 53ca6e0e3..4eabc2fc7 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_onyx_if.c @@ -1202,9 +1202,39 @@ 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; +} + static void init_config(struct VP9_COMP *cpi, VP9_CONFIG *oxcf) { VP9_COMMON *const cm = &cpi->common; - RATE_CONTROL *const rc = &cpi->rc; int i; cpi->oxcf = *oxcf; @@ -1230,35 +1260,6 @@ static void init_config(struct VP9_COMP *cpi, VP9_CONFIG *oxcf) { // change includes all joint functionality vp9_change_config(cpi, oxcf); - // Initialize active best and worst q and average q values. - if (cpi->pass == 0 && cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) { - rc->avg_frame_qindex[0] = cpi->oxcf.worst_allowed_q; - rc->avg_frame_qindex[1] = cpi->oxcf.worst_allowed_q; - rc->avg_frame_qindex[2] = cpi->oxcf.worst_allowed_q; - } else { - rc->avg_frame_qindex[0] = (cpi->oxcf.worst_allowed_q + - cpi->oxcf.best_allowed_q) / 2; - rc->avg_frame_qindex[1] = (cpi->oxcf.worst_allowed_q + - cpi->oxcf.best_allowed_q) / 2; - rc->avg_frame_qindex[2] = (cpi->oxcf.worst_allowed_q + - cpi->oxcf.best_allowed_q) / 2; - } - rc->last_q[0] = cpi->oxcf.best_allowed_q; - rc->last_q[1] = cpi->oxcf.best_allowed_q; - rc->last_q[2] = cpi->oxcf.best_allowed_q; - - // Initialise the starting buffer levels - rc->buffer_level = cpi->oxcf.starting_buffer_level; - rc->bits_off_target = cpi->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; - cpi->static_mb_pct = 0; cpi->lst_fb_idx = 0; @@ -1272,15 +1273,11 @@ static void init_config(struct VP9_COMP *cpi, VP9_CONFIG *oxcf) { cpi->fixed_divide[i] = 0x80000 / i; } -void vp9_change_config(struct VP9_COMP *cpi, VP9_CONFIG *oxcf) { +void vp9_change_config(struct VP9_COMP *cpi, const VP9_CONFIG *oxcf) { VP9_COMMON *const cm = &cpi->common; - if (!cpi || !oxcf) - return; - - if (cm->version != oxcf->version) { + if (cm->version != oxcf->version) cm->version = oxcf->version; - } cpi->oxcf = *oxcf; @@ -1631,6 +1628,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); init_pick_mode_context(cpi); cm->current_video_frame = 0; diff --git a/vp9/encoder/vp9_onyx_int.h b/vp9/encoder/vp9_onyx_int.h index a2147d0b4..022a63f91 100644 --- a/vp9/encoder/vp9_onyx_int.h +++ b/vp9/encoder/vp9_onyx_int.h @@ -825,7 +825,7 @@ void vp9_initialize_enc(); struct VP9_COMP *vp9_create_compressor(VP9_CONFIG *oxcf); void vp9_remove_compressor(VP9_COMP *cpi); -void vp9_change_config(VP9_COMP *cpi, VP9_CONFIG *oxcf); +void vp9_change_config(VP9_COMP *cpi, const VP9_CONFIG *oxcf); // receive a frames worth of data. caller can assume that a copy of this // frame is made and not just a copy of the pointer.. |