Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: source/libvpx/vp9/encoder/vp9_ratectrl.c

Issue 181493009: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_ratectrl.h ('k') | source/libvpx/vp9/encoder/vp9_rdopt.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: source/libvpx/vp9/encoder/vp9_ratectrl.c
===================================================================
--- source/libvpx/vp9/encoder/vp9_ratectrl.c (revision 254565)
+++ source/libvpx/vp9/encoder/vp9_ratectrl.c (working copy)
@@ -8,24 +8,25 @@
* be found in the AUTHORS file in the root of the source tree.
*/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <limits.h>
#include <assert.h>
+#include <limits.h>
#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include "vpx_mem/vpx_mem.h"
+
#include "vp9/common/vp9_alloccommon.h"
#include "vp9/common/vp9_common.h"
-#include "vp9/encoder/vp9_ratectrl.h"
#include "vp9/common/vp9_entropymode.h"
-#include "vpx_mem/vpx_mem.h"
-#include "vp9/common/vp9_systemdependent.h"
-#include "vp9/encoder/vp9_encodemv.h"
#include "vp9/common/vp9_quant_common.h"
#include "vp9/common/vp9_seg_common.h"
+#include "vp9/common/vp9_systemdependent.h"
+#include "vp9/encoder/vp9_encodemv.h"
+#include "vp9/encoder/vp9_ratectrl.h"
+
#define LIMIT_QRANGE_FOR_ALTREF_AND_KEY 1
#define MIN_BPB_FACTOR 0.005
@@ -354,7 +355,7 @@
int projected_size_based_on_q = 0;
// Clear down mmx registers to allow floating point in what follows
- vp9_clear_system_state(); // __asm emms;
+ vp9_clear_system_state();
// Work out how big we would have expected the frame to be at this Q given
// the current correction factor.
@@ -500,9 +501,9 @@
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 +518,8 @@
// 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 +530,10 @@
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;
}
@@ -957,18 +959,11 @@
}
// Clip the active best and worst quality values to limits.
- if (active_worst_quality > rc->worst_quality)
- active_worst_quality = rc->worst_quality;
+ active_best_quality = clamp(active_best_quality,
+ rc->best_quality, rc->worst_quality);
+ active_worst_quality = clamp(active_worst_quality,
+ active_best_quality, rc->worst_quality);
- if (active_best_quality < rc->best_quality)
- active_best_quality = rc->best_quality;
-
- if (active_best_quality > rc->worst_quality)
- active_best_quality = rc->worst_quality;
-
- if (active_worst_quality < active_best_quality)
- active_worst_quality = active_best_quality;
-
*top_index = active_worst_quality;
*bottom_index = active_best_quality;
@@ -1040,7 +1035,7 @@
// JBB : This is realtime mode. In real time mode the first frame
// should be larger. Q of 0 is disabled because we force tx size to be
// 16x16...
- if (cpi->sf.use_pick_mode) {
+ if (cpi->sf.use_nonrd_pick_mode) {
if (cpi->common.current_video_frame == 0)
q /= 3;
if (q == 0)
@@ -1150,7 +1145,7 @@
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 +1304,7 @@
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 +1320,11 @@
}
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);
@@ -1337,9 +1332,11 @@
static int calc_iframe_target_size_one_pass_cbr(const VP9_COMP *cpi) {
const RATE_CONTROL *rc = &cpi->rc;
+ int target;
if (cpi->common.current_video_frame == 0) {
- return cpi->oxcf.starting_buffer_level / 2;
+ target = ((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));
@@ -1347,8 +1344,9 @@
kf_boost = (int)(kf_boost * rc->frames_since_key /
(cpi->output_framerate / 2));
}
- return ((16 + kf_boost) * rc->av_per_frame_bandwidth) >> 4;
+ target = ((16 + kf_boost) * rc->av_per_frame_bandwidth) >> 4;
}
+ return vp9_rc_clamp_iframe_target_size(cpi, target);
}
void vp9_rc_get_svc_params(VP9_COMP *cpi) {
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_ratectrl.h ('k') | source/libvpx/vp9/encoder/vp9_rdopt.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698