Lines Matching refs:ps_cbr_buffer
126 static void set_upper_lower_vbv_threshold(cbr_buffer_t *ps_cbr_buffer, WORD32 i4_bits_per_frm) in set_upper_lower_vbv_threshold() argument
131 ps_cbr_buffer->i4_upr_thr[i] = in set_upper_lower_vbv_threshold()
132 (WORD32)(((LWORD64)ps_cbr_buffer->i4_buffer_size >> 4) * UPPER_THRESHOLD_EBF_Q4); in set_upper_lower_vbv_threshold()
133 if(ps_cbr_buffer->e_rc_type == VBR_STREAMING) in set_upper_lower_vbv_threshold()
136 if(ps_cbr_buffer->i4_vbr_no_peak_rate_duration_limit) in set_upper_lower_vbv_threshold()
137 ps_cbr_buffer->i4_low_thr[i] = 0; in set_upper_lower_vbv_threshold()
139 ps_cbr_buffer->i4_low_thr[i] = ps_cbr_buffer->i4_inter_frame_int * i4_bits_per_frm; in set_upper_lower_vbv_threshold()
143 if(ps_cbr_buffer->i4_inter_frame_int == 1) in set_upper_lower_vbv_threshold()
144 ps_cbr_buffer->i4_low_thr[i] = 0; in set_upper_lower_vbv_threshold()
147 ps_cbr_buffer->i4_low_thr[i] = ps_cbr_buffer->i4_inter_frame_int * i4_bits_per_frm; in set_upper_lower_vbv_threshold()
152 if(ps_cbr_buffer->i4_low_thr[i] < (ps_cbr_buffer->i4_buffer_size >> 6)) in set_upper_lower_vbv_threshold()
153 ps_cbr_buffer->i4_low_thr[i] = (ps_cbr_buffer->i4_buffer_size >> 6); in set_upper_lower_vbv_threshold()
155 if(ps_cbr_buffer->i4_low_thr[i] > (ps_cbr_buffer->i4_buffer_size >> 3)) //KISH_DEBUG in set_upper_lower_vbv_threshold()
156 ps_cbr_buffer->i4_low_thr[i] = (ps_cbr_buffer->i4_buffer_size >> 3); in set_upper_lower_vbv_threshold()
157 ASSERT(ps_cbr_buffer->i4_upr_thr[i] > ps_cbr_buffer->i4_low_thr[i]); in set_upper_lower_vbv_threshold()
174 cbr_buffer_t *ps_cbr_buffer, in init_cbr_buffer() argument
195 ps_cbr_buffer->i4_ebf = 0; in init_cbr_buffer()
196 ps_cbr_buffer->i4_ebf_estimate = 0; in init_cbr_buffer()
197 ps_cbr_buffer->i8_ebf_bit_alloc = 0; in init_cbr_buffer()
198 ps_cbr_buffer->i8_credit_level = 0; in init_cbr_buffer()
199 ps_cbr_buffer->e_rc_type = e_rc_type; in init_cbr_buffer()
200 ps_cbr_buffer->i4_capped_vbr_on = i4_capped_vbr_flag; in init_cbr_buffer()
202 ps_cbr_buffer->i4_vbr_no_peak_rate_duration_limit = 0; in init_cbr_buffer()
203 ps_cbr_buffer->i8_num_frames_encoded = 0; in init_cbr_buffer()
204 ps_cbr_buffer->i8_tot_frm_to_be_encoded = i8_num_frames_to_encode; in init_cbr_buffer()
205 ps_cbr_buffer->i4_cbr_rc_pass = i4_cbr_rc_pass; in init_cbr_buffer()
206 ps_cbr_buffer->i4_inter_frame_int = i4_inter_frm_int; in init_cbr_buffer()
207 ps_cbr_buffer->i4_intra_frame_int = u4_intra_frm_int; in init_cbr_buffer()
208 ps_cbr_buffer->f_max_dur_peak_rate = f_max_dur_peak_rate; in init_cbr_buffer()
214 ps_cbr_buffer->i4_drain_bits_per_frame[i] = i4_bits_per_frm[i]; in init_cbr_buffer()
216 init_error_bits(ps_cbr_buffer->aps_bpf_error_bits[i], i4_tgt_frm_rate, u4_bit_rate); in init_cbr_buffer()
224 ps_cbr_buffer->i4_buffer_size = (WORD32)u4_vbv_buf_size; in init_cbr_buffer()
225 ps_cbr_buffer->i4_is_cbr_mode = 1; in init_cbr_buffer()
226 ps_cbr_buffer->i4_peak_drain_rate_frame = i4_bits_per_frm[0]; in init_cbr_buffer()
228 ps_cbr_buffer->u4_vbr_max_bit_deviation = ps_cbr_buffer->i4_buffer_size; in init_cbr_buffer()
233 ps_cbr_buffer->i4_buffer_size = (WORD32)u4_vbv_buf_size; in init_cbr_buffer()
237 ps_cbr_buffer->i4_vbr_no_peak_rate_duration_limit = 1; in init_cbr_buffer()
267 ps_cbr_buffer->u4_vbr_max_bit_deviation = u8_vbr_max_bit_deviation; in init_cbr_buffer()
269 ps_cbr_buffer->i4_is_cbr_mode = 0; in init_cbr_buffer()
271 u4_peak_bit_rate, 1000, i4_tgt_frm_rate, ps_cbr_buffer->i4_peak_drain_rate_frame); in init_cbr_buffer()
279 if(ps_cbr_buffer->i4_buffer_size > (WORD32)u4_vbv_buf_size) in init_cbr_buffer()
281 ps_cbr_buffer->i4_buffer_size = u4_vbv_buf_size; in init_cbr_buffer()
293 set_upper_lower_vbv_threshold(ps_cbr_buffer, i4_bits_per_frm[0]); in init_cbr_buffer()
296 ps_cbr_buffer->ai4_bit_rate[i] = u4_bit_rate; in init_cbr_buffer()
299 ps_cbr_buffer->ai4_num_pics_in_delay_period[i] = u4_num_pics_in_delay_prd[i]; in init_cbr_buffer()
301 ps_cbr_buffer->i4_tgt_frm_rate = i4_tgt_frm_rate; in init_cbr_buffer()
302 ps_cbr_buffer->i4_max_delay = i4_buffer_delay; in init_cbr_buffer()
303 ps_cbr_buffer->u4_max_vbv_buf_size = u4_vbv_buf_size; in init_cbr_buffer()
304 ps_cbr_buffer->u4_num_frms_in_delay = u4_num_frames_in_delay; in init_cbr_buffer()
320 cbr_buffer_t *ps_cbr_buffer, in cbr_buffer_constraint_check() argument
328 ? ps_cbr_buffer->i4_drain_bits_per_frame[0] in cbr_buffer_constraint_check()
329 : ps_cbr_buffer->i4_drain_bits_per_frame[1]; in cbr_buffer_constraint_check()
331 ? get_error_bits(ps_cbr_buffer->aps_bpf_error_bits[0]) in cbr_buffer_constraint_check()
332 : get_error_bits(ps_cbr_buffer->aps_bpf_error_bits[1]); in cbr_buffer_constraint_check()
337 (WORD32)(ps_cbr_buffer->i4_upr_thr[e_pic_type] - ps_cbr_buffer->i4_ebf_estimate); in cbr_buffer_constraint_check()
345 ps_cbr_buffer->i4_low_thr[e_pic_type] - in cbr_buffer_constraint_check()
346 (ps_cbr_buffer->i4_ebf_estimate - i4_drain_bits_per_frame - i4_error_bits)); in cbr_buffer_constraint_check()
370 cbr_buffer_t *ps_cbr_buffer, in vbr_stream_buffer_constraint_check() argument
382 (ps_cbr_buffer->u4_num_frms_in_delay * ps_cbr_buffer->i4_peak_drain_rate_frame) - in vbr_stream_buffer_constraint_check()
383 ps_cbr_buffer->i4_ebf_estimate); in vbr_stream_buffer_constraint_check()
385 if(i4_max_tgt_bits > ps_cbr_buffer->i4_upr_thr[e_pic_type] - ps_cbr_buffer->i4_ebf_estimate) in vbr_stream_buffer_constraint_check()
388 (WORD32)(ps_cbr_buffer->i4_upr_thr[e_pic_type] - ps_cbr_buffer->i4_ebf_estimate); in vbr_stream_buffer_constraint_check()
394 if(ps_cbr_buffer->i4_vbr_no_peak_rate_duration_limit) in vbr_stream_buffer_constraint_check()
397 if(ps_cbr_buffer->i8_ebf_bit_alloc < 0 && ps_cbr_buffer->i4_cbr_rc_pass != 2) in vbr_stream_buffer_constraint_check()
398 i4_min_tgt_bits = (ps_cbr_buffer->i4_drain_bits_per_frame[0] >> 1); in vbr_stream_buffer_constraint_check()
403 i4_min_tgt_bits = (WORD32)(ps_cbr_buffer->i4_low_thr[0] - ps_cbr_buffer->i8_ebf_bit_alloc); in vbr_stream_buffer_constraint_check()
435 cbr_buffer_t *ps_cbr_buffer, in get_cbr_buffer_status() argument
444 ? get_error_bits(ps_cbr_buffer->aps_bpf_error_bits[0]) in get_cbr_buffer_status()
445 : get_error_bits(ps_cbr_buffer->aps_bpf_error_bits[1]); in get_cbr_buffer_status()
447 ? ps_cbr_buffer->i4_drain_bits_per_frame[0] in get_cbr_buffer_status()
448 : ps_cbr_buffer->i4_drain_bits_per_frame[1]; in get_cbr_buffer_status()
451 i4_cur_enc_buf = ps_cbr_buffer->i4_ebf + i4_tot_consumed_bits; in get_cbr_buffer_status()
454 if(i4_cur_enc_buf > ps_cbr_buffer->i4_buffer_size) in get_cbr_buffer_status()
457 i4_cur_enc_buf = ps_cbr_buffer->i4_buffer_size; in get_cbr_buffer_status()
494 pi4_num_bits_to_prevent_overflow[0] = (ps_cbr_buffer->i4_buffer_size - i4_cur_enc_buf); in get_cbr_buffer_status()
509 cbr_buffer_t *ps_cbr_buffer, WORD32 i4_tot_consumed_bits, picture_type_e e_pic_type) in update_cbr_buffer() argument
513 ? get_error_bits(ps_cbr_buffer->aps_bpf_error_bits[0]) in update_cbr_buffer()
514 : get_error_bits(ps_cbr_buffer->aps_bpf_error_bits[1]); in update_cbr_buffer()
516 ? ps_cbr_buffer->i4_drain_bits_per_frame[0] in update_cbr_buffer()
517 : ps_cbr_buffer->i4_drain_bits_per_frame[1]; in update_cbr_buffer()
519 ps_cbr_buffer->i8_num_frames_encoded++; in update_cbr_buffer()
520 if(ps_cbr_buffer->e_rc_type == VBR_STREAMING && ps_cbr_buffer->i8_tot_frm_to_be_encoded < 0) in update_cbr_buffer()
522 LWORD64 i8_max_bit_dev_allowed = ps_cbr_buffer->ai4_bit_rate[0]; in update_cbr_buffer()
523 LWORD64 approx_file_size = ps_cbr_buffer->i8_num_frames_encoded * in update_cbr_buffer()
524 ps_cbr_buffer->ai4_bit_rate[0] * 1000 / in update_cbr_buffer()
525 ps_cbr_buffer->i4_tgt_frm_rate; in update_cbr_buffer()
530 if(i8_max_bit_dev_allowed > (VBR_MAX_BIT_DEV_SEC * ps_cbr_buffer->ai4_bit_rate[0])) in update_cbr_buffer()
531 i8_max_bit_dev_allowed = (VBR_MAX_BIT_DEV_SEC * ps_cbr_buffer->ai4_bit_rate[0]); in update_cbr_buffer()
533 ps_cbr_buffer->u4_max_vbv_buf_size = (UWORD32)i8_max_bit_dev_allowed; in update_cbr_buffer()
536 if(ps_cbr_buffer->i4_is_cbr_mode != 0) in update_cbr_buffer()
538 ps_cbr_buffer->i4_ebf += i4_tot_consumed_bits; in update_cbr_buffer()
539 ps_cbr_buffer->i8_ebf_bit_alloc += i4_tot_consumed_bits; in update_cbr_buffer()
542 ps_cbr_buffer->i4_ebf -= (i4_drain_bits_per_frame + i4_error_bits); in update_cbr_buffer()
543 ps_cbr_buffer->i8_ebf_bit_alloc -= (i4_drain_bits_per_frame + i4_error_bits); in update_cbr_buffer()
547 ps_cbr_buffer->i4_ebf += i4_tot_consumed_bits; in update_cbr_buffer()
548 ps_cbr_buffer->i4_ebf -= in update_cbr_buffer()
549 ((MIN(ps_cbr_buffer->i4_peak_drain_rate_frame, ps_cbr_buffer->i4_ebf)) + i4_error_bits); in update_cbr_buffer()
551 ps_cbr_buffer->i8_ebf_bit_alloc += i4_tot_consumed_bits; in update_cbr_buffer()
552 ps_cbr_buffer->i8_ebf_bit_alloc -= in update_cbr_buffer()
553 (ps_cbr_buffer->i4_drain_bits_per_frame[0] + i4_error_bits); in update_cbr_buffer()
555 ps_cbr_buffer->i8_credit_level += i4_tot_consumed_bits; in update_cbr_buffer()
556 ps_cbr_buffer->i8_credit_level -= in update_cbr_buffer()
557 (ps_cbr_buffer->i4_drain_bits_per_frame[0] + i4_error_bits); in update_cbr_buffer()
559 if(!ps_cbr_buffer->i4_vbr_no_peak_rate_duration_limit) in update_cbr_buffer()
561 if(ps_cbr_buffer->i8_ebf_bit_alloc < 0) in update_cbr_buffer()
562 ps_cbr_buffer->i8_ebf_bit_alloc = in update_cbr_buffer()
568 if(ps_cbr_buffer->i4_ebf < 0) in update_cbr_buffer()
571 ps_cbr_buffer->i4_ebf = 0; in update_cbr_buffer()
574 if(ps_cbr_buffer->i4_ebf > ps_cbr_buffer->i4_buffer_size) in update_cbr_buffer()
577 ps_cbr_buffer->i4_ebf = ps_cbr_buffer->i4_buffer_size; in update_cbr_buffer()
580 ps_cbr_buffer->i4_ebf_estimate = ps_cbr_buffer->i4_ebf; in update_cbr_buffer()
583 "VBR ebf = %d bebf = %d ", ps_cbr_buffer->i4_ebf, ps_cbr_buffer->i8_ebf_bit_alloc); in update_cbr_buffer()
586 update_error_bits(ps_cbr_buffer->aps_bpf_error_bits[i]); in update_cbr_buffer()
601 cbr_buffer_t *ps_cbr_buffer, WORD32 i4_tot_consumed_bits, picture_type_e e_pic_type) in get_cbr_bits_to_stuff() argument
605 ? get_error_bits(ps_cbr_buffer->aps_bpf_error_bits[0]) in get_cbr_bits_to_stuff()
606 : get_error_bits(ps_cbr_buffer->aps_bpf_error_bits[1]); in get_cbr_bits_to_stuff()
608 ? ps_cbr_buffer->i4_drain_bits_per_frame[0] in get_cbr_bits_to_stuff()
609 : ps_cbr_buffer->i4_drain_bits_per_frame[1]; in get_cbr_bits_to_stuff()
614 i4_drain_bits_per_frame + i4_error_bits - (ps_cbr_buffer->i4_ebf + i4_tot_consumed_bits); in get_cbr_bits_to_stuff()
628 cbr_buffer_t *ps_cbr_buffer, WORD32 *i4_bit_rate, WORD32 i4_peak_bitrate) in change_cbr_vbv_bit_rate() argument
635 X_PROD_Y_DIV_Z(i4_bit_rate[i], 1000, ps_cbr_buffer->i4_tgt_frm_rate, i4_bits_per_frm[i]); in change_cbr_vbv_bit_rate()
637 ps_cbr_buffer->i4_drain_bits_per_frame[i] = i4_bits_per_frm[i]; in change_cbr_vbv_bit_rate()
640 change_bitrate_in_error_bits(ps_cbr_buffer->aps_bpf_error_bits[i], i4_bit_rate[i]); in change_cbr_vbv_bit_rate()
645 ps_cbr_buffer->i4_tgt_frm_rate, in change_cbr_vbv_bit_rate()
646 ps_cbr_buffer->i4_peak_drain_rate_frame); in change_cbr_vbv_bit_rate()
652 ps_cbr_buffer->i4_max_delay, in change_cbr_vbv_bit_rate()
654 ps_cbr_buffer->i4_buffer_size); //the delay term is supposed to remain constant in change_cbr_vbv_bit_rate()
656 ps_cbr_buffer->u4_max_vbv_buf_size = ps_cbr_buffer->i4_buffer_size; in change_cbr_vbv_bit_rate()
658 if(ps_cbr_buffer->i4_buffer_size > (WORD32)ps_cbr_buffer->u4_max_vbv_buf_size) in change_cbr_vbv_bit_rate()
660 ps_cbr_buffer->i4_buffer_size = ps_cbr_buffer->u4_max_vbv_buf_size; in change_cbr_vbv_bit_rate()
662 set_upper_lower_vbv_threshold(ps_cbr_buffer, i4_bits_per_frm[0]); in change_cbr_vbv_bit_rate()
663 if(ps_cbr_buffer->e_rc_type == CBR_NLDRC) in change_cbr_vbv_bit_rate()
665 ps_cbr_buffer->u4_vbr_max_bit_deviation = ps_cbr_buffer->i4_buffer_size; in change_cbr_vbv_bit_rate()
672 (ULWORD64)(ps_cbr_buffer->f_max_dur_peak_rate * i4_bit_rate[0]); in change_cbr_vbv_bit_rate()
674 (((LWORD64)i4_bit_rate[0] * 1000) / ps_cbr_buffer->i4_tgt_frm_rate) * in change_cbr_vbv_bit_rate()
675 (ps_cbr_buffer->i8_tot_frm_to_be_encoded - ps_cbr_buffer->i8_num_frames_encoded)); in change_cbr_vbv_bit_rate()
677 if(ps_cbr_buffer->f_max_dur_peak_rate > 0) in change_cbr_vbv_bit_rate()
679 (ULWORD64)(ps_cbr_buffer->f_max_dur_peak_rate * i4_bit_rate[0]); in change_cbr_vbv_bit_rate()
684 if(ps_cbr_buffer->i8_tot_frm_to_be_encoded > 0) in change_cbr_vbv_bit_rate()
697 ps_cbr_buffer->u4_vbr_max_bit_deviation = u8_vbr_max_bit_deviation; in change_cbr_vbv_bit_rate()
703 ps_cbr_buffer->ai4_bit_rate[i] = i4_bit_rate[i]; in change_cbr_vbv_bit_rate()
714 cbr_buffer_t *ps_cbr_buffer, UWORD32 *u4_num_pics_in_delay_prd) in change_cbr_vbv_num_pics_in_delay_period() argument
718 if(!ps_cbr_buffer->i4_is_cbr_mode) in change_cbr_vbv_num_pics_in_delay_period()
720 ps_cbr_buffer->i4_buffer_size = in change_cbr_vbv_num_pics_in_delay_period()
721 u4_num_pics_in_delay_prd[0] * ps_cbr_buffer->i4_drain_bits_per_frame[0] + in change_cbr_vbv_num_pics_in_delay_period()
722 u4_num_pics_in_delay_prd[1] * ps_cbr_buffer->i4_drain_bits_per_frame[1]; in change_cbr_vbv_num_pics_in_delay_period()
724 if(ps_cbr_buffer->i4_buffer_size > (WORD32)ps_cbr_buffer->u4_max_vbv_buf_size) in change_cbr_vbv_num_pics_in_delay_period()
726 ps_cbr_buffer->i4_buffer_size = ps_cbr_buffer->u4_max_vbv_buf_size; in change_cbr_vbv_num_pics_in_delay_period()
730 ps_cbr_buffer->i4_upr_thr[i] = in change_cbr_vbv_num_pics_in_delay_period()
731 ps_cbr_buffer->i4_buffer_size - (ps_cbr_buffer->i4_buffer_size >> 3); in change_cbr_vbv_num_pics_in_delay_period()
737 ps_cbr_buffer->ai4_num_pics_in_delay_period[i] = u4_num_pics_in_delay_prd[i]; in change_cbr_vbv_num_pics_in_delay_period()
749 void cbr_modify_ebf_estimate(cbr_buffer_t *ps_cbr_buffer, WORD32 i4_bit_error) in cbr_modify_ebf_estimate() argument
751 ps_cbr_buffer->i4_ebf_estimate = ps_cbr_buffer->i4_ebf + i4_bit_error; in cbr_modify_ebf_estimate()
752 if(ps_cbr_buffer->i4_ebf_estimate < 0) in cbr_modify_ebf_estimate()
754 ps_cbr_buffer->i4_ebf_estimate = 0; in cbr_modify_ebf_estimate()
756 else if(ps_cbr_buffer->i4_ebf_estimate > ps_cbr_buffer->i4_buffer_size) in cbr_modify_ebf_estimate()
758 ps_cbr_buffer->i4_ebf_estimate = ps_cbr_buffer->i4_buffer_size; in cbr_modify_ebf_estimate()
770 WORD32 get_cbr_buffer_size(cbr_buffer_t *ps_cbr_buffer) in get_cbr_buffer_size() argument
772 return (ps_cbr_buffer->i4_buffer_size); in get_cbr_buffer_size()
784 void change_cbr_vbv_tgt_frame_rate(cbr_buffer_t *ps_cbr_buffer, WORD32 i4_tgt_frm_rate) in change_cbr_vbv_tgt_frame_rate() argument
791 X_PROD_Y_DIV_Z(ps_cbr_buffer->ai4_bit_rate[i], 1000, i4_tgt_frm_rate, i4_bits_per_frm[i]); in change_cbr_vbv_tgt_frame_rate()
793 ps_cbr_buffer->i4_drain_bits_per_frame[i] = i4_bits_per_frm[i]; in change_cbr_vbv_tgt_frame_rate()
795 change_frm_rate_in_error_bits(ps_cbr_buffer->aps_bpf_error_bits[i], i4_tgt_frm_rate); in change_cbr_vbv_tgt_frame_rate()
799 if(!ps_cbr_buffer->i4_is_cbr_mode) in change_cbr_vbv_tgt_frame_rate()
802 ps_cbr_buffer->i4_buffer_size = ps_cbr_buffer->ai4_num_pics_in_delay_period[0] * in change_cbr_vbv_tgt_frame_rate()
803 ps_cbr_buffer->i4_drain_bits_per_frame[0] + in change_cbr_vbv_tgt_frame_rate()
804 ps_cbr_buffer->ai4_num_pics_in_delay_period[1] * in change_cbr_vbv_tgt_frame_rate()
805 ps_cbr_buffer->i4_drain_bits_per_frame[1]; in change_cbr_vbv_tgt_frame_rate()
808 if(ps_cbr_buffer->i4_buffer_size > (WORD32)ps_cbr_buffer->u4_max_vbv_buf_size) in change_cbr_vbv_tgt_frame_rate()
810 ps_cbr_buffer->i4_buffer_size = ps_cbr_buffer->u4_max_vbv_buf_size; in change_cbr_vbv_tgt_frame_rate()
824 ps_cbr_buffer->i4_upr_thr[i4_i] = in change_cbr_vbv_tgt_frame_rate()
825 ps_cbr_buffer->i4_buffer_size - (ps_cbr_buffer->i4_buffer_size >> 3); in change_cbr_vbv_tgt_frame_rate()
829 ps_cbr_buffer->i4_low_thr[i4_i] = i4_bits_per_frm[i4_index]; in change_cbr_vbv_tgt_frame_rate()
833 ps_cbr_buffer->i4_tgt_frm_rate = i4_tgt_frm_rate; in change_cbr_vbv_tgt_frame_rate()
843 void change_cbr_buffer_delay(cbr_buffer_t *ps_cbr_buffer, WORD32 i4_buffer_delay) in change_cbr_buffer_delay() argument
848 if(ps_cbr_buffer->i4_is_cbr_mode) in change_cbr_buffer_delay()
851 ps_cbr_buffer->ai4_bit_rate[0], i4_buffer_delay, 1000, ps_cbr_buffer->i4_buffer_size); in change_cbr_buffer_delay()
854 if(ps_cbr_buffer->i4_buffer_size > (WORD32)ps_cbr_buffer->u4_max_vbv_buf_size) in change_cbr_buffer_delay()
856 ps_cbr_buffer->i4_buffer_size = ps_cbr_buffer->u4_max_vbv_buf_size; in change_cbr_buffer_delay()
868 ps_cbr_buffer->i4_upr_thr[i4_i] = in change_cbr_buffer_delay()
869 ps_cbr_buffer->i4_buffer_size - (ps_cbr_buffer->i4_buffer_size >> 3); in change_cbr_buffer_delay()
873 ps_cbr_buffer->i4_max_delay = i4_buffer_delay; in change_cbr_buffer_delay()
883 WORD32 get_cbr_buffer_delay(cbr_buffer_t *ps_cbr_buffer) in get_cbr_buffer_delay() argument
885 return (ps_cbr_buffer->i4_max_delay); in get_cbr_buffer_delay()
894 WORD32 get_cbr_ebf(cbr_buffer_t *ps_cbr_buffer) in get_cbr_ebf() argument
896 return (ps_cbr_buffer->i4_ebf); in get_cbr_ebf()
905 WORD32 get_cbr_max_ebf(cbr_buffer_t *ps_cbr_buffer) in get_cbr_max_ebf() argument
907 return (ps_cbr_buffer->i4_upr_thr[0]); in get_cbr_max_ebf()
917 void set_cbr_ebf(cbr_buffer_t *ps_cbr_buffer, WORD32 i32_init_ebf) in set_cbr_ebf() argument
919 ps_cbr_buffer->i4_ebf = i32_init_ebf; in set_cbr_ebf()
929 void update_cbr_buf_mismatch_bit(cbr_buffer_t *ps_cbr_buffer, WORD32 i4_error_bits) in update_cbr_buf_mismatch_bit() argument
931 ps_cbr_buffer->i4_ebf -= i4_error_bits; in update_cbr_buf_mismatch_bit()
932 ps_cbr_buffer->i8_ebf_bit_alloc -= i4_error_bits; in update_cbr_buf_mismatch_bit()
933 ps_cbr_buffer->i8_credit_level -= i4_error_bits; in update_cbr_buf_mismatch_bit()
942 LWORD64 get_num_frms_encoded(cbr_buffer_t *ps_cbr_buffer) in get_num_frms_encoded() argument
944 return ps_cbr_buffer->i8_num_frames_encoded; in get_num_frms_encoded()
953 LWORD64 get_num_frms_to_encode(cbr_buffer_t *ps_cbr_buffer) in get_num_frms_to_encode() argument
955 return ps_cbr_buffer->i8_tot_frm_to_be_encoded; in get_num_frms_to_encode()
965 WORD32 get_buf_max_drain_rate(cbr_buffer_t *ps_cbr_buffer) in get_buf_max_drain_rate() argument
967 if(ps_cbr_buffer->e_rc_type == VBR_STREAMING) in get_buf_max_drain_rate()
968 return ps_cbr_buffer->i4_peak_drain_rate_frame; in get_buf_max_drain_rate()
969 else if(ps_cbr_buffer->e_rc_type != CONST_QP) in get_buf_max_drain_rate()
972 ps_cbr_buffer->i4_peak_drain_rate_frame == ps_cbr_buffer->i4_drain_bits_per_frame[0]); in get_buf_max_drain_rate()
973 return ps_cbr_buffer->i4_drain_bits_per_frame[0]; in get_buf_max_drain_rate()
975 return ps_cbr_buffer->i4_drain_bits_per_frame[0]; in get_buf_max_drain_rate()
987 cbr_buffer_t *ps_cbr_buffer, in get_vbv_buffer_based_excess() argument
993 LWORD64 max_buffer_level = (LWORD64)((float)ps_cbr_buffer->i4_buffer_size * 0.8f); in get_vbv_buffer_based_excess()
999 if(ps_cbr_buffer->i4_upr_thr[0] < in get_vbv_buffer_based_excess()
1001 max_buffer_level = ps_cbr_buffer->i4_upr_thr[0]; in get_vbv_buffer_based_excess()
1003 if(ps_cbr_buffer->e_rc_type == VBR_STREAMING) in get_vbv_buffer_based_excess()
1005 ps_cbr_buffer->i4_peak_drain_rate_frame * ps_cbr_buffer->u4_num_frms_in_delay * 0.8f); in get_vbv_buffer_based_excess()
1012 ps_cbr_buffer->i4_buffer_size < in get_vbv_buffer_based_excess()
1013 ps_cbr_buffer->ai4_bit_rate in get_vbv_buffer_based_excess()
1022 (max_buffer_level - ps_cbr_buffer->i4_ebf)); in get_vbv_buffer_based_excess()
1028 ((float)ps_cbr_buffer->i4_buffer_size / ps_cbr_buffer->ai4_bit_rate[0] * in get_vbv_buffer_based_excess()
1029 ps_cbr_buffer->i4_tgt_frm_rate / 1000) + in get_vbv_buffer_based_excess()
1036 if(ps_cbr_buffer->e_rc_type == VBR_STREAMING) in get_vbv_buffer_based_excess()
1042 (float)ps_cbr_buffer->i4_peak_drain_rate_frame * in get_vbv_buffer_based_excess()
1043 ps_cbr_buffer->u4_num_frms_in_delay * 0.8f)) in get_vbv_buffer_based_excess()
1045 (float)ps_cbr_buffer->i4_peak_drain_rate_frame * in get_vbv_buffer_based_excess()
1046 ps_cbr_buffer->u4_num_frms_in_delay * 0.8f); in get_vbv_buffer_based_excess()
1067 cbr_buffer_t *ps_cbr_buffer, WORD32 i4_lap_complexity_q7, WORD32 i4_bit_alloc_period) in get_error_bits_for_desired_buf() argument
1069 if(ps_cbr_buffer->e_rc_type == CBR_NLDRC) in get_error_bits_for_desired_buf()
1077 i8_default_bits_in_period = (LWORD64)ps_cbr_buffer->ai4_bit_rate[0] * 1000 * in get_error_bits_for_desired_buf()
1078 i4_bit_alloc_period / ps_cbr_buffer->i4_tgt_frm_rate; in get_error_bits_for_desired_buf()
1081 if(ps_cbr_buffer->e_rc_type == VBR_STREAMING) in get_error_bits_for_desired_buf()
1084 ((LWORD64)ps_cbr_buffer->i4_peak_drain_rate_frame * i4_bit_alloc_period) - in get_error_bits_for_desired_buf()
1102 if(ps_cbr_buffer->e_rc_type == CBR_NLDRC) in get_error_bits_for_desired_buf()
1104 complexity_mov_buf_size = (LWORD64)ps_cbr_buffer->i4_upr_thr[0]; in get_error_bits_for_desired_buf()
1106 else if(ps_cbr_buffer->e_rc_type == VBR_STREAMING) in get_error_bits_for_desired_buf()
1108 complexity_mov_buf_size = ps_cbr_buffer->u4_vbr_max_bit_deviation; in get_error_bits_for_desired_buf()
1112 if(ps_cbr_buffer->i4_cbr_rc_pass == 2) in get_error_bits_for_desired_buf()
1121 error_bits = (LWORD64)(desired_buf_level - ps_cbr_buffer->i8_ebf_bit_alloc); in get_error_bits_for_desired_buf()
1148 if(abs_lap_complexity < 0.2f && ps_cbr_buffer->i8_ebf_bit_alloc >= 0) in get_error_bits_for_desired_buf()
1161 if(ps_cbr_buffer->i8_ebf_bit_alloc > in get_error_bits_for_desired_buf()
1162 (LWORD64)(ps_cbr_buffer->i4_buffer_size * 0.75)) in get_error_bits_for_desired_buf()
1186 if(ps_cbr_buffer->i8_ebf_bit_alloc > (ps_cbr_buffer->i4_buffer_size >> 1)) in get_error_bits_for_desired_buf()
1215 ps_cbr_buffer->i4_drain_bits_per_frame[0] * i4_bit_alloc_period; in get_error_bits_for_desired_buf()
1217 bit_dev_so_far = ps_cbr_buffer->i8_ebf_bit_alloc; in get_error_bits_for_desired_buf()
1218 credit_limit_level = ps_cbr_buffer->i8_credit_level; in get_error_bits_for_desired_buf()
1220 ps_cbr_buffer->u4_vbr_max_bit_deviation * 5 / ps_cbr_buffer->i4_drain_bits_per_frame[0]; in get_error_bits_for_desired_buf()
1221 if(Ravg_dur > 20 * ps_cbr_buffer->i8_tot_frm_to_be_encoded / 100) in get_error_bits_for_desired_buf()
1222 Ravg_dur = 20 * ps_cbr_buffer->i8_tot_frm_to_be_encoded / 100; in get_error_bits_for_desired_buf()
1227 if(ps_cbr_buffer->i4_cbr_rc_pass == 2) in get_error_bits_for_desired_buf()
1235 num_intra_in_clip = ps_cbr_buffer->i8_tot_frm_to_be_encoded / i4_bit_alloc_period; in get_error_bits_for_desired_buf()
1238 if(ps_cbr_buffer->i8_tot_frm_to_be_encoded < i4_bit_alloc_period) in get_error_bits_for_desired_buf()
1249 max_excess_bits = (ps_cbr_buffer->i4_peak_drain_rate_frame - in get_error_bits_for_desired_buf()
1250 ps_cbr_buffer->i4_drain_bits_per_frame[0]) * in get_error_bits_for_desired_buf()
1254 if(ps_cbr_buffer->i4_ebf > in get_error_bits_for_desired_buf()
1255 (ps_cbr_buffer->i4_upr_thr[0] - (WORD32)(max_excess_bits * 0.2))) in get_error_bits_for_desired_buf()
1264 ((LWORD64)ps_cbr_buffer->u4_vbr_max_bit_deviation * i4_bit_alloc_period * 12) >> 12; in get_error_bits_for_desired_buf()
1266 ((LWORD64)ps_cbr_buffer->u4_vbr_max_bit_deviation * i4_bit_alloc_period * 8) >> 12; in get_error_bits_for_desired_buf()
1269 if(i8_buf_based_limit_red < (((LWORD64)ps_cbr_buffer->u4_vbr_max_bit_deviation * 10) >> 7)) in get_error_bits_for_desired_buf()
1270 i8_buf_based_limit_red = (((LWORD64)ps_cbr_buffer->u4_vbr_max_bit_deviation * 10) >> 7); in get_error_bits_for_desired_buf()
1271 if(i8_buf_based_limit_inc < (((LWORD64)ps_cbr_buffer->u4_vbr_max_bit_deviation * 10) >> 7)) in get_error_bits_for_desired_buf()
1272 i8_buf_based_limit_inc = (((LWORD64)ps_cbr_buffer->u4_vbr_max_bit_deviation * 10) >> 7); in get_error_bits_for_desired_buf()
1277 if(1 != ps_cbr_buffer->i4_capped_vbr_on) in get_error_bits_for_desired_buf()
1290 if(1 != ps_cbr_buffer->i4_capped_vbr_on) in get_error_bits_for_desired_buf()
1303 if(credit_limit_level > ps_cbr_buffer->u4_vbr_max_bit_deviation) in get_error_bits_for_desired_buf()
1309 else if(credit_limit_level > (LWORD64)(ps_cbr_buffer->u4_vbr_max_bit_deviation * 0.8f)) in get_error_bits_for_desired_buf()
1314 ((ps_cbr_buffer->u4_vbr_max_bit_deviation - credit_limit_level) / in get_error_bits_for_desired_buf()
1315 (0.2f * ps_cbr_buffer->u4_vbr_max_bit_deviation)) * in get_error_bits_for_desired_buf()
1320 else if(credit_limit_level > (LWORD64)(ps_cbr_buffer->u4_vbr_max_bit_deviation * 0.2f)) in get_error_bits_for_desired_buf()
1326 credit_limit_level < (WORD32)(ps_cbr_buffer->u4_vbr_max_bit_deviation * 0.2f) && in get_error_bits_for_desired_buf()
1331 (credit_limit_level / (0.2f * ps_cbr_buffer->u4_vbr_max_bit_deviation)) * in get_error_bits_for_desired_buf()
1369 rc_type_e get_rc_type(cbr_buffer_t *ps_cbr_buffer) in get_rc_type() argument
1371 return (ps_cbr_buffer->e_rc_type); in get_rc_type()
1380 UWORD32 cbr_get_delay_frames(cbr_buffer_t *ps_cbr_buffer) in cbr_get_delay_frames() argument
1382 return (ps_cbr_buffer->u4_num_frms_in_delay); in cbr_get_delay_frames()