From fa25a31ed441e3e6475bffad4d340a88ae785cdf Mon Sep 17 00:00:00 2001 From: Adrian Grange Date: Mon, 7 Nov 2011 16:54:40 -0800 Subject: [PATCH] Additional clipping of buffer level to maximum buffer size Added additional check of buffer level against maximum buffer size. Change-Id: Iaf1fbaf008601161e402b43ce82c3dbc129bf740 --- vp8/encoder/onyx_if.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/vp8/encoder/onyx_if.c b/vp8/encoder/onyx_if.c index 644e77aac..496ef7110 100644 --- a/vp8/encoder/onyx_if.c +++ b/vp8/encoder/onyx_if.c @@ -3659,7 +3659,11 @@ static void encode_frame_to_data_rate else if (cpi->decimation_count > 0) { 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++; @@ -3676,9 +3680,11 @@ static void encode_frame_to_data_rate // Propagate bits saved by dropping the frame to higher layers for (i=cpi->current_layer+1; ioxcf.number_of_layers; i++) { - cpi->layer_context[i].bits_off_target - += cpi->av_per_frame_bandwidth; - cpi->layer_context[i].buffer_level = cpi->bits_off_target; + LAYER_CONTEXT *lc = &cpi->layer_context[i]; + lc->bits_off_target += cpi->av_per_frame_bandwidth; + if (lc->bits_off_target > lc->maximum_buffer_size) + lc->bits_off_target = lc->maximum_buffer_size; + lc->buffer_level = lc->bits_off_target; } }