xref: /aosp_15_r20/external/libxaac/encoder/ixheaace_sbr_code_envelope.h (revision 15dc779a375ca8b5125643b829a8aa4b70d7f451)
1*15dc779aSAndroid Build Coastguard Worker /******************************************************************************
2*15dc779aSAndroid Build Coastguard Worker  *                                                                            *
3*15dc779aSAndroid Build Coastguard Worker  * Copyright (C) 2023 The Android Open Source Project
4*15dc779aSAndroid Build Coastguard Worker  *
5*15dc779aSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
6*15dc779aSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
7*15dc779aSAndroid Build Coastguard Worker  * You may obtain a copy of the License at:
8*15dc779aSAndroid Build Coastguard Worker  *
9*15dc779aSAndroid Build Coastguard Worker  * http://www.apache.org/licenses/LICENSE-2.0
10*15dc779aSAndroid Build Coastguard Worker  *
11*15dc779aSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
12*15dc779aSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
13*15dc779aSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14*15dc779aSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
15*15dc779aSAndroid Build Coastguard Worker  * limitations under the License.
16*15dc779aSAndroid Build Coastguard Worker  *
17*15dc779aSAndroid Build Coastguard Worker  *****************************************************************************
18*15dc779aSAndroid Build Coastguard Worker  * Originally developed and contributed by Ittiam Systems Pvt. Ltd, Bangalore
19*15dc779aSAndroid Build Coastguard Worker  */
20*15dc779aSAndroid Build Coastguard Worker 
21*15dc779aSAndroid Build Coastguard Worker #pragma once
22*15dc779aSAndroid Build Coastguard Worker #define COUPLING_1 (1)
23*15dc779aSAndroid Build Coastguard Worker 
24*15dc779aSAndroid Build Coastguard Worker typedef struct {
25*15dc779aSAndroid Build Coastguard Worker   WORD32 offset;
26*15dc779aSAndroid Build Coastguard Worker   WORD32 update;
27*15dc779aSAndroid Build Coastguard Worker   WORD32 num_scf[2];
28*15dc779aSAndroid Build Coastguard Worker   WORD32 sfb_nrg_prev[MAXIMUM_FREQ_COEFFS];
29*15dc779aSAndroid Build Coastguard Worker   WORD32 delta_t_across_frames;
30*15dc779aSAndroid Build Coastguard Worker   FLOAT32 df_edge_1st_env;
31*15dc779aSAndroid Build Coastguard Worker   FLOAT32 df_edge_incr;
32*15dc779aSAndroid Build Coastguard Worker   WORD32 df_edge_incr_fac;
33*15dc779aSAndroid Build Coastguard Worker 
34*15dc779aSAndroid Build Coastguard Worker   WORD32 code_book_scf_lav_time;
35*15dc779aSAndroid Build Coastguard Worker   WORD32 code_book_scf_lav_freq;
36*15dc779aSAndroid Build Coastguard Worker 
37*15dc779aSAndroid Build Coastguard Worker   WORD32 code_book_scf_lav_lvl_time;
38*15dc779aSAndroid Build Coastguard Worker   WORD32 code_book_scf_lav_lvl_freq;
39*15dc779aSAndroid Build Coastguard Worker   WORD32 code_book_scf_lav_bal_time;
40*15dc779aSAndroid Build Coastguard Worker   WORD32 code_book_scf_lav_bal_freq;
41*15dc779aSAndroid Build Coastguard Worker 
42*15dc779aSAndroid Build Coastguard Worker   WORD32 start_bits;
43*15dc779aSAndroid Build Coastguard Worker   WORD32 start_bits_balance;
44*15dc779aSAndroid Build Coastguard Worker 
45*15dc779aSAndroid Build Coastguard Worker   const UWORD8 *ptr_huff_tab_time_l;
46*15dc779aSAndroid Build Coastguard Worker   const UWORD8 *ptr_huff_tab_freq_l;
47*15dc779aSAndroid Build Coastguard Worker 
48*15dc779aSAndroid Build Coastguard Worker   const UWORD8 *ptr_huff_tab_lvl_time_l;
49*15dc779aSAndroid Build Coastguard Worker   const UWORD8 *ptr_huff_tab_bal_time_l;
50*15dc779aSAndroid Build Coastguard Worker   const UWORD8 *ptr_huff_tab_lvl_freq_l;
51*15dc779aSAndroid Build Coastguard Worker   const UWORD8 *ptr_huff_tab_bal_freq_l;
52*15dc779aSAndroid Build Coastguard Worker } ixheaace_str_sbr_code_envelope;
53*15dc779aSAndroid Build Coastguard Worker 
54*15dc779aSAndroid Build Coastguard Worker typedef ixheaace_str_sbr_code_envelope *ixheaace_pstr_sbr_code_envelope;
55*15dc779aSAndroid Build Coastguard Worker struct ixheaace_str_sbr_env_data;
56*15dc779aSAndroid Build Coastguard Worker 
57*15dc779aSAndroid Build Coastguard Worker IA_ERRORCODE ixheaace_code_envelope(WORD32 *ptr_sfb_energy, const ixheaace_freq_res *freq_res,
58*15dc779aSAndroid Build Coastguard Worker                                     ixheaace_str_sbr_code_envelope *pstr_code_env,
59*15dc779aSAndroid Build Coastguard Worker                                     WORD32 *ptr_dir_vec, WORD32 coupling, WORD32 num_envelopes,
60*15dc779aSAndroid Build Coastguard Worker                                     WORD32 channel, WORD32 header_active, WORD32 usac_indep_flag,
61*15dc779aSAndroid Build Coastguard Worker                                     WORD32 is_ld_sbr);
62*15dc779aSAndroid Build Coastguard Worker 
63*15dc779aSAndroid Build Coastguard Worker VOID ixheaace_create_sbr_code_envelope(ixheaace_pstr_sbr_code_envelope pstr_code_env,
64*15dc779aSAndroid Build Coastguard Worker                                        WORD32 *num_sfb, WORD32 delta_t_across_frames,
65*15dc779aSAndroid Build Coastguard Worker                                        FLOAT32 df_edge_first_env, FLOAT32 df_edge_incr);
66*15dc779aSAndroid Build Coastguard Worker 
67*15dc779aSAndroid Build Coastguard Worker IA_ERRORCODE
68*15dc779aSAndroid Build Coastguard Worker ixheaace_init_sbr_huffman_tabs(struct ixheaace_str_sbr_env_data *pstr_sbr_env,
69*15dc779aSAndroid Build Coastguard Worker                                ixheaace_pstr_sbr_code_envelope pstr_code_env,
70*15dc779aSAndroid Build Coastguard Worker                                ixheaace_pstr_sbr_code_envelope pstr_noise,
71*15dc779aSAndroid Build Coastguard Worker                                ixheaace_amp_res amp_res,
72*15dc779aSAndroid Build Coastguard Worker                                ixheaace_str_sbr_huff_tabs *pstr_sbr_huff_tabs);
73*15dc779aSAndroid Build Coastguard Worker 
74*15dc779aSAndroid Build Coastguard Worker VOID ixheaace_map_low_res_energy_value(WORD32 curr_val, WORD32 *ptr_prev_data, WORD32 offset,
75*15dc779aSAndroid Build Coastguard Worker                                        WORD32 index, ixheaace_freq_res res);
76*15dc779aSAndroid Build Coastguard Worker 
77*15dc779aSAndroid Build Coastguard Worker IA_ERRORCODE
78*15dc779aSAndroid Build Coastguard Worker ixheaace_compute_bits(WORD32 delta, WORD32 code_book_scf_lav_lvl,
79*15dc779aSAndroid Build Coastguard Worker                       WORD32 code_book_scf_lav_balance, const UWORD8 *ptr_huff_tbl_lvl,
80*15dc779aSAndroid Build Coastguard Worker                       const UWORD8 *ptr_huff_tbl_bal, WORD32 coupling, WORD32 ch,
81*15dc779aSAndroid Build Coastguard Worker                       WORD32 *ptr_delta_bits);
82