summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Grange <agrange@google.com>2011-11-07 16:28:13 -0800
committerAdrian Grange <agrange@google.com>2011-11-07 16:28:13 -0800
commit9dc95b0a122b5f519117c0be6525d980c32f507e (patch)
tree5e78f6630fe277f4aab99399acc4424d1077d1a3
parentf89ea3432fd213f0e7c65eceaf6553cb3191306d (diff)
downloadlibvpx-9dc95b0a122b5f519117c0be6525d980c32f507e.tar
libvpx-9dc95b0a122b5f519117c0be6525d980c32f507e.tar.gz
libvpx-9dc95b0a122b5f519117c0be6525d980c32f507e.tar.bz2
libvpx-9dc95b0a122b5f519117c0be6525d980c32f507e.zip
Added check to make sure maximum buffer size not exceeded
Added code to clip the buffer level to the maximum buffer size. Without this the buffer level would increase unchecked. This bug was found when encoding an essentially static scene at 2Mb/s. The encoder is unable to generate frames consistent with the high data-rate because Q bottoms out at Qmin. As frames generated are consistently undersized the buffer level increases and does not get checked against the maximum size specified by the user (or default). Change-Id: Id8a3c6323d3246da50f7cb53ddbf78b5528032c6
-rw-r--r--vp8/encoder/onyx_if.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c
index 5a1cf1f9f..644e77aac 100644
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -4525,6 +4525,10 @@ static void encode_frame_to_data_rate
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;
cpi->rolling_actual_bits = ((cpi->rolling_actual_bits * 3) + cpi->projected_frame_size + 2) / 4;
@@ -4552,6 +4556,10 @@ static void encode_frame_to_data_rate
lc->bits_off_target += bits_off_for_this_layer;
+ // Clip buffer level to maximum buffer size for the layer
+ if (lc->bits_off_target > lc->maximum_buffer_size)
+ lc->bits_off_target = lc->maximum_buffer_size;
+
lc->total_actual_bits += cpi->projected_frame_size;
lc->total_target_vs_actual += bits_off_for_this_layer;
lc->buffer_level = lc->bits_off_target;