1 /****************************************************************************** 2 * * 3 * Copyright (C) 2023 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 #pragma once 22 23 #ifndef IXHEAACE_MAX_CH_IN_BS_ELE 24 #define IXHEAACE_MAX_CH_IN_BS_ELE (2) 25 #endif 26 27 #define FRAME_LEN_BYTES_MODULO (1) 28 #define FRAME_LEN_BYTES_INT (2) 29 30 typedef struct { 31 WORD32 ch_bitrate; 32 WORD32 avg_bits; 33 WORD32 max_bits; 34 WORD32 bit_res_lvl; 35 WORD32 max_bitres_bits; 36 WORD32 static_bits; 37 FLOAT32 max_bit_fac; 38 WORD32 tot_avg_bits; 39 WORD32 padding; 40 ia_adj_thr_state_struct str_adj_thr; 41 ia_adj_thr_elem_struct str_adj_thr_ele; 42 WORD8 num_ch; 43 } ia_qc_data_struct; 44 45 typedef struct { 46 WORD16 quant_spec[LEN_SUPERFRAME]; 47 UWORD16 max_val_in_sfb[LEN_SUPERFRAME]; 48 WORD16 scalefactor[LEN_SUPERFRAME]; 49 WORD32 global_gain; 50 } ia_qc_out_chan_struct; 51 52 typedef struct { 53 ia_qc_out_chan_struct str_qc_out_chan[IXHEAACE_MAX_CH_IN_BS_ELE]; 54 WORD32 static_bits; 55 WORD32 dyn_bits; 56 WORD32 fill_bits; 57 FLOAT32 pe; 58 } ia_qc_out_data_struct; 59 60 typedef struct { 61 ia_qc_data_struct str_qc_data[IXHEAACE_MAX_CH_IN_BS_ELE]; 62 ia_qc_out_data_struct str_qc_out; 63 } ia_qc_main_struct; 64 65 VOID iusace_qc_create(ia_qc_main_struct *pstr_qc_data); 66 67 VOID iusace_qc_init(ia_qc_data_struct *pstr_qc_data, const WORD32 max_bits, WORD32 sample_rate, 68 WORD32 bw_limit, WORD32 channels, WORD32 ccfl); 69 70 VOID iusace_adj_bitrate(ia_qc_data_struct *pstr_qc_data, WORD32 bit_rate, WORD32 sample_rate, 71 WORD32 ccfl); 72 73 WORD32 iusace_calc_max_val_in_sfb(WORD32 sfb_count, WORD32 max_sfb_per_grp, WORD32 sfb_per_group, 74 WORD32 *ptr_sfb_offset, WORD16 *ptr_quant_spec); 75