Merge "vp9_ratectrl - convert buffers to int64 to avoid casting"
This commit is contained in:
commit
80ccb45c9e
@ -500,9 +500,9 @@ static int calc_active_worst_quality_one_pass_cbr(const VP9_COMP *cpi) {
|
|||||||
const VP9_CONFIG *oxcf = &cpi->oxcf;
|
const VP9_CONFIG *oxcf = &cpi->oxcf;
|
||||||
const RATE_CONTROL *rc = &cpi->rc;
|
const RATE_CONTROL *rc = &cpi->rc;
|
||||||
// Buffer level below which we push active_worst to worst_quality.
|
// Buffer level below which we push active_worst to worst_quality.
|
||||||
int critical_level = oxcf->optimal_buffer_level >> 2;
|
int64_t critical_level = oxcf->optimal_buffer_level >> 2;
|
||||||
|
int64_t buff_lvl_step = 0;
|
||||||
int adjustment = 0;
|
int adjustment = 0;
|
||||||
int buff_lvl_step = 0;
|
|
||||||
int active_worst_quality;
|
int active_worst_quality;
|
||||||
if (cpi->common.frame_type == KEY_FRAME)
|
if (cpi->common.frame_type == KEY_FRAME)
|
||||||
return rc->worst_quality;
|
return rc->worst_quality;
|
||||||
@ -517,8 +517,8 @@ static int calc_active_worst_quality_one_pass_cbr(const VP9_COMP *cpi) {
|
|||||||
// Maximum limit for down adjustment, ~30%.
|
// Maximum limit for down adjustment, ~30%.
|
||||||
int max_adjustment_down = active_worst_quality / 3;
|
int max_adjustment_down = active_worst_quality / 3;
|
||||||
if (max_adjustment_down) {
|
if (max_adjustment_down) {
|
||||||
buff_lvl_step = (int)((oxcf->maximum_buffer_size -
|
buff_lvl_step = ((oxcf->maximum_buffer_size -
|
||||||
oxcf->optimal_buffer_level) / max_adjustment_down);
|
oxcf->optimal_buffer_level) / max_adjustment_down);
|
||||||
if (buff_lvl_step)
|
if (buff_lvl_step)
|
||||||
adjustment = (int)((rc->buffer_level - oxcf->optimal_buffer_level) /
|
adjustment = (int)((rc->buffer_level - oxcf->optimal_buffer_level) /
|
||||||
buff_lvl_step);
|
buff_lvl_step);
|
||||||
@ -529,9 +529,10 @@ static int calc_active_worst_quality_one_pass_cbr(const VP9_COMP *cpi) {
|
|||||||
if (critical_level) {
|
if (critical_level) {
|
||||||
buff_lvl_step = (oxcf->optimal_buffer_level - critical_level);
|
buff_lvl_step = (oxcf->optimal_buffer_level - critical_level);
|
||||||
if (buff_lvl_step) {
|
if (buff_lvl_step) {
|
||||||
adjustment = (rc->worst_quality - rc->avg_frame_qindex[INTER_FRAME]) *
|
adjustment =
|
||||||
(oxcf->optimal_buffer_level - rc->buffer_level) /
|
(int)((rc->worst_quality - rc->avg_frame_qindex[INTER_FRAME]) *
|
||||||
buff_lvl_step;
|
(oxcf->optimal_buffer_level - rc->buffer_level) /
|
||||||
|
buff_lvl_step);
|
||||||
}
|
}
|
||||||
active_worst_quality = rc->avg_frame_qindex[INTER_FRAME] + adjustment;
|
active_worst_quality = rc->avg_frame_qindex[INTER_FRAME] + adjustment;
|
||||||
}
|
}
|
||||||
@ -1150,7 +1151,7 @@ void vp9_rc_postencode_update(VP9_COMP *cpi, uint64_t bytes_used) {
|
|||||||
|
|
||||||
cm->last_frame_type = cm->frame_type;
|
cm->last_frame_type = cm->frame_type;
|
||||||
// Update rate control heuristics
|
// Update rate control heuristics
|
||||||
rc->projected_frame_size = (bytes_used << 3);
|
rc->projected_frame_size = (int)(bytes_used << 3);
|
||||||
|
|
||||||
// Post encode loop adjustment of Q prediction.
|
// Post encode loop adjustment of Q prediction.
|
||||||
vp9_rc_update_rate_correction_factors(
|
vp9_rc_update_rate_correction_factors(
|
||||||
@ -1309,7 +1310,7 @@ static int calc_pframe_target_size_one_pass_cbr(const VP9_COMP *cpi) {
|
|||||||
const VP9_CONFIG *oxcf = &cpi->oxcf;
|
const VP9_CONFIG *oxcf = &cpi->oxcf;
|
||||||
const RATE_CONTROL *rc = &cpi->rc;
|
const RATE_CONTROL *rc = &cpi->rc;
|
||||||
const int64_t diff = oxcf->optimal_buffer_level - rc->buffer_level;
|
const int64_t diff = oxcf->optimal_buffer_level - rc->buffer_level;
|
||||||
const int one_pct_bits = 1 + oxcf->optimal_buffer_level / 100;
|
const int64_t one_pct_bits = 1 + oxcf->optimal_buffer_level / 100;
|
||||||
int min_frame_target = MAX(rc->av_per_frame_bandwidth >> 4,
|
int min_frame_target = MAX(rc->av_per_frame_bandwidth >> 4,
|
||||||
FRAME_OVERHEAD_BITS);
|
FRAME_OVERHEAD_BITS);
|
||||||
int target = rc->av_per_frame_bandwidth;
|
int target = rc->av_per_frame_bandwidth;
|
||||||
@ -1325,11 +1326,11 @@ static int calc_pframe_target_size_one_pass_cbr(const VP9_COMP *cpi) {
|
|||||||
}
|
}
|
||||||
if (diff > 0) {
|
if (diff > 0) {
|
||||||
// Lower the target bandwidth for this frame.
|
// Lower the target bandwidth for this frame.
|
||||||
const int pct_low = MIN(diff / one_pct_bits, oxcf->under_shoot_pct);
|
const int pct_low = (int)MIN(diff / one_pct_bits, oxcf->under_shoot_pct);
|
||||||
target -= (target * pct_low) / 200;
|
target -= (target * pct_low) / 200;
|
||||||
} else if (diff < 0) {
|
} else if (diff < 0) {
|
||||||
// Increase the target bandwidth for this frame.
|
// Increase the target bandwidth for this frame.
|
||||||
const int pct_high = MIN(-diff / one_pct_bits, oxcf->over_shoot_pct);
|
const int pct_high = (int)MIN(-diff / one_pct_bits, oxcf->over_shoot_pct);
|
||||||
target += (target * pct_high) / 200;
|
target += (target * pct_high) / 200;
|
||||||
}
|
}
|
||||||
return MAX(min_frame_target, target);
|
return MAX(min_frame_target, target);
|
||||||
@ -1339,7 +1340,8 @@ static int calc_iframe_target_size_one_pass_cbr(const VP9_COMP *cpi) {
|
|||||||
const RATE_CONTROL *rc = &cpi->rc;
|
const RATE_CONTROL *rc = &cpi->rc;
|
||||||
|
|
||||||
if (cpi->common.current_video_frame == 0) {
|
if (cpi->common.current_video_frame == 0) {
|
||||||
return cpi->oxcf.starting_buffer_level / 2;
|
return ((cpi->oxcf.starting_buffer_level / 2) > INT_MAX)
|
||||||
|
? INT_MAX : (int)(cpi->oxcf.starting_buffer_level / 2);
|
||||||
} else {
|
} else {
|
||||||
const int initial_boost = 32;
|
const int initial_boost = 32;
|
||||||
int kf_boost = MAX(initial_boost, (int)(2 * cpi->output_framerate - 16));
|
int kf_boost = MAX(initial_boost, (int)(2 * cpi->output_framerate - 16));
|
||||||
|
@ -57,8 +57,8 @@ typedef struct {
|
|||||||
double tot_q;
|
double tot_q;
|
||||||
double avg_q;
|
double avg_q;
|
||||||
|
|
||||||
int buffer_level;
|
int64_t buffer_level;
|
||||||
int bits_off_target;
|
int64_t bits_off_target;
|
||||||
|
|
||||||
int decimation_factor;
|
int decimation_factor;
|
||||||
int decimation_count;
|
int decimation_count;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user