mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-05 03:11:23 +00:00
[libvpx] Update to v1.12.0
This commit is contained in:
@@ -314,7 +314,7 @@ static void calc_iframe_target_size(VP8_COMP *cpi) {
|
||||
* bandwidth per second * fraction of the initial buffer
|
||||
* level
|
||||
*/
|
||||
target = cpi->oxcf.starting_buffer_level / 2;
|
||||
target = (uint64_t)cpi->oxcf.starting_buffer_level / 2;
|
||||
|
||||
if (target > cpi->oxcf.target_bandwidth * 3 / 2) {
|
||||
target = cpi->oxcf.target_bandwidth * 3 / 2;
|
||||
@@ -327,7 +327,8 @@ static void calc_iframe_target_size(VP8_COMP *cpi) {
|
||||
int initial_boost = 32; /* |3.0 * per_frame_bandwidth| */
|
||||
/* Boost depends somewhat on frame rate: only used for 1 layer case. */
|
||||
if (cpi->oxcf.number_of_layers == 1) {
|
||||
kf_boost = VPXMAX(initial_boost, (int)(2 * cpi->output_framerate - 16));
|
||||
kf_boost =
|
||||
VPXMAX(initial_boost, (int)round(2 * cpi->output_framerate - 16));
|
||||
} else {
|
||||
/* Initial factor: set target size to: |3.0 * per_frame_bandwidth|. */
|
||||
kf_boost = initial_boost;
|
||||
@@ -349,15 +350,19 @@ static void calc_iframe_target_size(VP8_COMP *cpi) {
|
||||
}
|
||||
|
||||
if (cpi->oxcf.rc_max_intra_bitrate_pct) {
|
||||
unsigned int max_rate =
|
||||
cpi->per_frame_bandwidth * cpi->oxcf.rc_max_intra_bitrate_pct / 100;
|
||||
unsigned int max_rate;
|
||||
// This product may overflow unsigned int
|
||||
uint64_t product = cpi->per_frame_bandwidth;
|
||||
product *= cpi->oxcf.rc_max_intra_bitrate_pct;
|
||||
product /= 100;
|
||||
max_rate = (unsigned int)VPXMIN(INT_MAX, product);
|
||||
|
||||
if (target > max_rate) target = max_rate;
|
||||
}
|
||||
|
||||
cpi->this_frame_target = (int)target;
|
||||
|
||||
/* TODO: if we separate rate targeting from Q targetting, move this.
|
||||
/* TODO: if we separate rate targeting from Q targeting, move this.
|
||||
* Reset the active worst quality to the baseline value for key frames.
|
||||
*/
|
||||
if (cpi->pass != 2) cpi->active_worst_quality = cpi->worst_quality;
|
||||
@@ -776,6 +781,7 @@ static void calc_pframe_target_size(VP8_COMP *cpi) {
|
||||
}
|
||||
} else {
|
||||
int percent_high = 0;
|
||||
int64_t target = cpi->this_frame_target;
|
||||
|
||||
if ((cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) &&
|
||||
(cpi->buffer_level > cpi->oxcf.optimal_buffer_level)) {
|
||||
@@ -793,7 +799,9 @@ static void calc_pframe_target_size(VP8_COMP *cpi) {
|
||||
percent_high = 0;
|
||||
}
|
||||
|
||||
cpi->this_frame_target += (cpi->this_frame_target * percent_high) / 200;
|
||||
target += (target * percent_high) / 200;
|
||||
target = VPXMIN(target, INT_MAX);
|
||||
cpi->this_frame_target = (int)target;
|
||||
|
||||
/* Are we allowing control of active_worst_allowed_q according
|
||||
* to buffer level.
|
||||
@@ -1074,8 +1082,8 @@ void vp8_update_rate_correction_factors(VP8_COMP *cpi, int damp_var) {
|
||||
|
||||
/* Work out a size correction factor. */
|
||||
if (projected_size_based_on_q > 0) {
|
||||
correction_factor =
|
||||
(100 * cpi->projected_frame_size) / projected_size_based_on_q;
|
||||
correction_factor = (int)((100 * (int64_t)cpi->projected_frame_size) /
|
||||
projected_size_based_on_q);
|
||||
}
|
||||
|
||||
/* More heavily damped adjustment used if we have been oscillating
|
||||
@@ -1375,14 +1383,17 @@ void vp8_compute_frame_size_bounds(VP8_COMP *cpi, int *frame_under_shoot_limit,
|
||||
*frame_under_shoot_limit = 0;
|
||||
*frame_over_shoot_limit = INT_MAX;
|
||||
} else {
|
||||
const int64_t this_frame_target = cpi->this_frame_target;
|
||||
int64_t over_shoot_limit, under_shoot_limit;
|
||||
|
||||
if (cpi->common.frame_type == KEY_FRAME) {
|
||||
*frame_over_shoot_limit = cpi->this_frame_target * 9 / 8;
|
||||
*frame_under_shoot_limit = cpi->this_frame_target * 7 / 8;
|
||||
over_shoot_limit = this_frame_target * 9 / 8;
|
||||
under_shoot_limit = this_frame_target * 7 / 8;
|
||||
} else {
|
||||
if (cpi->oxcf.number_of_layers > 1 || cpi->common.refresh_alt_ref_frame ||
|
||||
cpi->common.refresh_golden_frame) {
|
||||
*frame_over_shoot_limit = cpi->this_frame_target * 9 / 8;
|
||||
*frame_under_shoot_limit = cpi->this_frame_target * 7 / 8;
|
||||
over_shoot_limit = this_frame_target * 9 / 8;
|
||||
under_shoot_limit = this_frame_target * 7 / 8;
|
||||
} else {
|
||||
/* For CBR take buffer fullness into account */
|
||||
if (cpi->oxcf.end_usage == USAGE_STREAM_FROM_SERVER) {
|
||||
@@ -1392,18 +1403,18 @@ void vp8_compute_frame_size_bounds(VP8_COMP *cpi, int *frame_under_shoot_limit,
|
||||
/* Buffer is too full so relax overshoot and tighten
|
||||
* undershoot
|
||||
*/
|
||||
*frame_over_shoot_limit = cpi->this_frame_target * 12 / 8;
|
||||
*frame_under_shoot_limit = cpi->this_frame_target * 6 / 8;
|
||||
over_shoot_limit = this_frame_target * 12 / 8;
|
||||
under_shoot_limit = this_frame_target * 6 / 8;
|
||||
} else if (cpi->buffer_level <=
|
||||
(cpi->oxcf.optimal_buffer_level >> 1)) {
|
||||
/* Buffer is too low so relax undershoot and tighten
|
||||
* overshoot
|
||||
*/
|
||||
*frame_over_shoot_limit = cpi->this_frame_target * 10 / 8;
|
||||
*frame_under_shoot_limit = cpi->this_frame_target * 4 / 8;
|
||||
over_shoot_limit = this_frame_target * 10 / 8;
|
||||
under_shoot_limit = this_frame_target * 4 / 8;
|
||||
} else {
|
||||
*frame_over_shoot_limit = cpi->this_frame_target * 11 / 8;
|
||||
*frame_under_shoot_limit = cpi->this_frame_target * 5 / 8;
|
||||
over_shoot_limit = this_frame_target * 11 / 8;
|
||||
under_shoot_limit = this_frame_target * 5 / 8;
|
||||
}
|
||||
}
|
||||
/* VBR and CQ mode */
|
||||
@@ -1413,11 +1424,11 @@ void vp8_compute_frame_size_bounds(VP8_COMP *cpi, int *frame_under_shoot_limit,
|
||||
else {
|
||||
/* Stron overshoot limit for constrained quality */
|
||||
if (cpi->oxcf.end_usage == USAGE_CONSTRAINED_QUALITY) {
|
||||
*frame_over_shoot_limit = cpi->this_frame_target * 11 / 8;
|
||||
*frame_under_shoot_limit = cpi->this_frame_target * 2 / 8;
|
||||
over_shoot_limit = this_frame_target * 11 / 8;
|
||||
under_shoot_limit = this_frame_target * 2 / 8;
|
||||
} else {
|
||||
*frame_over_shoot_limit = cpi->this_frame_target * 11 / 8;
|
||||
*frame_under_shoot_limit = cpi->this_frame_target * 5 / 8;
|
||||
over_shoot_limit = this_frame_target * 11 / 8;
|
||||
under_shoot_limit = this_frame_target * 5 / 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1427,9 +1438,13 @@ void vp8_compute_frame_size_bounds(VP8_COMP *cpi, int *frame_under_shoot_limit,
|
||||
* (eg * 7/8) may be tiny make sure there is at least a minimum
|
||||
* range.
|
||||
*/
|
||||
*frame_over_shoot_limit += 200;
|
||||
*frame_under_shoot_limit -= 200;
|
||||
if (*frame_under_shoot_limit < 0) *frame_under_shoot_limit = 0;
|
||||
over_shoot_limit += 200;
|
||||
under_shoot_limit -= 200;
|
||||
if (under_shoot_limit < 0) under_shoot_limit = 0;
|
||||
if (under_shoot_limit > INT_MAX) under_shoot_limit = INT_MAX;
|
||||
if (over_shoot_limit > INT_MAX) over_shoot_limit = INT_MAX;
|
||||
*frame_under_shoot_limit = (int)under_shoot_limit;
|
||||
*frame_over_shoot_limit = (int)over_shoot_limit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user