summaryrefslogtreecommitdiff
path: root/vp9/encoder
diff options
context:
space:
mode:
authorJim Bankoski <jimbankoski@google.com>2014-02-14 07:12:38 -0800
committerJim Bankoski <jimbankoski@google.com>2014-02-14 07:36:47 -0800
commitfb4f10a26e967298c55aa342a2afe7ebf02011b2 (patch)
tree6ea512582ec6e3c6dad4c85c91d7bc250dfe205c /vp9/encoder
parent0abb06571bb0407c54b8de2aedd6f59a74cc7b84 (diff)
downloadlibvpx-fb4f10a26e967298c55aa342a2afe7ebf02011b2.tar
libvpx-fb4f10a26e967298c55aa342a2afe7ebf02011b2.tar.gz
libvpx-fb4f10a26e967298c55aa342a2afe7ebf02011b2.tar.bz2
libvpx-fb4f10a26e967298c55aa342a2afe7ebf02011b2.zip
vp9_ratectrl - convert buffers to int64 to avoid casting
Change-Id: Ifd6b2d36d91237b5f38853a3a8a529d8be38ba09
Diffstat (limited to 'vp9/encoder')
-rw-r--r--vp9/encoder/vp9_ratectrl.c26
-rw-r--r--vp9/encoder/vp9_ratectrl.h4
2 files changed, 16 insertions, 14 deletions
diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c
index bc2c3a69a..7aa4b39ed 100644
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -500,9 +500,9 @@ static int calc_active_worst_quality_one_pass_cbr(const VP9_COMP *cpi) {
const VP9_CONFIG *oxcf = &cpi->oxcf;
const RATE_CONTROL *rc = &cpi->rc;
// 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 buff_lvl_step = 0;
int active_worst_quality;
if (cpi->common.frame_type == KEY_FRAME)
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%.
int max_adjustment_down = active_worst_quality / 3;
if (max_adjustment_down) {
- buff_lvl_step = (int)((oxcf->maximum_buffer_size -
- oxcf->optimal_buffer_level) / max_adjustment_down);
+ buff_lvl_step = ((oxcf->maximum_buffer_size -
+ oxcf->optimal_buffer_level) / max_adjustment_down);
if (buff_lvl_step)
adjustment = (int)((rc->buffer_level - oxcf->optimal_buffer_level) /
buff_lvl_step);
@@ -529,9 +529,10 @@ static int calc_active_worst_quality_one_pass_cbr(const VP9_COMP *cpi) {
if (critical_level) {
buff_lvl_step = (oxcf->optimal_buffer_level - critical_level);
if (buff_lvl_step) {
- adjustment = (rc->worst_quality - rc->avg_frame_qindex[INTER_FRAME]) *
- (oxcf->optimal_buffer_level - rc->buffer_level) /
- buff_lvl_step;
+ adjustment =
+ (int)((rc->worst_quality - rc->avg_frame_qindex[INTER_FRAME]) *
+ (oxcf->optimal_buffer_level - rc->buffer_level) /
+ buff_lvl_step);
}
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;
// 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.
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 RATE_CONTROL *rc = &cpi->rc;
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,
FRAME_OVERHEAD_BITS);
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) {
// 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;
} else if (diff < 0) {
// 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;
}
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;
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 {
const int initial_boost = 32;
int kf_boost = MAX(initial_boost, (int)(2 * cpi->output_framerate - 16));
diff --git a/vp9/encoder/vp9_ratectrl.h b/vp9/encoder/vp9_ratectrl.h
index 551b6c327..c6ea7c194 100644
--- a/vp9/encoder/vp9_ratectrl.h
+++ b/vp9/encoder/vp9_ratectrl.h
@@ -57,8 +57,8 @@ typedef struct {
double tot_q;
double avg_q;
- int buffer_level;
- int bits_off_target;
+ int64_t buffer_level;
+ int64_t bits_off_target;
int decimation_factor;
int decimation_count;