For a large change in the target avg_frame_bandwidth, via the update in change_config()), reset the buffer_level to optimal_level. This fix prevents possible frame drops, where for example, encoder suddenly goes from lower to higher bitrate.
Unified · Split
| @@ -1868,6 +1868,7 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) { · 1867 unmodified lines | ||
| 1868 | 1868 | // Check for resetting the rc flags (rc_1_frame, rc_2_frame) if the |
| 1869 | 1869 | // configuration change has a large change in avg_frame_bandwidth. |
| 1870 | 1870 | // For SVC check for resetting based on spatial layer average bandwidth. |
| 1871 | + // Also reset buffer level to optimal level. | |
| 1871 | 1872 | if (cm->current_video_frame > 0) { |
| 1872 | 1873 | if (cpi->use_svc) { |
| 1873 | 1874 | vp9_svc_check_reset_layer_rc_flag(cpi); |
| @@ -1876,6 +1877,8 @@ void vp9_change_config(struct VP9_COMP *cpi, const VP9EncoderConfig *oxcf) { · 2 unmodified lines | ||
| 1876 | 1877 | rc->avg_frame_bandwidth < (rc->last_avg_frame_bandwidth >> 1)) { |
| 1877 | 1878 | rc->rc_1_frame = 0; |
| 1878 | 1879 | rc->rc_2_frame = 0; |
| 1880 | + rc->bits_off_target = rc->optimal_buffer_level; | |
| 1881 | + rc->buffer_level = rc->optimal_buffer_level; | |
| 1879 | 1882 | } |
| 1880 | 1883 | } |
| 1881 | 1884 | } |
| @@ -881,6 +881,8 @@ void vp9_svc_check_reset_layer_rc_flag(VP9_COMP *const cpi) { · 880 unmodified lines | ||
| 881 | 881 | RATE_CONTROL *lrc = &lc->rc; |
| 882 | 882 | lrc->rc_1_frame = 0; |
| 883 | 883 | lrc->rc_2_frame = 0; |
| 884 | + lrc->bits_off_target = lrc->optimal_buffer_level; | |
| 885 | + lrc->buffer_level = lrc->optimal_buffer_level; | |
| 884 | 886 | } |
| 885 | 887 | } |
| 886 | 888 | } |