xref: /aosp_15_r20/external/libxaac/encoder/ixheaace_sbr_ps_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 #define NUMBER_OF_BINS (20)
23 #define NUMBER_OF_LOW_RES_BINS (NUMBER_OF_IID_BINS / 2)
24 
25 #define NUMBER_OF_IID_BINS (NUMBER_OF_BINS)
26 #define NUMBER_OF_ICC_BINS (NUMBER_OF_BINS)
27 #define NUMBER_OF_IPD_BINS (11)
28 #define NUMBER_OF_IPD_BINS_EST (NUMBER_OF_BINS)
29 
30 #define NUMBER_OF_LOW_RES_IID_BINS (NUMBER_OF_LOW_RES_BINS)
31 
32 #define NUMBER_OF_IPD_GROUPS (NUMBER_OF_IPD_BINS_EST + 6 + 2)
33 #define IXHEAACE_IPD_MASK_NEGATED (0x00001000)
34 
35 #define NUMBER_OF_SUBSAMPLES (32)
36 #define NUMBER_OF_QMF_BANDS (64)
37 #define SYSTEMLOOKAHEAD (1)
38 #define PS_MODE_LOW_FREQ_RES_IID_ICC (0x00020000)
39 #define SUBQMF_BINS_ENERGY (8)
40 #define SUBQMF_GROUPS_MIX (16)
41 
42 struct ixheaace_ps_enc {
43   WORD32 b_enable_header;
44 
45   WORD32 b_hi_freq_res_iid_icc;
46   WORD32 iid_icc_bins;
47 
48   UWORD32 b_prev_zero_iid;
49   UWORD32 b_prev_zero_icc;
50 
51   WORD32 ps_mode;
52   WORD32 hdr_bits_prev_frame;
53 
54   WORD8 a_last_iid_index[NUMBER_OF_IID_BINS];
55   WORD8 a_last_icc_index[NUMBER_OF_ICC_BINS];
56 
57   ixheaace_str_hybrid hybrid_left;
58   ixheaace_str_hybrid hybrid_right;
59 
60   ixheaace_pstr_hybrid ptr_hybrid_left;
61   ixheaace_pstr_hybrid ptr_hybrid_right;
62 
63   WORD32 bit_buf_write_offset;
64   WORD32 bit_buf_read_offset;
65 
66   FLOAT32 **aaa_IID_data_buf;
67   FLOAT32 **aaa_ICC_data_buf;
68 
69   FLOAT32 *m_hybrid_real_left[NUMBER_OF_SUBSAMPLES];
70   FLOAT32 *m_hybrid_imag_left[NUMBER_OF_SUBSAMPLES];
71   FLOAT32 *m_hybrid_real_right[NUMBER_OF_SUBSAMPLES];
72   FLOAT32 *m_hybrid_imag_right[NUMBER_OF_SUBSAMPLES];
73 
74   FLOAT32 pow_left_right[2 * NUMBER_OF_BINS];
75   FLOAT32 pow_corr_real_imag[2 * NUMBER_OF_BINS];
76 
77   FLOAT32 **temp_qmf_left_real;
78   FLOAT32 **temp_qmf_left_imag;
79   FLOAT32 **hist_qmf_left_real;
80   FLOAT32 **hist_qmf_left_imag;
81   FLOAT32 **hist_qmf_right_real;
82   FLOAT32 **hist_qmf_right_imag;
83 
84   FLOAT32
85   ps_buf2[(IXHEAACE_HYBRID_FILTER_DELAY * sizeof(FLOAT32 *) * (1 + NUMBER_OF_QMF_BANDS))];
86   ixheaace_bit_buf ps_bit_buf;
87 };
88 
89 typedef struct ixheaace_ps_enc *ixheaace_pstr_ps_enc;
90 
91 WORD32 ixheaace_get_ps_mode(WORD32 bit_rate);
92 
93 IA_ERRORCODE
94 ixheaace_create_ps_enc(ixheaace_pstr_ps_enc pstr_ps_enc, WORD32 ps_mode,
95                        FLOAT32 *ptr_common_buffer, FLOAT32 *ptr_common_buffer2,
96                        FLOAT32 *ptr_ps_buf3);
97 
98 IA_ERRORCODE ixheaace_encode_ps_frame(ixheaace_pstr_ps_enc pms, FLOAT32 **i_buffer_left,
99                                       FLOAT32 **r_buffer_left, FLOAT32 **i_buffer_right,
100                                       FLOAT32 **r_buffer_right, ixheaace_str_ps_tab *ps_tabs,
101                                       ixheaace_comm_tables *common_tab);
102