xref: /aosp_15_r20/external/libxaac/encoder/ixheaace_sbr_qmf_enc.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_NUM_QMF_SYNTH_CHANNELS (64)
24 #define IXHEAACE_TIMESLOT_BUFFER_SIZE (78)
25 
26 #define IXHEAACE_PS_BUF4_SIZE                                              \
27   (sizeof(WORD32) * (IXHEAACE_QMF_TIME_SLOTS + IXHEAACE_QMF_BUFFER_MOVE) + \
28    sizeof(WORD32 *) * (IXHEAACE_NUM_QMF_BANDS_IN_HYBRID +                  \
29                        IXHEAACE_NUM_QMF_BANDS_IN_HYBRID * IXHEAACE_QMF_BUFFER_MOVE))
30 
31 typedef struct {
32   const FLOAT32 *ptr_flt_filter;
33   const FLOAT32 *ptr_flt_cos_twiddle;
34   const FLOAT32 *ptr_flt_alt_sin_twiddle;
35   FLOAT32 *ptr_flt_time_buf;
36   FLOAT32 *ptr_flt_work_buf;
37   WORD16 flag;
38   SIZE_T offset_l;
39   SIZE_T offset_r;
40   WORD16 offset;
41   const FLOAT32 *ptr_filter;
42   const FLOAT32 *ptr_cos_twiddle;
43   const FLOAT32 *ptr_sin_twiddle;
44   const FLOAT32 *ptr_alt_sin_twiddle;
45   FLOAT32 *ptr_work_buf;
46   FLOAT32 *ptr_sbr_qmf_states_ana;
47   FLOAT32 *ptr_qmf_states_buf;
48   FLOAT32 *ptr_qmf_states_curr_pos;
49   const FLOAT32 *ptr_ref_coeff_l;
50   const FLOAT32 *ptr_ref_coeff_r;
51   const FLOAT32 *ptr_cld_filt;
52   FLOAT32 *ptr_fp1;
53   FLOAT32 *ptr_fp2;
54   WORD32 start_coeff_cnt;
55   WORD32 num_time_slots;
56   WORD32 rate;
57 } ixheaace_str_sbr_qmf_filter_bank;
58 
59 typedef ixheaace_str_sbr_qmf_filter_bank *ixheaace_pstr_sbr_qmf_filter_bank;
60 
61 VOID ixheaace_sbr_analysis_filtering(const FLOAT32 *ptr_time_in, WORD32 time_sn_stride,
62                                      FLOAT32 **ptr_ana_r, FLOAT32 **ptr_ana_i,
63                                      ixheaace_pstr_sbr_qmf_filter_bank pstr_qmf_bank,
64                                      ixheaace_str_qmf_tabs *pstr_qmf_tab, WORD32 num_qmf_subsamp,
65                                      WORD32 is_ld_sbr, FLOAT32 *ptr_sbr_scratch,
66                                      WORD32 is_ps_960);
67 
68 VOID ixheaace_create_qmf_bank(ixheaace_pstr_sbr_qmf_filter_bank pstr_sbr_qmf_handle,
69                               ixheaace_str_sbr_tabs *pstr_sbr_tab, WORD32 is_ld_sbr);
70 
71 VOID ixheaace_get_energy_from_cplx_qmf(
72     FLOAT32 **ptr_energy_vals, FLOAT32 **ptr_real_values, FLOAT32 **ptr_imag_values,
73     WORD32 is_ld_sbr, WORD32 num_time_slots, WORD32 samp_ratio_fac,
74     ixheaace_str_hbe_enc *pstr_hbe_enc, WORD32 op_delay, WORD32 harmonic_sbr);
75 
76 VOID ixheaace_enc_synthesis_qmf_filtering(FLOAT32 **ptr_sbr_re, FLOAT32 **ptr_sbr_im,
77                                           FLOAT32 *time_float,
78                                           ixheaace_pstr_sbr_qmf_filter_bank pstr_qmf_bank);
79 
80 VOID ixheaace_create_synthesis_qmf_bank(
81     ixheaace_pstr_sbr_qmf_filter_bank pstr_sbr_qmf_filter_bank, WORD32 *ptr_common_buffer,
82     ixheaace_str_sbr_tabs *pstr_sbr_tab);
83