xref: /aosp_15_r20/external/libxaac/encoder/ixheaace_qc_util.h (revision 15dc779a375ca8b5125643b829a8aa4b70d7f451)
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 IA_ERRORCODE ia_enhaacplus_enc_qc_out_new(ixheaace_qc_out *pstr_qc_out, WORD32 num_channels,
24                                           WORD32 *ptr_shared_buffer1, WORD32 *ptr_shared_buffer3,
25                                           WORD32 frame_len_long);
26 
27 IA_ERRORCODE ia_enhaacplus_enc_qc_new(ixheaace_qc_state *pstr_qc_state,
28                                       WORD32 *ptr_shared_buffer_2, WORD32 frame_len_long);
29 
30 IA_ERRORCODE ia_enhaacplus_enc_qc_init(ixheaace_qc_state *pstr_qc_state, WORD32 aot,
31                                        ixheaace_qc_init *pstr_init, FLAG flag_framelength_small);
32 
33 IA_ERRORCODE ia_enhaacplus_enc_qc_main(
34     ixheaace_qc_state *pstr_qc_state, WORD32 num_channels, ixheaace_element_bits *pstr_el_bits,
35     ixheaace_psy_out_channel **psy_out_ch,
36     ixheaace_psy_out_element *pstr_psy_out_element,
37     ixheaace_qc_out_channel **pstr_qc_out_ch,
38     ixheaace_qc_out_element *pstr_qc_out_element, WORD32 ancillary_data_bytes,
39     ixheaace_aac_tables *pstr_aac_tables, WORD32 adts_flag, WORD32 aot, WORD32 stat_bits_flag,
40     WORD32 flag_last_element, WORD32 frame_len_long, WORD8 *ptr_scratch,
41     WORD32 *is_quant_spec_zero, WORD32 *is_gain_limited);
42 
43 VOID ia_enhaacplus_enc_update_bit_reservoir(ixheaace_qc_state *pstr_qc_kernel,
44                                             ixheaace_qc_out *pstr_qc_out);
45 
46 VOID ia_enhaacplus_enc_adjust_bitrate(ixheaace_qc_state *pstr_qc_state, WORD32 bit_rate,
47                                       WORD32 sample_rate, WORD32 flag_last_element,
48                                       WORD32 frame_len_long);
49 
50 WORD32 ia_enhaacplus_aac_limitbitrate(WORD32 core_sampling_rate, WORD32 frame_length,
51                                       WORD32 num_channels, WORD32 bit_rate);
52 
53 WORD32 iaace_calc_max_val_in_sfb(WORD32 sfb_count, WORD32 max_sfb_per_grp, WORD32 ptr_sfb_per_grp,
54                                  WORD32 *ptr_sfb_offset, WORD16 *ptr_quant_spec,
55                                  UWORD16 *ptr_max_value);
56 
57 IA_ERRORCODE ia_enhaacplus_enc_finalize_bit_consumption(ixheaace_qc_state *pstr_qc_kernel,
58                                                         ixheaace_qc_out *pstr_qc_out,
59                                                         WORD32 flag_last_element, WORD32 cnt_bits,
60                                                         WORD32 *tot_fill_bits,
61                                                         iexheaac_encoder_str **pstr_aac_enc,
62                                                         WORD32 num_bs_elements, WORD32 aot);