ref: 2b1c2990a98f090d91ab3ca5c6c1e1ce7ee1a701
parent: 5825f942bcf625ae6d6b4cc653589c9cf89f84e6
author: Adrian Grange <agrange@google.com>
date: Tue Nov 15 11:39:53 EST 2011
Added clipping of the buffer level to maximum_buffer_size The buffer level was not being capped at the maximum decode buffer size specified by the user. In CBR mode this resulted in large files being generated immediately after a dramatic reduction in the data rate target. This fix should prevent this from happening. Change-Id: Iaf01c9fb037cf51515217a5834d6ee4fbb0cb853
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -3490,6 +3490,9 @@
{
cpi->decimation_count --;
cpi->bits_off_target += cpi->av_per_frame_bandwidth;
+ if (cpi->bits_off_target > cpi->oxcf.maximum_buffer_size)
+ cpi->bits_off_target = cpi->oxcf.maximum_buffer_size;
+
cm->current_video_frame++;
cpi->frames_since_key++;
@@ -4320,6 +4323,10 @@
cpi->bits_off_target -= cpi->projected_frame_size;
else
cpi->bits_off_target += cpi->av_per_frame_bandwidth - cpi->projected_frame_size;
+
+ // Clip the buffer level to the maximum specified buffer size
+ if (cpi->bits_off_target > cpi->oxcf.maximum_buffer_size)
+ cpi->bits_off_target = cpi->oxcf.maximum_buffer_size;
// Rolling monitors of whether we are over or underspending used to help regulate min and Max Q in two pass.
cpi->rolling_target_bits = ((cpi->rolling_target_bits * 3) + cpi->this_frame_target + 2) / 4;
--- a/vp8/encoder/ratectrl.c
+++ b/vp8/encoder/ratectrl.c
@@ -1029,6 +1029,8 @@
{
// Update the buffer level variable.
cpi->bits_off_target += cpi->av_per_frame_bandwidth;
+ if (cpi->bits_off_target > cpi->oxcf.maximum_buffer_size)
+ cpi->bits_off_target = cpi->oxcf.maximum_buffer_size;
cpi->buffer_level = cpi->bits_off_target;
}
else
--
⑨