1 /****************************************************************************** 2 * 3 * Copyright (C) 2015 The Android Open Source Project 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ***************************************************************************** 18 * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore 19 */ 20 21 #ifndef _BIT_ALLOCATION_H_ 22 #define _BIT_ALLOCATION_H_ 23 24 typedef struct bit_allocation_t *bit_allocation_handle; 25 26 WORD32 irc_ba_num_fill_use_free_memtab(bit_allocation_handle *pps_bit_allocation, 27 itt_memtab_t *ps_memtab, 28 ITT_FUNC_TYPE_E e_func_type); 29 30 void irc_ba_init_bit_allocation(bit_allocation_handle ps_bit_allocation, 31 pic_handling_handle ps_pic_handling, 32 WORD32 i4_num_intra_frm_interval, 33 WORD32 i4_bit_rate, 34 WORD32 i4_frm_rate, 35 WORD32 *u4_peak_bit_rate, 36 WORD32 i4_min_bitrate); 37 38 /* Estimates the number of texture bits required by the current frame */ 39 WORD32 irc_ba_get_cur_frm_est_texture_bits(bit_allocation_handle ps_bit_allocation, 40 rc_rd_model_handle *pps_rd_model, 41 est_sad_handle ps_est_sad, 42 pic_handling_handle ps_pic_handling, 43 picture_type_e e_pic_type); 44 45 /* Estimate the number of header bits required by the current frame */ 46 WORD32 irc_ba_get_cur_frm_est_header_bits(bit_allocation_handle ps_bit_allocation, 47 picture_type_e e_pic_type); 48 49 /* Get the remaining bits allocated in the period */ 50 WORD32 irc_ba_get_rem_bits_in_period(bit_allocation_handle ps_bit_allocation, 51 pic_handling_handle ps_pic_handling); 52 53 WORD32 irc_ba_get_frame_rate(bit_allocation_handle ps_bit_allocation); 54 55 WORD32 irc_ba_get_bit_rate(bit_allocation_handle ps_bit_allocation); 56 void irc_ba_get_peak_bit_rate(bit_allocation_handle ps_bit_allocation, 57 WORD32 *pi4_peak_bit_rate); 58 59 /* Updates the bit allocation module with the actual encoded values */ 60 void irc_ba_update_cur_frm_consumed_bits(bit_allocation_handle ps_bit_allocation, 61 pic_handling_handle ps_pic_handling, 62 WORD32 i4_total_frame_bits, 63 WORD32 i4_model_updation_hdr_bits, 64 picture_type_e e_pic_type, 65 UWORD8 u1_is_scd, 66 WORD32 i4_last_frm_in_gop); 67 68 void irc_ba_check_and_update_bit_allocation(bit_allocation_handle ps_bit_allocation, 69 pic_handling_handle ps_pic_handling, 70 WORD32 i4_cur_buf_size, 71 WORD32 i4_max_buf_size, 72 WORD32 i4_max_bits_inflow_per_frm, 73 WORD32 i4_tot_frame_bits); 74 75 /* Based on the change in frame/bit rate update the remaining bits in period */ 76 void irc_ba_change_remaining_bits_in_period(bit_allocation_handle ps_bit_allocation, 77 pic_handling_handle ps_pic_handling, 78 WORD32 i4_bit_rate, 79 WORD32 i4_frame_rate, 80 WORD32 *i4_peak_bit_rate); 81 82 /* Change the gop size in the middle of a current gop */ 83 void change_gop_size(bit_allocation_handle ps_bit_allocation, 84 WORD32 i4_intra_frm_interval, 85 WORD32 i4_inter_frm_interval, 86 WORD32 i4_num_intra_frm_interval); 87 88 void update_rem_frms_in_period(bit_allocation_handle ps_bit_allocation, 89 picture_type_e e_pic_type, 90 UWORD8 u1_is_first_frm, 91 WORD32 i4_intra_frm_interval, 92 WORD32 i4_num_intra_frm_interval); 93 94 void irc_ba_change_rem_bits_in_prd_at_force_I_frame(bit_allocation_handle ps_bit_allocation, 95 pic_handling_handle ps_pic_handling); 96 97 void irc_ba_change_ba_peak_bit_rate(bit_allocation_handle ps_bit_allocation, 98 WORD32 *ai4_peak_bit_rate); 99 #endif 100