Commit 5a78c406 authored by Dmitry Kovalev's avatar Dmitry Kovalev

Moving framerate from VP9EncoderConfig to VP9_COMP.

Framerate changes over time, VP9EncoderConfig supposed to have static
read-only data.

Change-Id: I36580a7ee71243c1eabb57691089691731d03e67
parent 9a4cd417
......@@ -488,7 +488,7 @@ static void update_frame_size(VP9_COMP *cpi) {
}
void vp9_new_framerate(VP9_COMP *cpi, double framerate) {
cpi->oxcf.framerate = framerate < 0.1 ? 30 : framerate;
cpi->framerate = framerate < 0.1 ? 30 : framerate;
vp9_rc_update_framerate(cpi);
}
......@@ -521,6 +521,7 @@ static void init_config(struct VP9_COMP *cpi, VP9EncoderConfig *oxcf) {
VP9_COMMON *const cm = &cpi->common;
cpi->oxcf = *oxcf;
cpi->framerate = oxcf->init_framerate;
cm->profile = oxcf->profile;
cm->bit_depth = oxcf->bit_depth;
......@@ -632,7 +633,7 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) {
rc->buffer_level = MIN(rc->buffer_level, rc->maximum_buffer_size);
// Set up frame rate and related parameters rate control values.
vp9_new_framerate(cpi, cpi->oxcf.framerate);
vp9_new_framerate(cpi, cpi->framerate);
// Set absolute upper and lower quality limits
rc->worst_quality = cpi->oxcf.worst_allowed_q;
......@@ -2500,7 +2501,7 @@ void adjust_frame_rate(VP9_COMP *cpi) {
// over the whole interval seen.
const double interval = MIN((double)(cpi->source->ts_end
- cpi->first_time_stamp_ever), 10000000.0);
double avg_duration = 10000000.0 / cpi->oxcf.framerate;
double avg_duration = 10000000.0 / cpi->framerate;
avg_duration *= (interval - avg_duration + this_duration);
avg_duration /= interval;
......
......@@ -134,7 +134,7 @@ typedef struct VP9EncoderConfig {
BIT_DEPTH bit_depth;
int width; // width of data passed to the compressor
int height; // height of data passed to the compressor
double framerate; // set to passed in framerate
double init_framerate; // set to passed in framerate
int64_t target_bandwidth; // bandwidth to be used in kilobits per second
int noise_sensitivity; // pre processing blur: recommendation 0
......@@ -305,6 +305,7 @@ typedef struct VP9_COMP {
int64_t first_time_stamp_ever;
RATE_CONTROL rc;
double framerate;
vp9_coeff_count coef_counts[TX_SIZES][PLANE_TYPES];
......
......@@ -1208,7 +1208,7 @@ static int calc_iframe_target_size_one_pass_cbr(const VP9_COMP *cpi) {
? INT_MAX : (int)(rc->starting_buffer_level / 2);
} else {
int kf_boost = 32;
double framerate = oxcf->framerate;
double framerate = cpi->framerate;
if (svc->number_temporal_layers > 1 &&
oxcf->rc_mode == VPX_CBR) {
// Use the layer framerate for temporal layers CBR mode.
......@@ -1364,7 +1364,7 @@ void vp9_rc_update_framerate(VP9_COMP *cpi) {
RATE_CONTROL *const rc = &cpi->rc;
int vbr_max_bits;
rc->avg_frame_bandwidth = (int)(oxcf->target_bandwidth / oxcf->framerate);
rc->avg_frame_bandwidth = (int)(oxcf->target_bandwidth / cpi->framerate);
rc->min_frame_bandwidth = (int)(rc->avg_frame_bandwidth *
oxcf->two_pass_vbrmin_section / 100);
......
......@@ -116,9 +116,9 @@ void vp9_update_layer_context_change_config(VP9_COMP *const cpi,
lrc->buffer_level = MIN(lrc->buffer_level, lrc->maximum_buffer_size);
// Update framerate-related quantities.
if (svc->number_temporal_layers > 1) {
lc->framerate = oxcf->framerate / oxcf->ts_rate_decimator[layer];
lc->framerate = cpi->framerate / oxcf->ts_rate_decimator[layer];
} else {
lc->framerate = oxcf->framerate;
lc->framerate = cpi->framerate;
}
lrc->avg_frame_bandwidth = (int)(lc->target_bandwidth / lc->framerate);
lrc->max_frame_bandwidth = rc->max_frame_bandwidth;
......@@ -141,7 +141,7 @@ void vp9_update_temporal_layer_framerate(VP9_COMP *const cpi) {
RATE_CONTROL *const lrc = &lc->rc;
const int layer = svc->temporal_layer_id;
lc->framerate = oxcf->framerate / oxcf->ts_rate_decimator[layer];
lc->framerate = cpi->framerate / oxcf->ts_rate_decimator[layer];
lrc->avg_frame_bandwidth = (int)(lc->target_bandwidth / lc->framerate);
lrc->max_frame_bandwidth = cpi->rc.max_frame_bandwidth;
// Update the average layer frame size (non-cumulative per-frame-bw).
......@@ -149,7 +149,7 @@ void vp9_update_temporal_layer_framerate(VP9_COMP *const cpi) {
lc->avg_frame_size = lrc->avg_frame_bandwidth;
} else {
const double prev_layer_framerate =
oxcf->framerate / oxcf->ts_rate_decimator[layer - 1];
cpi->framerate / oxcf->ts_rate_decimator[layer - 1];
const int prev_layer_target_bandwidth = oxcf->ts_target_bitrate[layer - 1];
lc->avg_frame_size =
(int)((lc->target_bandwidth - prev_layer_target_bandwidth) /
......
......@@ -330,9 +330,9 @@ static vpx_codec_err_t set_encoder_config(
oxcf->height = cfg->g_h;
oxcf->bit_depth = extra_cfg->bit_depth;
// guess a frame rate if out of whack, use 30
oxcf->framerate = (double)cfg->g_timebase.den / cfg->g_timebase.num;
if (oxcf->framerate > 180)
oxcf->framerate = 30;
oxcf->init_framerate = (double)cfg->g_timebase.den / cfg->g_timebase.num;
if (oxcf->init_framerate > 180)
oxcf->init_framerate = 30;
switch (cfg->g_pass) {
case VPX_RC_ONE_PASS:
......
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