summaryrefslogtreecommitdiff
path: root/vp8/encoder/firstpass.c
diff options
context:
space:
mode:
authorPaul Wilkins <paulwilkins@google.com>2012-01-11 14:05:57 +0000
committerPaul Wilkins <paulwilkins@google.com>2012-01-17 17:42:46 +0000
commitcf561bad1d027da0b28b4cd75036942e97d4fef7 (patch)
treebb0463901124f79e6b1c42a712432faeb4baed62 /vp8/encoder/firstpass.c
parent483b262bab7cae4387dae4d07d126fb9915cc6c8 (diff)
downloadlibvpx-cf561bad1d027da0b28b4cd75036942e97d4fef7.tar
libvpx-cf561bad1d027da0b28b4cd75036942e97d4fef7.tar.gz
libvpx-cf561bad1d027da0b28b4cd75036942e97d4fef7.tar.bz2
libvpx-cf561bad1d027da0b28b4cd75036942e97d4fef7.zip
Rate control on static scenes plus Y2dc delta Q fix.
A problem can arise on static clips with force key frames where attempts to avoid popping lead to a progressive reduction in key frame Q that ultimately may lead to unexpected overspend against the rate target. The changes in this patch help to insure that in such clips the quality of the key frames across the clip is more uniform (rather than starting bad and getting better - especially at low target rates). This patch also includes a fix that removes a delta on the Y2DC when the baseline q index < 4 as this is no longer needed. There is also a fix to try and prevent repeat single step Q adjustment in the recode loop leading to lots of recodes, especially where the use of forced skips as part of segmentation has made the impact of Q on the number of bits generated much smaller. Patch 2: Amend "last_boosted_qindex" calculation for arf overlay frames. Change-Id: Ia1feeb79ed8ed014e4239994fcf5e58e68fd9459
Diffstat (limited to 'vp8/encoder/firstpass.c')
-rw-r--r--vp8/encoder/firstpass.c24
1 files changed, 20 insertions, 4 deletions
diff --git a/vp8/encoder/firstpass.c b/vp8/encoder/firstpass.c
index 901404617..19ae70684 100644
--- a/vp8/encoder/firstpass.c
+++ b/vp8/encoder/firstpass.c
@@ -3032,10 +3032,26 @@ static void find_next_key_frame(VP8_COMP *cpi, FIRSTPASS_STATS *this_frame)
// We do three calculations for kf size.
// The first is based on the error score for the whole kf group.
- // The second (optionaly) on the key frames own error if this is smaller than the average for the group.
- // The final one insures that the frame receives at least the allocation it would have received based on its own error score vs the error score remaining
-
- allocation_chunks = ((cpi->twopass.frames_to_key - 1) * 100) + kf_boost; // cpi->twopass.frames_to_key-1 because key frame itself is taken care of by kf_boost
+ // The second (optionaly) on the key frames own error if this is
+ // smaller than the average for the group.
+ // The final one insures that the frame receives at least the
+ // allocation it would have received based on its own error score vs
+ // the error score remaining
+ // Special case if the sequence appears almost totaly static
+ // as measured by the decay accumulator. In this case we want to
+ // spend almost all of the bits on the key frame.
+ // cpi->twopass.frames_to_key-1 because key frame itself is taken
+ // care of by kf_boost.
+ if ( decay_accumulator >= 0.99 )
+ {
+ allocation_chunks =
+ ((cpi->twopass.frames_to_key - 1) * 10) + kf_boost;
+ }
+ else
+ {
+ allocation_chunks =
+ ((cpi->twopass.frames_to_key - 1) * 100) + kf_boost;
+ }
// Normalize Altboost and allocations chunck down to prevent overflow
while (kf_boost > 1000)