Line data Source code
1 : /******************************************************************************************************
2 :
3 : (C) 2022-2025 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
4 : Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
5 : Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
6 : Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
7 : contributors to this repository. All Rights Reserved.
8 :
9 : This software is protected by copyright law and by international treaties.
10 : The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
11 : Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
12 : Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
13 : Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
14 : contributors to this repository retain full ownership rights in their respective contributions in
15 : the software. This notice grants no license of any kind, including but not limited to patent
16 : license, nor is any license granted by implication, estoppel or otherwise.
17 :
18 : Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
19 : contributions.
20 :
21 : This software is provided "AS IS", without any express or implied warranties. The software is in the
22 : development stage. It is intended exclusively for experts who have experience with such software and
23 : solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
24 : and fitness for a particular purpose are hereby disclaimed and excluded.
25 :
26 : Any dispute, controversy or claim arising under or in relation to providing this software shall be
27 : submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
28 : accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
29 : the United Nations Convention on Contracts on the International Sales of Goods.
30 :
31 : *******************************************************************************************************/
32 :
33 : /*====================================================================================
34 : EVS Codec 3GPP TS26.443 Nov 04, 2021. Version 12.14.0 / 13.10.0 / 14.6.0 / 15.4.0 / 16.3.0
35 : ====================================================================================*/
36 :
37 : #include <stdint.h>
38 : #include "options.h"
39 : #ifdef DEBUGGING
40 : #include "debug.h"
41 : #endif
42 : #include "cnst.h"
43 : #include "rom_com.h"
44 : #include "prot.h"
45 : #include "wmc_auto.h"
46 :
47 : /*--------------------------------------------------------------------------*
48 : * hq_configure()
49 : *
50 : * Configuration routine for HQ mode
51 : *--------------------------------------------------------------------------*/
52 :
53 273098 : void hq_configure(
54 : const int16_t length, /* i : Frame length */
55 : const int16_t hqswb_clas, /* i : HQ SWB class */
56 : const int32_t core_brate, /* i : Codec bitrate */
57 : int16_t *num_sfm, /* o : Total number of subbands */
58 : int16_t *nb_sfm, /* o : Total number of coded bands */
59 : int16_t *start_norm, /* o : First norm to be SDE encoded */
60 : int16_t *num_env_bands, /* o : Number coded envelope bands */
61 : int16_t *numnrmibits, /* o : Number of bits in fall-back norm encoding */
62 : int16_t *hq_generic_offset, /* o : Freq offset for HQ GENERIC */
63 : int16_t *sfmsize, /* o : Subband bandwidths */
64 : int16_t *sfm_start, /* o : Subband start coefficients */
65 : int16_t *sfm_end /* o : Subband end coefficients */
66 : )
67 : {
68 : const int16_t *p_sfmsize;
69 : const int16_t *p_sfm_start;
70 : const int16_t *p_sfm_end;
71 : int16_t i, bw_ext;
72 :
73 273098 : bw_ext = 0;
74 273098 : *start_norm = 0;
75 :
76 273098 : if ( length == L_SPEC48k )
77 : {
78 121680 : if ( hqswb_clas == HQ_GEN_FB )
79 : {
80 38500 : *num_sfm = NB_SFM;
81 38500 : p_sfmsize = band_len_HQ;
82 38500 : p_sfm_start = band_start_HQ;
83 38500 : p_sfm_end = band_end_HQ;
84 :
85 38500 : if ( core_brate >= HQ_32k )
86 : {
87 542 : *hq_generic_offset = HQ_GENERIC_FOFFSET_32K;
88 : /* setting start frequency of FD BWE */
89 542 : *num_env_bands = SFM_N_STA_10k;
90 : }
91 : else
92 : {
93 37958 : *hq_generic_offset = HQ_GENERIC_FOFFSET_24K4;
94 37958 : *num_env_bands = SFM_N_STA_8k;
95 : }
96 :
97 38500 : *nb_sfm = *num_sfm;
98 : }
99 : else
100 : {
101 83180 : if ( hqswb_clas == HQ_HARMONIC )
102 : {
103 12815 : *num_sfm = SFM_N_HARM_FB;
104 12815 : *nb_sfm = SFM_N_HARM_FB;
105 12815 : *num_env_bands = SFM_N_HARM_FB;
106 :
107 12815 : p_sfmsize = band_len_harm;
108 12815 : p_sfm_start = band_start_harm;
109 12815 : p_sfm_end = band_end_harm;
110 : }
111 70365 : else if ( hqswb_clas == HQ_HVQ )
112 : {
113 14853 : if ( core_brate < HQ_BWE_CROSSOVER_BRATE )
114 : {
115 9694 : *num_sfm = SFM_N_HARM_FB;
116 9694 : *nb_sfm = HVQ_THRES_SFM_24k;
117 9694 : *num_env_bands = *num_sfm - *nb_sfm;
118 9694 : *start_norm = HVQ_THRES_SFM_24k;
119 : }
120 : else
121 : {
122 5159 : *num_sfm = SFM_N_HARM_FB;
123 5159 : *nb_sfm = HVQ_THRES_SFM_32k;
124 5159 : *num_env_bands = *num_sfm - *nb_sfm;
125 5159 : *start_norm = HVQ_THRES_SFM_32k;
126 : }
127 :
128 14853 : p_sfmsize = band_len_harm;
129 14853 : p_sfm_start = band_start_harm;
130 14853 : p_sfm_end = band_end_harm;
131 : }
132 : else
133 : {
134 55512 : *num_sfm = NB_SFM;
135 55512 : *nb_sfm = *num_sfm;
136 55512 : *num_env_bands = NB_SFM;
137 :
138 55512 : p_sfmsize = band_len_HQ;
139 55512 : p_sfm_start = band_start_HQ;
140 55512 : p_sfm_end = band_end_HQ;
141 : }
142 : }
143 : }
144 151418 : else if ( length == L_SPEC32k )
145 : {
146 102254 : if ( hqswb_clas == HQ_HARMONIC )
147 : {
148 16155 : *num_sfm = SFM_N_HARM;
149 16155 : *nb_sfm = SFM_N_HARM;
150 16155 : *num_env_bands = SFM_N_HARM;
151 :
152 16155 : p_sfmsize = band_len_harm;
153 16155 : p_sfm_start = band_start_harm;
154 16155 : p_sfm_end = band_end_harm;
155 : }
156 86099 : else if ( hqswb_clas == HQ_HVQ )
157 : {
158 21754 : if ( core_brate < HQ_BWE_CROSSOVER_BRATE )
159 : {
160 19219 : *num_sfm = SFM_N_HARM;
161 19219 : *nb_sfm = HVQ_THRES_SFM_24k;
162 19219 : *num_env_bands = *num_sfm - *nb_sfm;
163 19219 : *start_norm = HVQ_THRES_SFM_24k;
164 : }
165 : else
166 : {
167 2535 : *num_sfm = SFM_N_HARM;
168 2535 : *nb_sfm = HVQ_THRES_SFM_32k;
169 2535 : *num_env_bands = *num_sfm - *nb_sfm;
170 2535 : *start_norm = HVQ_THRES_SFM_32k;
171 : }
172 :
173 21754 : p_sfmsize = band_len_harm;
174 21754 : p_sfm_start = band_start_harm;
175 21754 : p_sfm_end = band_end_harm;
176 : }
177 64345 : else if ( hqswb_clas == HQ_GEN_SWB )
178 : {
179 43208 : *num_sfm = SFM_N_SWB;
180 43208 : p_sfmsize = band_len_HQ;
181 43208 : p_sfm_start = band_start_HQ;
182 43208 : p_sfm_end = band_end_HQ;
183 :
184 43208 : if ( core_brate >= HQ_32k )
185 : {
186 1224 : *hq_generic_offset = HQ_GENERIC_FOFFSET_32K;
187 : /* setting start frequency of FD BWE */
188 1224 : *num_env_bands = SFM_N_STA_10k;
189 : }
190 : else
191 : {
192 41984 : *hq_generic_offset = HQ_GENERIC_FOFFSET_24K4;
193 : /* setting start frequency of FD BWE */
194 41984 : *num_env_bands = SFM_N_STA_8k;
195 : }
196 43208 : *nb_sfm = *num_sfm;
197 : }
198 : else
199 : {
200 : /* HQ_NORMAL and HQ_TRANSIENT */
201 21137 : *num_sfm = SFM_N_SWB;
202 21137 : *nb_sfm = *num_sfm;
203 21137 : *num_env_bands = SFM_N_SWB;
204 :
205 21137 : p_sfmsize = band_len_HQ;
206 21137 : p_sfm_start = band_start_HQ;
207 21137 : p_sfm_end = band_end_HQ;
208 : }
209 : }
210 49164 : else if ( length == L_SPEC48k_EXT )
211 : {
212 1795 : bw_ext = 1;
213 1795 : p_sfmsize = band_len_HQ;
214 1795 : p_sfm_start = band_start_HQ;
215 1795 : p_sfm_end = band_end_HQ;
216 1795 : *num_sfm = NB_SFM;
217 : }
218 47369 : else if ( length == L_SPEC16k_EXT )
219 : {
220 1056 : bw_ext = 1;
221 1056 : p_sfmsize = band_len_wb;
222 1056 : p_sfm_start = band_start_wb;
223 1056 : p_sfm_end = band_end_wb;
224 1056 : *num_sfm = SFM_N_WB;
225 : }
226 : else
227 : {
228 46313 : *num_sfm = SFM_N_WB;
229 46313 : *nb_sfm = *num_sfm;
230 46313 : *num_env_bands = SFM_N_WB;
231 :
232 46313 : p_sfmsize = band_len_wb;
233 46313 : p_sfm_start = band_start_wb;
234 46313 : p_sfm_end = band_end_wb;
235 : }
236 :
237 273098 : if ( bw_ext )
238 : {
239 109287 : for ( i = 0; i < *num_sfm; i++ )
240 : {
241 106436 : sfmsize[i] = (int16_t) ( 1.25f * p_sfmsize[i] );
242 106436 : sfm_start[i] = (int16_t) ( 1.25f * p_sfm_start[i] );
243 106436 : sfm_end[i] = (int16_t) ( 1.25f * p_sfm_end[i] );
244 : }
245 2851 : *nb_sfm = *num_sfm;
246 2851 : *num_env_bands = *num_sfm;
247 : }
248 : else
249 : {
250 270247 : mvs2s( p_sfmsize, sfmsize, *num_sfm );
251 270247 : mvs2s( p_sfm_start, sfm_start, *num_sfm );
252 270247 : mvs2s( p_sfm_end, sfm_end, *num_sfm );
253 : }
254 :
255 273098 : *numnrmibits = ( *num_env_bands - 1 ) * NORMI_BITS;
256 :
257 273098 : return;
258 : }
|