enc->enc_pic.rc.frame_rate_num = pic->rate_ctrl.frame_rate_num;
enc->enc_pic.rc.frame_rate_den = pic->rate_ctrl.frame_rate_den;
enc->enc_pic.rc.max_qp = 51;
- enc->enc_pic.rc.vbv_buffer_size = pic->rate_ctrl.vbv_buffer_size;
+
+ /* For CBR mode, to guarantee bitrate of generated stream complies with
+ * target bitrate (e.g. no over +/-10%), vbv_buffer_size should be same
+ * as target bitrate.
+ */
+ if (enc->enc_pic.rc.rc_method == PIPE_H264_ENC_RATE_CONTROL_METHOD_CONSTANT) {
+ enc->enc_pic.rc.vbv_buffer_size = pic->rate_ctrl.target_bitrate;
+ } else {
+ enc->enc_pic.rc.vbv_buffer_size = pic->rate_ctrl.vbv_buffer_size;
+ }
+
enc->enc_pic.rc.vbv_buf_lv = pic->rate_ctrl.vbv_buf_lv;
enc->enc_pic.rc.fill_data_enable = pic->rate_ctrl.fill_data_enable;
enc->enc_pic.rc.enforce_hrd = pic->rate_ctrl.enforce_hrd;