summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Wilkins <paulwilkins@google.com>2017-10-19 10:06:33 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2017-10-19 10:06:33 +0000
commitd8c34a2552f9ffe7cb738d7d4a7a89ff786bcced (patch)
tree97cda341dcb90363a2a879d48bdcfa4d9da6b3a1
parent401e6d48bfd3cbf74a41da724d05c989e207662b (diff)
parent416b7051d7f610ed6d62dff18af7776ec520fd9c (diff)
downloadlibvpx-d8c34a2552f9ffe7cb738d7d4a7a89ff786bcced.tar
libvpx-d8c34a2552f9ffe7cb738d7d4a7a89ff786bcced.tar.gz
libvpx-d8c34a2552f9ffe7cb738d7d4a7a89ff786bcced.tar.bz2
libvpx-d8c34a2552f9ffe7cb738d7d4a7a89ff786bcced.zip
Merge "Prevent double application of min rate in two pass."
-rw-r--r--vp9/encoder/vp9_ratectrl.c25
-rw-r--r--vp9/encoder/vp9_ratectrl.h2
2 files changed, 16 insertions, 11 deletions
diff --git a/vp9/encoder/vp9_ratectrl.c b/vp9/encoder/vp9_ratectrl.c
index 73d78a30c..a936ec943 100644
--- a/vp9/encoder/vp9_ratectrl.c
+++ b/vp9/encoder/vp9_ratectrl.c
@@ -44,8 +44,6 @@
#define MIN_BPB_FACTOR 0.005
#define MAX_BPB_FACTOR 50
-#define FRAME_OVERHEAD_BITS 200
-
#if CONFIG_VP9_HIGHBITDEPTH
#define ASSIGN_MINQ_TABLE(bit_depth, name) \
do { \
@@ -212,18 +210,23 @@ int vp9_estimate_bits_at_q(FRAME_TYPE frame_type, int q, int mbs,
int vp9_rc_clamp_pframe_target_size(const VP9_COMP *const cpi, int target) {
const RATE_CONTROL *rc = &cpi->rc;
const VP9EncoderConfig *oxcf = &cpi->oxcf;
- const int min_frame_target =
- VPXMAX(rc->min_frame_bandwidth, rc->avg_frame_bandwidth >> 5);
- if (target < min_frame_target) target = min_frame_target;
- if (cpi->refresh_golden_frame && rc->is_src_frame_alt_ref) {
- // If there is an active ARF at this location use the minimum
- // bits on this frame even if it is a constructed arf.
- // The active maximum quantizer insures that an appropriate
- // number of bits will be spent if needed for constructed ARFs.
- target = min_frame_target;
+
+ if (cpi->oxcf.pass != 2) {
+ const int min_frame_target =
+ VPXMAX(rc->min_frame_bandwidth, rc->avg_frame_bandwidth >> 5);
+ if (target < min_frame_target) target = min_frame_target;
+ if (cpi->refresh_golden_frame && rc->is_src_frame_alt_ref) {
+ // If there is an active ARF at this location use the minimum
+ // bits on this frame even if it is a constructed arf.
+ // The active maximum quantizer insures that an appropriate
+ // number of bits will be spent if needed for constructed ARFs.
+ target = min_frame_target;
+ }
}
+
// Clip the frame target to the maximum allowed value.
if (target > rc->max_frame_bandwidth) target = rc->max_frame_bandwidth;
+
if (oxcf->rc_max_inter_bitrate_pct) {
const int max_rate =
rc->avg_frame_bandwidth * oxcf->rc_max_inter_bitrate_pct / 100;
diff --git a/vp9/encoder/vp9_ratectrl.h b/vp9/encoder/vp9_ratectrl.h
index f851e4286..61e50e9f7 100644
--- a/vp9/encoder/vp9_ratectrl.h
+++ b/vp9/encoder/vp9_ratectrl.h
@@ -35,6 +35,8 @@ extern "C" {
#define FIXED_GF_INTERVAL 8 // Used in some testing modes only
#define ONEHALFONLY_RESIZE 0
+#define FRAME_OVERHEAD_BITS 200
+
typedef enum {
INTER_NORMAL = 0,
INTER_HIGH = 1,