summaryrefslogtreecommitdiff
path: root/vp9
diff options
context:
space:
mode:
authorDeepa K G <deepa.kg@ittiam.com>2019-05-29 08:01:23 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-05-29 08:01:23 +0000
commit75e31e41d4b2a55fb71a43a3ac78e5226860b5e9 (patch)
tree9b4fa0fe218cfed6e67dafcfe7206edc8f23969d /vp9
parent0308a9a132612006056f9920c069a1942e49c26c (diff)
parent869d82d656eaea8f0db1df6364af4d22875103f4 (diff)
downloadlibvpx-75e31e41d4b2a55fb71a43a3ac78e5226860b5e9.tar
libvpx-75e31e41d4b2a55fb71a43a3ac78e5226860b5e9.tar.gz
libvpx-75e31e41d4b2a55fb71a43a3ac78e5226860b5e9.tar.bz2
libvpx-75e31e41d4b2a55fb71a43a3ac78e5226860b5e9.zip
Merge "Increase the bits allocated to key frame"
Diffstat (limited to 'vp9')
-rw-r--r--vp9/encoder/vp9_firstpass.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c
index 9b7f944b2..dfad3b4fa 100644
--- a/vp9/encoder/vp9_firstpass.c
+++ b/vp9/encoder/vp9_firstpass.c
@@ -2929,6 +2929,7 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
FIRSTPASS_STATS next_frame;
FIRSTPASS_STATS last_frame;
int kf_bits = 0;
+ int64_t max_kf_bits;
double decay_accumulator = 1.0;
double zero_motion_accumulator = 1.0;
double zero_motion_sum = 0.0;
@@ -3179,6 +3180,13 @@ static void find_next_key_frame(VP9_COMP *cpi, FIRSTPASS_STATS *this_frame) {
// Work out how many bits to allocate for the key frame itself.
kf_bits = calculate_boost_bits((rc->frames_to_key - 1), rc->kf_boost,
twopass->kf_group_bits);
+ // Based on the spatial complexity, increase the bits allocated to key frame.
+ kf_bits +=
+ (int)((twopass->kf_group_bits - kf_bits) * (kf_mod_err / kf_group_err));
+ max_kf_bits =
+ twopass->kf_group_bits - (rc->frames_to_key - 1) * FRAME_OVERHEAD_BITS;
+ max_kf_bits = lclamp(max_kf_bits, 0, INT_MAX);
+ kf_bits = VPXMIN(kf_bits, (int)max_kf_bits);
twopass->kf_group_bits -= kf_bits;