xref: /aosp_15_r20/external/libxaac/encoder/ixheaace_sbr_ton_corr.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 #define IXHEAACE_MAXIMUM_NUM_PATCHES (6)
24 
25 typedef struct {
26   FLOAT32 r00r;
27   FLOAT32 r11r;
28   FLOAT32 r01r;
29   FLOAT32 r01i;
30   FLOAT32 r02r;
31   FLOAT32 r02i;
32   FLOAT32 r12r;
33   FLOAT32 r12i;
34   FLOAT32 r22r;
35   FLOAT32 det;
36 } ixheaace_acorr_coeffs;
37 
38 typedef struct {
39   WORD32 source_start_band;
40   WORD32 source_stop_band;
41   WORD32 guard_start_band;
42 
43   WORD32 target_start_band;
44   WORD32 target_band_offs;
45   WORD32 num_bands_in_patch;
46 } ixheaace_patch_param;
47 
48 typedef struct {
49   WORD32 switch_inverse_filt;
50   WORD32 num_qmf_ch;
51   WORD32 est_cnt;
52   WORD32 est_cnt_per_frame;
53   WORD32 move;
54   WORD32 frame_start_index;
55   WORD32 start_index_matrix;
56   WORD32 frame_start_index_invf_est;
57 
58   WORD32 prev_trans_flag;
59   WORD32 trans_nxt_frame;
60   WORD32 trans_pos_offset;
61 
62   FLOAT32 sbr_quota_mtx[NO_OF_ESTIMATES * IXHEAACE_QMF_CHANNELS];
63 
64   FLOAT32 *ptr_quota_mtx[NO_OF_ESTIMATES];
65   FLOAT32 energy_vec[NO_OF_ESTIMATES];
66   WORD8 idx_vx[IXHEAACE_QMF_CHANNELS];
67 
68   ixheaace_patch_param str_patch_param[IXHEAACE_MAXIMUM_NUM_PATCHES];
69   WORD32 guard;
70   WORD32 shift_start_sb;
71   WORD32 no_of_patches;
72 
73   ixheaace_str_sbr_missing_har_detector sbr_missing_har_detector;
74   ixheaace_str_noise_flr_est_sbr sbr_noise_floor_est;
75   ixheaace_str_sbr_inv_filt_est sbr_noise_inv_filt;
76 } ixheaace_str_sbr_ton_corr_est;
77 
78 typedef ixheaace_str_sbr_ton_corr_est *ixheaace_pstr_sbr_ton_corr_est;
79 
80 IA_ERRORCODE
81 ixheaace_create_ton_corr_param_extr(WORD32 ch, ixheaace_pstr_sbr_ton_corr_est pstr_ton_corr,
82                                     WORD32 fs, WORD32 num_qmf_ch, WORD32 xpos_ctrl,
83                                     WORD32 high_band_start_sb, UWORD8 *ptr_vk_master,
84                                     WORD32 num_master, WORD32 ana_max_level,
85                                     UWORD8 *ptr_freq_band_tab[2], WORD32 *ptr_num_scf,
86                                     WORD32 noise_groups, UWORD32 use_speech_config,
87                                     WORD32 *ptr_common_buffer,
88                                     ixheaace_str_qmf_tabs *pstr_qmf_tab, WORD32 is_ld_sbr);
89 
90 VOID ixheaace_ton_corr_param_extr(ixheaace_pstr_sbr_ton_corr_est pstr_ton_corr,
91                                   ixheaace_invf_mode *pstr_inf_vec, FLOAT32 *ptr_noise_lvls,
92                                   WORD32 *ptr_missing_harmonic_flag,
93                                   UWORD8 *ptr_missing_harmonic_index, WORD8 *ptr_env_compensation,
94                                   const ixheaace_str_frame_info_sbr *pstr_frame_info,
95                                   WORD32 *ptr_trans_info, UWORD8 *ptr_freq_band_tab,
96                                   WORD32 ptr_num_scf, ixheaace_sbr_xpos_mode xpos_type,
97                                   WORD8 *ptr_sbr_scratch, WORD32 is_ld_sbr);
98 
99 VOID ixheaace_calculate_tonality_quotas(ixheaace_pstr_sbr_ton_corr_est pstr_ton_corr,
100                                         FLOAT32 **ptr_real, FLOAT32 **ptr_imag, WORD32 usb,
101                                         WORD32 num_time_slots, WORD32 is_ld_sbr);
102