Commit 193fa5c8 authored by Marco Paniconi's avatar Marco Paniconi
Browse files

Keep buffer clipped to maximum in change_config.

Under a configuration change, where the bitrate suddenly decreases,
the buffer level may be larger than maximum allowed (for that first frame to be encoded after change_config).
This change keeps it clipped to its maximum level.

Change-Id: I4d0b5b3d1fd8148600dd39e02bd630c9464baba5
parent c8e8d3a4
...@@ -1623,6 +1623,12 @@ void vp8_change_config(VP8_COMP *cpi, VP8_CONFIG *oxcf) ...@@ -1623,6 +1623,12 @@ void vp8_change_config(VP8_COMP *cpi, VP8_CONFIG *oxcf)
cpi->oxcf.maximum_buffer_size = cpi->oxcf.maximum_buffer_size =
rescale((int)cpi->oxcf.maximum_buffer_size, rescale((int)cpi->oxcf.maximum_buffer_size,
cpi->oxcf.target_bandwidth, 1000); cpi->oxcf.target_bandwidth, 1000);
// Under a configuration change, where maximum_buffer_size may change,
// keep buffer level clipped to the maximum allowed buffer size.
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;
}
/* Set up frame rate and related parameters rate control values. */ /* Set up frame rate and related parameters rate control values. */
vp8_new_framerate(cpi, cpi->framerate); vp8_new_framerate(cpi, cpi->framerate);
......
...@@ -1392,6 +1392,12 @@ void vp9_change_config(VP9_PTR ptr, VP9_CONFIG *oxcf) { ...@@ -1392,6 +1392,12 @@ void vp9_change_config(VP9_PTR ptr, VP9_CONFIG *oxcf) {
else else
cpi->oxcf.maximum_buffer_size = rescale(cpi->oxcf.maximum_buffer_size, cpi->oxcf.maximum_buffer_size = rescale(cpi->oxcf.maximum_buffer_size,
cpi->oxcf.target_bandwidth, 1000); cpi->oxcf.target_bandwidth, 1000);
// Under a configuration change, where maximum_buffer_size may change,
// keep buffer level clipped to the maximum allowed buffer size.
if (cpi->rc.bits_off_target > cpi->oxcf.maximum_buffer_size) {
cpi->rc.bits_off_target = cpi->oxcf.maximum_buffer_size;
cpi->rc.buffer_level = cpi->rc.bits_off_target;
}
// Set up frame rate and related parameters rate control values. // Set up frame rate and related parameters rate control values.
vp9_new_framerate(cpi, cpi->oxcf.framerate); vp9_new_framerate(cpi, cpi->oxcf.framerate);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment