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 341747 : 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 341747 : bw_ext = 0;
74 341747 : *start_norm = 0;
75 :
76 341747 : if ( length == L_SPEC48k )
77 : {
78 167896 : if ( hqswb_clas == HQ_GEN_FB )
79 : {
80 57851 : *num_sfm = NB_SFM;
81 57851 : p_sfmsize = band_len_HQ;
82 57851 : p_sfm_start = band_start_HQ;
83 57851 : p_sfm_end = band_end_HQ;
84 :
85 57851 : 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 57309 : *hq_generic_offset = HQ_GENERIC_FOFFSET_24K4;
94 57309 : *num_env_bands = SFM_N_STA_8k;
95 : }
96 :
97 57851 : *nb_sfm = *num_sfm;
98 : }
99 : else
100 : {
101 110045 : if ( hqswb_clas == HQ_HARMONIC )
102 : {
103 17804 : *num_sfm = SFM_N_HARM_FB;
104 17804 : *nb_sfm = SFM_N_HARM_FB;
105 17804 : *num_env_bands = SFM_N_HARM_FB;
106 :
107 17804 : p_sfmsize = band_len_harm;
108 17804 : p_sfm_start = band_start_harm;
109 17804 : p_sfm_end = band_end_harm;
110 : }
111 92241 : else if ( hqswb_clas == HQ_HVQ )
112 : {
113 22151 : if ( core_brate < HQ_BWE_CROSSOVER_BRATE )
114 : {
115 13754 : *num_sfm = SFM_N_HARM_FB;
116 13754 : *nb_sfm = HVQ_THRES_SFM_24k;
117 13754 : *num_env_bands = *num_sfm - *nb_sfm;
118 13754 : *start_norm = HVQ_THRES_SFM_24k;
119 : }
120 : else
121 : {
122 8397 : *num_sfm = SFM_N_HARM_FB;
123 8397 : *nb_sfm = HVQ_THRES_SFM_32k;
124 8397 : *num_env_bands = *num_sfm - *nb_sfm;
125 8397 : *start_norm = HVQ_THRES_SFM_32k;
126 : }
127 :
128 22151 : p_sfmsize = band_len_harm;
129 22151 : p_sfm_start = band_start_harm;
130 22151 : p_sfm_end = band_end_harm;
131 : }
132 : else
133 : {
134 70090 : *num_sfm = NB_SFM;
135 70090 : *nb_sfm = *num_sfm;
136 70090 : *num_env_bands = NB_SFM;
137 :
138 70090 : p_sfmsize = band_len_HQ;
139 70090 : p_sfm_start = band_start_HQ;
140 70090 : p_sfm_end = band_end_HQ;
141 : }
142 : }
143 : }
144 173851 : else if ( length == L_SPEC32k )
145 : {
146 117558 : if ( hqswb_clas == HQ_HARMONIC )
147 : {
148 18394 : *num_sfm = SFM_N_HARM;
149 18394 : *nb_sfm = SFM_N_HARM;
150 18394 : *num_env_bands = SFM_N_HARM;
151 :
152 18394 : p_sfmsize = band_len_harm;
153 18394 : p_sfm_start = band_start_harm;
154 18394 : p_sfm_end = band_end_harm;
155 : }
156 99164 : else if ( hqswb_clas == HQ_HVQ )
157 : {
158 23012 : if ( core_brate < HQ_BWE_CROSSOVER_BRATE )
159 : {
160 20441 : *num_sfm = SFM_N_HARM;
161 20441 : *nb_sfm = HVQ_THRES_SFM_24k;
162 20441 : *num_env_bands = *num_sfm - *nb_sfm;
163 20441 : *start_norm = HVQ_THRES_SFM_24k;
164 : }
165 : else
166 : {
167 2571 : *num_sfm = SFM_N_HARM;
168 2571 : *nb_sfm = HVQ_THRES_SFM_32k;
169 2571 : *num_env_bands = *num_sfm - *nb_sfm;
170 2571 : *start_norm = HVQ_THRES_SFM_32k;
171 : }
172 :
173 23012 : p_sfmsize = band_len_harm;
174 23012 : p_sfm_start = band_start_harm;
175 23012 : p_sfm_end = band_end_harm;
176 : }
177 76152 : else if ( hqswb_clas == HQ_GEN_SWB )
178 : {
179 49676 : *num_sfm = SFM_N_SWB;
180 49676 : p_sfmsize = band_len_HQ;
181 49676 : p_sfm_start = band_start_HQ;
182 49676 : p_sfm_end = band_end_HQ;
183 :
184 49676 : 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 48452 : *hq_generic_offset = HQ_GENERIC_FOFFSET_24K4;
193 : /* setting start frequency of FD BWE */
194 48452 : *num_env_bands = SFM_N_STA_8k;
195 : }
196 49676 : *nb_sfm = *num_sfm;
197 : }
198 : else
199 : {
200 : /* HQ_NORMAL and HQ_TRANSIENT */
201 26476 : *num_sfm = SFM_N_SWB;
202 26476 : *nb_sfm = *num_sfm;
203 26476 : *num_env_bands = SFM_N_SWB;
204 :
205 26476 : p_sfmsize = band_len_HQ;
206 26476 : p_sfm_start = band_start_HQ;
207 26476 : p_sfm_end = band_end_HQ;
208 : }
209 : }
210 56293 : else if ( length == L_SPEC48k_EXT )
211 : {
212 2471 : bw_ext = 1;
213 2471 : p_sfmsize = band_len_HQ;
214 2471 : p_sfm_start = band_start_HQ;
215 2471 : p_sfm_end = band_end_HQ;
216 2471 : *num_sfm = NB_SFM;
217 : }
218 53822 : else if ( length == L_SPEC16k_EXT )
219 : {
220 1282 : bw_ext = 1;
221 1282 : p_sfmsize = band_len_wb;
222 1282 : p_sfm_start = band_start_wb;
223 1282 : p_sfm_end = band_end_wb;
224 1282 : *num_sfm = SFM_N_WB;
225 : }
226 : else
227 : {
228 52540 : *num_sfm = SFM_N_WB;
229 52540 : *nb_sfm = *num_sfm;
230 52540 : *num_env_bands = SFM_N_WB;
231 :
232 52540 : p_sfmsize = band_len_wb;
233 52540 : p_sfm_start = band_start_wb;
234 52540 : p_sfm_end = band_end_wb;
235 : }
236 :
237 341747 : if ( bw_ext )
238 : {
239 145809 : for ( i = 0; i < *num_sfm; i++ )
240 : {
241 142056 : sfmsize[i] = (int16_t) ( 1.25f * p_sfmsize[i] );
242 142056 : sfm_start[i] = (int16_t) ( 1.25f * p_sfm_start[i] );
243 142056 : sfm_end[i] = (int16_t) ( 1.25f * p_sfm_end[i] );
244 : }
245 3753 : *nb_sfm = *num_sfm;
246 3753 : *num_env_bands = *num_sfm;
247 : }
248 : else
249 : {
250 337994 : mvs2s( p_sfmsize, sfmsize, *num_sfm );
251 337994 : mvs2s( p_sfm_start, sfm_start, *num_sfm );
252 337994 : mvs2s( p_sfm_end, sfm_end, *num_sfm );
253 : }
254 :
255 341747 : *numnrmibits = ( *num_env_bands - 1 ) * NORMI_BITS;
256 :
257 341747 : return;
258 : }
|