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 : #include <stdint.h>
34 : #include "options.h"
35 : #include "cnst.h"
36 : #include "stat_enc.h"
37 : #include "rom_com.h"
38 : #include "ivas_rom_com.h"
39 : #include "ivas_cnst.h"
40 : #include "prot_fx.h"
41 : #include "wmc_auto.h"
42 : #include "ivas_prot_fx.h"
43 : #include "ivas_rom_com_fx.h"
44 :
45 :
46 : /*-------------------------------------------------------------------*
47 : * Local constants
48 : *-------------------------------------------------------------------*/
49 :
50 : #define NB_RATE_POSS 10 /* Nmbr of possible FCB bitrate for half rate mode*/
51 : #define MIN_SEC_ACB_RATE ( 2 * 8 * FRAMES_PER_SEC ) /* 2 subfr ACB bitrate */
52 : #define MIN_SEC_LPC_RATE ( ( 24 + 2 ) * FRAMES_PER_SEC ) /* LPC min rate */
53 :
54 : #define MAX_SC_FCB_RATE ( 24 + 1 ) /* Maximum bit for a FCB subfr */
55 : #define MIN_4SUBFR_FCB_RATE 40 /* Minimum 4 subfr bitrate (4x10 bits) */
56 : #define MIN_GAIN_BITS 6 /* Minimum number of bits used */
57 :
58 : #define TDM_UC_NORMAL_MODE_MBRATE 9000 /* Max bitrate for normal UC if LP coded */
59 : #define TDM_UC_NORMAL_MODE_MBRATE_LP_R 8200 /* Normal bitrate for normal UC if LP is reused */
60 : #define TDM_UC_NORMAL_MODE_MINBR_LP_R 7000 /* If bitrate is below 7k, add back MID_LP_BRATE */
61 : #define MID_LP_BRATE ( 31 + 5 ) * FRAMES_PER_SEC /* average bitrate for LP */
62 : #define MAX_TDM_UC_BRATE 11000 /* Maximum bitrate for tdm normal UC mode */
63 :
64 : #define MIN_SIGN_RATE ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS * FRAMES_PER_SEC ) /* min. 2 time 12 bits FCB, used only when LPC and/or pitch is transmitted */
65 : #define MIN_FCB_SECRATE2 ( 2 * 16 * FRAMES_PER_SEC ) /* min. 2 time 14 bits FCB, used only when LPC and/or pitch is transmitted */
66 :
67 :
68 : /*-------------------------------------------------------------------*
69 : * tdm_bit_alloc()
70 : *
71 : * Bitbudget distribution between Primary and Secondary channel in TD stereo
72 : *-------------------------------------------------------------------*/
73 7522 : void tdm_bit_alloc(
74 : const Word16 ivas_format, /* i : IVAS format Q0*/
75 : const Word16 ism_mode, /* i : ISM mode in combined format Q0*/
76 : const Word32 element_brate_wo_meta, /* i : element bitrate without metadata Q0*/
77 : const Word16 tdm_lp_reuse_flag, /* i : LPC reusage flag Q0*/
78 : Word32 *total_brate_pri, /* o : Allocated primary channel bitrate Q0*/
79 : Word32 *total_brate_sec, /* o : Allocated secondary channel bitrate Q0*/
80 : Word16 *tdm_low_rate_mode, /* o : secondary channel low rate mode flag Q0*/
81 : const Word16 coder_type, /* i : secondary channel coder type Q0*/
82 : const Word16 ener_ratio_idx, /* i : correlation ratio indexe Q0*/
83 : const Word16 tdm_Pitch_reuse_flag, /* i : primary channel pitch reuse flag Q0*/
84 : const Word16 bwidth_pri, /* i : bandwidth of the primary channel Q0*/
85 : const Word16 bwidth_sec, /* i : bandwidth of the secondary channel Q0*/
86 : const Word16 flag_ACELP16k_pri, /* i : ACELP@16kHz core flag, primary chan. Q0*/
87 : const Word16 tdm_LRTD_flag, /* i : LRTD stereo mode flag Q0*/
88 : const Word16 coder_type0, /* i : coder type (temporary in the encoder, from bitstream in decoder) Q0*/
89 : const Word16 tdm_inst_ratio_idx_ref /* i : instantaneous correlation ratio idx Q0*/
90 : )
91 : {
92 : Word16 idx, four_subfr_fcb, two_subfr_fcb;
93 : Word32 bit_rate_diff_fx;
94 : Word32 BWE_brate;
95 : Word16 tmp_bits;
96 7522 : Word16 tdm_inst_ratio_idx = tdm_inst_ratio_idx_ref; /*Q0*/
97 7522 : move16();
98 7522 : if ( EQ_16( tdm_inst_ratio_idx, TDM_NQ ) )
99 : {
100 180 : tdm_inst_ratio_idx = LRTD_STEREO_MID_IS_PRIM; /* Bit rate almost split half and half*/
101 180 : move16();
102 : }
103 :
104 : /* Decision on using the low rate mode or the normal mode */
105 : /* default is using the low rate mode for the secondary channel coding*/
106 : /* UC and IC are automatically coded with low rate mode */
107 7522 : *tdm_low_rate_mode = 1;
108 7522 : move16();
109 :
110 : /* Allocating different bitrate to channels */
111 7522 : idx = 0;
112 7522 : move16();
113 7522 : IF( LE_32( element_brate_wo_meta, IVAS_13k2 ) )
114 : {
115 0 : idx = 0;
116 0 : move16();
117 : }
118 7522 : ELSE IF( LE_32( element_brate_wo_meta, IVAS_16k4 ) )
119 : {
120 1136 : idx = 1;
121 1136 : move16();
122 : }
123 6386 : ELSE IF( LE_32( element_brate_wo_meta, IVAS_24k4 ) )
124 : {
125 2237 : idx = 2;
126 2237 : move16();
127 : }
128 4149 : ELSE IF( LE_32( element_brate_wo_meta, IVAS_32k ) )
129 : {
130 4149 : idx = 3;
131 4149 : move16();
132 : }
133 0 : ELSE IF( LE_32( element_brate_wo_meta, IVAS_48k ) )
134 : {
135 0 : idx = 4;
136 0 : move16();
137 : }
138 :
139 7522 : test();
140 7522 : if ( EQ_16( coder_type, UNVOICED ) && GE_16( tdm_bit_allc_tbl[idx][coder_type], 4200 ) )
141 : {
142 0 : *tdm_low_rate_mode = 0;
143 0 : move16();
144 : }
145 :
146 : /* Secondary channel based bitrate allocation */
147 7522 : *total_brate_sec = tdm_bit_allc_tbl[idx][coder_type]; /*Q0*/
148 7522 : move16();
149 :
150 7522 : test();
151 7522 : test();
152 7522 : test();
153 7522 : test();
154 7522 : test();
155 7522 : test();
156 : /* secondary channel bitrate allocation based on the energy scaling ratio */
157 7522 : IF( ( ( NE_16( ivas_format, MASA_ISM_FORMAT ) || ism_mode == ISM_MODE_NONE ) && ( ( NE_16( coder_type, UNVOICED ) ) || EQ_16( tdm_LRTD_flag, 1 ) ) ) || ( EQ_16( ivas_format, MASA_ISM_FORMAT ) && ism_mode != ISM_MODE_NONE && GT_16( coder_type, UNVOICED ) ) )
158 7498 : {
159 7498 : bit_rate_diff_fx = L_sub( element_brate_wo_meta, L_shl( *total_brate_sec, 1 ) ); /*Q0*/
160 :
161 7498 : IF( EQ_16( tdm_LRTD_flag, 1 ) ) /* > element_brate > STEREO_22k or CT0 not used */
162 : {
163 : /* further adjustment in function of the energy/correlation ratio */
164 7267 : IF( coder_type == INACTIVE )
165 : {
166 0 : Word32 res_fix = 0;
167 0 : move32();
168 0 : res_fix = Mpy_32_32( 644245095 /*0.3f in Q31*/, L_sub( element_brate_wo_meta, 500 ) ); /*Q0*/
169 0 : res_fix = imult3216( Mpy_32_32( L_abs( res_fix ), 21474837 /*0.01 in Q31*/ ), 100 ); /*Q0*/
170 0 : if ( res_fix < 0 )
171 : {
172 0 : res_fix = L_negate( res_fix );
173 : }
174 0 : *total_brate_sec = L_max( *total_brate_sec, res_fix ); /*Q0*/
175 0 : move32();
176 :
177 0 : tmp_bits = imult1616( negate( abs_s( sub( tdm_inst_ratio_idx, 16 ) ) ), imult1616( idx, 200 ) ); /*Q0*/
178 : }
179 : ELSE
180 : {
181 7267 : Word32 res_fix = 0;
182 7267 : move32();
183 7267 : res_fix = Mpy_32_32( 1073741824 /*0.5f in Q31*/, L_sub( element_brate_wo_meta, 500 ) ); /*Q0*/
184 7267 : res_fix = imult3216( Mpy_32_32( L_abs( res_fix ), 21474837 /*0.01 in Q31*/ ), 100 ); /*Q0*/
185 7267 : if ( res_fix < 0 )
186 : {
187 0 : res_fix = L_negate( res_fix );
188 : }
189 7267 : *total_brate_sec = L_max( *total_brate_sec, res_fix ); /*Q0*/
190 7267 : move32();
191 :
192 7267 : tmp_bits = imult1616( negate( abs_s( sub( tdm_inst_ratio_idx, 16 ) ) ), imult1616( 100, idx ) ); /*Q0*/
193 : }
194 :
195 : /* tmp_bits should be subtract from the secondary channel bitrate */
196 : /* IF the primary channel doesn't correspond to the channel having the highest correlation to the mono- inverse the bitrate compensation */
197 7267 : test();
198 7267 : test();
199 7267 : test();
200 7267 : if ( ( GE_16( ener_ratio_idx, LRTD_STEREO_MID_IS_PRIM ) && LT_16( tdm_inst_ratio_idx, LRTD_STEREO_MID_IS_PRIM ) ) || ( LT_16( ener_ratio_idx, LRTD_STEREO_MID_IS_PRIM ) && GE_16( tdm_inst_ratio_idx, LRTD_STEREO_MID_IS_PRIM ) ) )
201 : {
202 3238 : tmp_bits = negate( tmp_bits );
203 : }
204 7267 : bit_rate_diff_fx = tmp_bits;
205 7267 : move16();
206 : }
207 : ELSE
208 : {
209 231 : IF( LT_16( ener_ratio_idx, LRTD_STEREO_MID_IS_PRIM ) )
210 : {
211 :
212 131 : bit_rate_diff_fx = imult3216( bit_rate_diff_fx, sub( LRTD_STEREO_MID_IS_PRIM, ener_ratio_idx ) ); /*Q0*/
213 131 : bit_rate_diff_fx = L_shr( bit_rate_diff_fx, 1 ); /*Q0*/
214 131 : bit_rate_diff_fx = Mpy_32_16_1( L_abs( bit_rate_diff_fx ), 3277 /*0.1f in Q15*/ ); /*Q0*/
215 131 : if ( bit_rate_diff_fx < 0 )
216 : {
217 0 : bit_rate_diff_fx = L_negate( bit_rate_diff_fx );
218 : }
219 : }
220 : ELSE
221 : {
222 100 : bit_rate_diff_fx = imult3216( bit_rate_diff_fx, sub( ener_ratio_idx, LRTD_STEREO_MID_IS_PRIM ) ); /*Q0*/
223 100 : bit_rate_diff_fx = L_shr( bit_rate_diff_fx, 1 ); /*Q0*/
224 100 : bit_rate_diff_fx = Mpy_32_16_1( L_abs( bit_rate_diff_fx ), 3277 /*0.1f in Q15*/ ); /*Q0*/
225 100 : if ( bit_rate_diff_fx < 0 )
226 : {
227 0 : bit_rate_diff_fx = L_negate( bit_rate_diff_fx );
228 : }
229 : }
230 : }
231 : /*bit_rate_diff2 = ((Word16)(10.f*(-0.5f*ener_ratio_LR+0.5f)*bit_rate_diff)/100)*100;*/
232 7498 : Word32 temp = imult3216( Mpy_32_16_1( L_abs( bit_rate_diff_fx ), 328 /*0.01f in Q15*/ ), 100 ); /*Q0*/
233 7498 : if ( bit_rate_diff_fx < 0 )
234 : {
235 3881 : temp = L_negate( temp );
236 : }
237 7498 : *total_brate_sec = L_add( *total_brate_sec, temp ); /*Q0*/
238 7498 : move32();
239 :
240 7498 : *total_brate_sec = L_max( *total_brate_sec, tdm_bit_allc_tbl[idx][coder_type] ); /*Q0*/
241 7498 : move32();
242 :
243 7498 : test();
244 7498 : IF( ( coder_type == INACTIVE ) && tdm_LRTD_flag == 0 )
245 : {
246 0 : *total_brate_sec = L_min( *total_brate_sec, MIN_BRATE_SWB_BWE ); /*Q0*/
247 0 : move32();
248 : }
249 :
250 7498 : test();
251 7498 : test();
252 7498 : IF( ( LE_16( ener_ratio_idx, 1 ) || GE_16( ener_ratio_idx, 29 ) ) && GE_16( coder_type, UNVOICED ) )
253 7369 : {
254 7369 : Word16 delta_brate = 0;
255 7369 : move16();
256 :
257 7369 : IF( GT_16( bwidth_pri, WB ) )
258 : {
259 5745 : delta_brate = 600; /* To slightly compensate for SWB BWE instead of WB BWE Q0*/
260 5745 : move16();
261 5745 : if ( LE_32( element_brate_wo_meta, IVAS_16k4 ) )
262 : {
263 898 : delta_brate = 1250; /* To compensate for SWB BWE instead of WB BWE Q0*/
264 898 : move16();
265 : }
266 : }
267 :
268 7369 : IF( LE_32( element_brate_wo_meta, IVAS_13k2 ) )
269 : {
270 0 : *total_brate_sec = L_max( *total_brate_sec, add( 5600, delta_brate ) ); /* ~42-47 % of the total bitrate */
271 0 : move32();
272 : }
273 7369 : ELSE IF( LE_32( element_brate_wo_meta, IVAS_16k4 ) )
274 : {
275 1106 : *total_brate_sec = L_max( *total_brate_sec, add( 6500, delta_brate ) ); /* ~40-43 % of the total bitrate Q0*/
276 1106 : move32();
277 : }
278 6263 : ELSE IF( LE_32( element_brate_wo_meta, IVAS_24k4 ) )
279 : {
280 2201 : *total_brate_sec = L_max( *total_brate_sec, add( 9000, delta_brate ) ); /* ~37-39 % of the total bitrate Q0*/
281 2201 : move32();
282 : }
283 : ELSE
284 : {
285 4062 : *total_brate_sec = L_max( *total_brate_sec, add( 9600, delta_brate ) ); /* ~30-32% of the total bitrate Q0*/
286 4062 : move32();
287 : }
288 : }
289 : ELSE
290 : {
291 129 : *total_brate_sec = L_min( *total_brate_sec, Mpy_32_32( 9663677 /*0.0045f in Q31*/, element_brate_wo_meta ) * 100 ); /*Q0*/
292 129 : move32();
293 : }
294 :
295 7498 : *total_brate_sec = L_min( *total_brate_sec, 18000 ); /*Q0*/
296 7498 : move32();
297 : }
298 24 : ELSE IF( EQ_16( coder_type, UNVOICED ) )
299 : {
300 24 : IF( tdm_lp_reuse_flag == 0 )
301 : {
302 16 : *total_brate_sec = L_add( *total_brate_sec, imult3216( FRAMES_PER_SEC, 36 ) ); /*Q0*/
303 16 : move32();
304 : }
305 : }
306 :
307 7522 : IF( LE_16( coder_type, UNVOICED ) )
308 : {
309 190 : *total_brate_sec = L_min( *total_brate_sec, MAX_TDM_UC_BRATE ); /*Q0*/
310 190 : move32();
311 :
312 190 : test();
313 190 : test();
314 190 : test();
315 190 : test();
316 190 : test();
317 190 : IF( GE_32( *total_brate_sec, TDM_UC_NORMAL_MODE_MBRATE ) && tdm_lp_reuse_flag == 0 )
318 : {
319 144 : *tdm_low_rate_mode = 0;
320 144 : move16();
321 : }
322 46 : ELSE IF( GE_32( *total_brate_sec, TDM_UC_NORMAL_MODE_MBRATE_LP_R ) )
323 : {
324 0 : *tdm_low_rate_mode = 0;
325 0 : move16();
326 : }
327 46 : ELSE IF( ( tdm_lp_reuse_flag == 0 && LT_32( *total_brate_sec, TDM_UC_NORMAL_MODE_MINBR_LP_R ) && EQ_16( coder_type, UNVOICED ) ) || ( tdm_lp_reuse_flag == 0 && LE_32( *total_brate_sec, L_deposit_l( add( tdm_bit_allc_tbl[idx][0], MID_LP_BRATE ) ) ) ) )
328 : {
329 16 : *total_brate_sec = L_add( *total_brate_sec, MID_LP_BRATE ); /*Q0*/
330 16 : move32();
331 : }
332 : }
333 :
334 : /* verify that primary channel bitrate is higher than the minimum supported bitrate */
335 7522 : IF( flag_ACELP16k_pri )
336 : {
337 4185 : BWE_brate = SWB_TBE_1k75;
338 4185 : move32();
339 :
340 4185 : test();
341 4185 : test();
342 4185 : if ( LT_32( element_brate_wo_meta, IVAS_24k4 ) )
343 : {
344 0 : BWE_brate = SWB_TBE_1k10;
345 0 : move32();
346 : }
347 :
348 4185 : test();
349 4185 : if ( GT_16( bwidth_pri, WB ) && tdm_LRTD_flag == 0 )
350 : {
351 171 : BWE_brate = L_add( BWE_brate, ( STEREO_BITS_ICBWE + STEREO_ICBWE_MSFLAG_BITS ) * FRAMES_PER_SEC );
352 : }
353 4185 : test();
354 4185 : if ( GT_16( bwidth_pri, SWB ) && EQ_16( tdm_LRTD_flag, 1 ) )
355 : {
356 1397 : BWE_brate = L_add( BWE_brate, 300 );
357 : }
358 :
359 4185 : if ( EQ_16( bwidth_pri, FB ) )
360 : {
361 1418 : BWE_brate = L_add( BWE_brate, ( FB_TBE_1k8 - SWB_TBE_1k75 ) );
362 : }
363 :
364 4185 : IF( LT_32( ( L_sub( ( L_sub( element_brate_wo_meta, *total_brate_sec ) ), BWE_brate ) ), 14000 ) )
365 : {
366 1906 : *total_brate_sec = L_sub( element_brate_wo_meta, L_add( 14000, BWE_brate ) ); /*Q0*/
367 1906 : move32();
368 : }
369 : }
370 : ELSE
371 : {
372 3337 : BWE_brate = SWB_TBE_1k75;
373 3337 : move32();
374 3337 : IF( EQ_16( bwidth_pri, WB ) )
375 : {
376 821 : BWE_brate = WB_BWE_0k35;
377 821 : move32();
378 821 : if ( tdm_LRTD_flag == 0 )
379 : {
380 6 : BWE_brate = L_add( BWE_brate, 250 ); /* ICA Brate Q0*/
381 : }
382 : }
383 2516 : ELSE IF( tdm_LRTD_flag == 0 )
384 : {
385 24 : BWE_brate = L_add( BWE_brate, 350 ); /* ICA Brate Q0*/
386 : }
387 : }
388 :
389 7522 : IF( EQ_16( coder_type0, TRANSITION ) )
390 : {
391 45 : IF( GT_32( element_brate_wo_meta, IVAS_13k2 ) )
392 : {
393 45 : *total_brate_sec = L_min( *total_brate_sec, L_sub( element_brate_wo_meta, L_add( ACELP_8k00, BWE_brate ) ) ); /*Q0*/
394 45 : move32();
395 : }
396 : ELSE
397 : {
398 0 : *total_brate_sec = L_min( *total_brate_sec, L_sub( element_brate_wo_meta, L_add( ACELP_7k20, BWE_brate ) ) ); /*Q0*/
399 0 : move32();
400 : }
401 : }
402 : ELSE
403 : {
404 7477 : *total_brate_sec = L_min( *total_brate_sec, L_sub( element_brate_wo_meta, L_add( 5900, BWE_brate ) ) ); /*Q0*/
405 7477 : move32();
406 : }
407 :
408 7522 : IF( coder_type == INACTIVE )
409 : {
410 0 : *total_brate_sec = L_max( *total_brate_sec, tdm_bit_allc_tbl[0][0] ); /* sanity check to ensure the secondary channel always gets the minimal bitrate it needs Q0*/
411 0 : move32();
412 : }
413 : ELSE
414 : {
415 7522 : *total_brate_sec = L_max( *total_brate_sec, 3500 ); /* sanity check to ensure the secondary channel always gets the minimal bitrate it needs Q0*/
416 7522 : move32();
417 : }
418 :
419 : /* Secondary channel bitrate adjusment */
420 : /* First, adjust the bitrate depending of what is transmitted */
421 : /* Second, choose the number of subframe for ACELP core depending of the targetted bitratre */
422 : /* Finally, verify that the concordance between the number of subframe, the parameters sent and the bitrate available */
423 7522 : IF( EQ_16( coder_type, GENERIC ) /* || coder_type == AUDIO*/ )
424 : {
425 : /* Adjust the bitrate depending of what is transmitted */
426 : /* IF LPC are transmitted, ensure enough bits are used */
427 7332 : IF( tdm_lp_reuse_flag == 0 )
428 : {
429 : /* Pitch is transmitted as well, further increase the bitrate */
430 7069 : IF( tdm_Pitch_reuse_flag == 0 )
431 : {
432 7001 : *total_brate_sec = L_max( *total_brate_sec, MIN_FCB_SECRATE2 + MIN_SEC_ACB_RATE + MIN_SEC_LPC_RATE + MIN_SIGN_RATE ); /*Q0*/
433 7001 : move32();
434 :
435 7001 : test();
436 7001 : IF( EQ_16( tdm_LRTD_flag, 1 ) && EQ_16( bwidth_sec, SWB ) )
437 : {
438 : /* ensure that there are enough bits to code SWB TBE_1k10 as well */
439 3936 : *total_brate_sec = L_max( *total_brate_sec, MIN_FCB_SECRATE2 + MIN_SEC_ACB_RATE + MIN_SEC_LPC_RATE + MIN_SIGN_RATE + SWB_TBE_1k10 ); /*Q0*/
440 3936 : move32();
441 : }
442 : }
443 : ELSE /* only LPC is tranmitted -> IF ( *total_brate_sec < MIN_SEC_BRATE+MIN_SEC_LPC_RATE ) */
444 : {
445 68 : *total_brate_sec = L_max( *total_brate_sec, MIN_FCB_SECRATE2 + MIN_SEC_LPC_RATE + MIN_SIGN_RATE ); /*Q0*/
446 68 : move32();
447 : }
448 : }
449 263 : ELSE IF( /*tdm_lp_reuse_flag == 1*/ tdm_Pitch_reuse_flag == 0 )
450 : {
451 263 : *total_brate_sec = L_max( *total_brate_sec, MIN_FCB_SECRATE2 + MIN_SEC_ACB_RATE + MIN_SIGN_RATE ); /*Q0*/
452 263 : move32();
453 : }
454 :
455 : /* Choose between 2 and 4 subfr, depending of the bitrate available and prevent the gap between the 2 atlernative */
456 7332 : IF( EQ_16( tdm_LRTD_flag, 1 ) )
457 : {
458 7101 : four_subfr_fcb = extract_l( L_sub( *total_brate_sec, ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS - STEREO_BITS_TCA + 1 + 4 * MIN_GAIN_BITS ) * FRAMES_PER_SEC ) ); /*Q0*/
459 7101 : two_subfr_fcb = extract_l( L_sub( *total_brate_sec, ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS - STEREO_BITS_TCA + 1 + 2 * MIN_GAIN_BITS ) * FRAMES_PER_SEC ) ); /*Q0*/
460 : }
461 : ELSE
462 : {
463 231 : four_subfr_fcb = extract_l( L_sub( *total_brate_sec, ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + 1 + 4 * MIN_GAIN_BITS ) * FRAMES_PER_SEC ) ); /*Q0*/
464 231 : two_subfr_fcb = extract_l( L_sub( *total_brate_sec, ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + 1 + 2 * MIN_GAIN_BITS ) * FRAMES_PER_SEC ) ); /*Q0*/
465 : }
466 :
467 7332 : IF( tdm_lp_reuse_flag == 0 )
468 : {
469 7069 : four_subfr_fcb = sub( four_subfr_fcb, MIN_SEC_LPC_RATE ); /*Q0*/
470 7069 : two_subfr_fcb = sub( two_subfr_fcb, MIN_SEC_LPC_RATE ); /*Q0*/
471 : }
472 :
473 7332 : IF( tdm_Pitch_reuse_flag == 0 )
474 : {
475 7264 : four_subfr_fcb = sub( four_subfr_fcb, ( MIN_SEC_ACB_RATE + 10 * FRAMES_PER_SEC ) ); /*Q0*/
476 7264 : two_subfr_fcb = sub( two_subfr_fcb, MIN_SEC_ACB_RATE ); /*Q0*/
477 : }
478 :
479 : /* Too much bits for the 2 subfr model but not enough for the the 4 subfr model -> slightly reduce the 2nd channel bitrate */
480 7332 : test();
481 7332 : IF( GT_16( two_subfr_fcb, 2 * MAX_SC_FCB_RATE * FRAMES_PER_SEC ) && LT_16( four_subfr_fcb, MIN_4SUBFR_FCB_RATE * FRAMES_PER_SEC ) )
482 : {
483 0 : IF( EQ_16( tdm_LRTD_flag, 1 ) )
484 : {
485 0 : *total_brate_sec = 2 * MAX_SC_FCB_RATE * FRAMES_PER_SEC + ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS - STEREO_BITS_TCA + 1 + 2 * MIN_GAIN_BITS ) * FRAMES_PER_SEC; /*Q0*/
486 0 : move32();
487 : }
488 : ELSE
489 : {
490 0 : *total_brate_sec = 2 * MAX_SC_FCB_RATE * FRAMES_PER_SEC + ( TDM_SIGNAL_BITS_READ_FROM_THE_END_OF_BS + 1 + 2 * MIN_GAIN_BITS ) * FRAMES_PER_SEC; /*Q0*/
491 0 : move32();
492 : }
493 :
494 0 : IF( tdm_lp_reuse_flag == 0 )
495 : {
496 0 : *total_brate_sec = L_add( *total_brate_sec, MIN_SEC_LPC_RATE ); /*Q0*/
497 0 : move32();
498 : }
499 :
500 0 : IF( tdm_Pitch_reuse_flag == 0 )
501 : {
502 0 : *total_brate_sec = L_add( *total_brate_sec, MIN_SEC_ACB_RATE ); /*Q0*/
503 0 : move32();
504 : }
505 : }
506 7332 : ELSE IF( GE_16( four_subfr_fcb, 40 * FRAMES_PER_SEC ) ) /* Enough bits to have minimally 2 x 12 + 2*7 bits FCB */
507 : {
508 7327 : *tdm_low_rate_mode = 0; /* Use normal rate mode */
509 7327 : move16();
510 : }
511 : ELSE /* Possible slight increase of secondary channel bit budget to compensate for FCB limited flexibility */
512 : {
513 : Word16 tmp_rate, i;
514 5 : tmp_rate = two_subfr_fcb; /*Q0*/
515 5 : move16();
516 5 : idx = sub( NB_RATE_POSS, 2 );
517 :
518 40 : FOR( i = 0; i < NB_RATE_POSS; i++ ){
519 40 : IF( LE_16( tmp_rate, fast_FCB_rates_2sfr[i] ) ){
520 5 : idx = i;
521 5 : move16();
522 5 : BREAK;
523 : }
524 : }
525 5 : *total_brate_sec = L_add( *total_brate_sec, sub( fast_FCB_rates_2sfr[idx], tmp_rate ) ); /*Q0*/
526 5 : move32();
527 : }
528 : /* To prevent 13.2 kb/s for primary channel as some bitstream issues arrise with it */
529 7332 : IF( EQ_32( L_sub( element_brate_wo_meta, *total_brate_sec ), ACELP_13k20 ) )
530 : {
531 0 : *total_brate_sec = L_add( *total_brate_sec, 100 ); /*Q0*/
532 0 : move32();
533 : }
534 : }
535 : /* prevent 2.4 kb/s and 2.8 kb/s as they are reserved bitrates for DTX and VBR */
536 7522 : test();
537 7522 : IF( EQ_32( *total_brate_sec, PPP_NELP_2k80 ) || EQ_32( *total_brate_sec, SID_2k40 ) )
538 : {
539 0 : *total_brate_sec = L_sub( *total_brate_sec, 100 ); /*Q0*/
540 0 : move32();
541 : }
542 :
543 7522 : *total_brate_pri = L_sub( element_brate_wo_meta, *total_brate_sec ); /*Q0*/
544 7522 : move32();
545 :
546 7522 : return;
547 : }
548 : /*-------------------------------------------------------------------*
549 : * td_stereo_param_updt()
550 : *
551 : * copy certain TD stereo parameters from primary channel to secondary channel
552 : *-------------------------------------------------------------------*/
553 7578 : void td_stereo_param_updt_fx(
554 : const Word16 lsp_old_PCh_fx[], /* i : primary channel old LSPs Q15 */
555 : const Word16 lsf_old_PCh_fx[], /* i : primary channel old LSFs Qlog2(2.56) */
556 : const Word16 pitch_buf_PCh_fx[], /* i : primary channel pitch buffer Q6 */
557 : Word16 tdm_lspQ_PCh_fx[], /* o : Q LSPs for primary channel Q15 */
558 : Word16 tdm_lsfQ_PCh_fx[], /* o : Q LSFs for primary channel Qlog2(2.56) */
559 : Word16 tdm_Pri_pitch_buf_fx[], /* o : pitch values for primary channel Q6 */
560 : const Word16 flag_ACELP16k, /* i : ACELP@16kHz flag Q0*/
561 : const Word16 tdm_use_IAWB_Ave_lpc /* i : flag to indicate the usage of mean inactive LP coefficients Q0*/
562 : )
563 : {
564 : Word16 i;
565 : /* Copy some primary channel information into the secondary channel structure for later usage */
566 7578 : IF( EQ_16( tdm_use_IAWB_Ave_lpc, 1 ) )
567 : {
568 : /*not being assert*/
569 0 : Copy( IAWB_Ave_fx, tdm_lsfQ_PCh_fx, M ); /*Qlog2(2.56)*/
570 0 : lsf2lsp_fx( tdm_lsfQ_PCh_fx, tdm_lspQ_PCh_fx, M, INT_FS_12k8 );
571 : }
572 7578 : ELSE IF( EQ_16( flag_ACELP16k, 1 ) )
573 : {
574 4223 : Copy( lsp_old_PCh_fx, tdm_lspQ_PCh_fx, M ); /*Q15*/
575 4223 : lsp_convert_poly_fx( tdm_lspQ_PCh_fx, L_FRAME, 0 );
576 4223 : lsp2lsf_fx( tdm_lspQ_PCh_fx, tdm_lsfQ_PCh_fx, M, INT_FS_12k8 );
577 : }
578 : ELSE
579 : {
580 3355 : Copy( lsp_old_PCh_fx, tdm_lspQ_PCh_fx, M ); /*Q15*/
581 3355 : Copy( lsf_old_PCh_fx, tdm_lsfQ_PCh_fx, M ); /*Qlog2(2.56)*/
582 : }
583 7578 : IF( EQ_16( flag_ACELP16k, 1 ) )
584 : {
585 : Word16 tmp16;
586 4223 : Word16 mult_factor = 26214 /*0.8f in Q15*/;
587 4223 : move16();
588 21115 : FOR( i = 0; i < NB_SUBFR; i++ )
589 : {
590 16892 : tmp16 = mult_r( pitch_buf_PCh_fx[i], mult_factor ); /* Convert 16kHz to 12.8 kHz pitch values Q6*/
591 16892 : tdm_Pri_pitch_buf_fx[i] = s_max( tmp16, shl( PIT_MIN, 6 ) ); /* pitch is represented in Q6*/
592 16892 : move16();
593 : }
594 : }
595 : ELSE
596 : {
597 3355 : Copy( pitch_buf_PCh_fx, tdm_Pri_pitch_buf_fx, NB_SUBFR ); /*Q6*/
598 : }
599 :
600 7578 : return;
601 : }
602 :
603 : /*-------------------------------------------------------------------*
604 : * tdm_SCh_LSF_intra_pred_zero_bits_fx()
605 : *
606 : *
607 : *-------------------------------------------------------------------*/
608 :
609 236 : static void tdm_SCh_LSF_intra_pred_zero_bits_fx(
610 : const Word16 *tdm_lsfQ_PCh_fx, /* i : primary channel LSFs x2.56*/
611 : Word16 *pred_lsf_SCh_fx, /* o : predicted secondary channel LSFs x2.56*/
612 : const Word16 *lsf_mean_fx, /* i : secondary channel mean LSFs x2.56*/
613 : const Word16 beta_fx /* i : pull to average beta factor Q15*/
614 : )
615 : {
616 : Word16 i;
617 : /* pulling the LSFs closer to the average */
618 4012 : FOR( i = 0; i < M; i++ )
619 : {
620 3776 : pred_lsf_SCh_fx[i] = add( mult_r( beta_fx, tdm_lsfQ_PCh_fx[i] ), mult_r( sub( 32767 /*1.0f in Q15*/, beta_fx ), lsf_mean_fx[i] ) );
621 3776 : move16();
622 : }
623 :
624 236 : return;
625 : }
626 :
627 : /*-------------------------------------------------------------------*
628 : * tdm_SCh_LSF_intra_pred_tri_diag_mat_fx()
629 : *
630 : *
631 : *-------------------------------------------------------------------*/
632 :
633 507 : static void tdm_SCh_LSF_intra_pred_tri_diag_mat_fx(
634 : Word16 *lsf_SCh_fx, /* i/o: secondary channel LSFs x2.56*/
635 : const Word16 *lsf_mean_in_fx, /* i : secondary channel mean LSFs (in) x2.56*/
636 : const Word16 *lsf_mean_out_fx, /* i : secondary channel mean LSFs (out) x2.56*/
637 : const Word16 *prd_diag_3_fx /* i : secondary channel mean LSFs Q15*/
638 : )
639 : {
640 : Word16 i;
641 : Word16 lsf_tmp_fx[M];
642 : const Word16 *prd_ptr_fx;
643 : Word16 *lsf_tmp_ptr1_fx;
644 : Word16 *lsf_tmp_ptr2_fx;
645 : Word16 *lsf_SCh_ptr_fx;
646 :
647 507 : prd_ptr_fx = prd_diag_3_fx; /*Q15*/
648 :
649 507 : v_sub_16( lsf_SCh_fx, lsf_mean_in_fx, lsf_tmp_fx, M );
650 :
651 507 : lsf_tmp_ptr1_fx = lsf_tmp_fx; /*x2.56*/
652 :
653 507 : lsf_SCh_ptr_fx = lsf_SCh_fx; /*x2.56*/
654 :
655 :
656 507 : lsf_tmp_ptr2_fx = lsf_tmp_ptr1_fx; /*x2.56*/
657 :
658 507 : *lsf_SCh_ptr_fx = mult_r( *lsf_tmp_ptr1_fx++, *prd_ptr_fx++ ); // Q2.56 + 15 -15
659 507 : move16();
660 507 : *lsf_SCh_ptr_fx = add( *lsf_SCh_ptr_fx, mult_r( *lsf_tmp_ptr1_fx, *prd_ptr_fx++ ) ); // Q2.56 + 15 -15
661 507 : move16();
662 507 : lsf_SCh_ptr_fx++;
663 :
664 7605 : FOR( i = 1; i < M - 1; i++ )
665 : {
666 7098 : lsf_tmp_ptr1_fx = lsf_tmp_ptr2_fx; // Q2.56
667 7098 : *lsf_SCh_ptr_fx = mult_r( *lsf_tmp_ptr1_fx++, *prd_ptr_fx++ ); // Q2.56 + 15 -15
668 7098 : move16();
669 7098 : lsf_tmp_ptr2_fx = lsf_tmp_ptr1_fx; /*x2.56*/
670 7098 : *lsf_SCh_ptr_fx = add( *lsf_SCh_ptr_fx, mult_r( ( *lsf_tmp_ptr1_fx++ ), ( *prd_ptr_fx++ ) ) ); /*x2.56*/
671 7098 : move16();
672 7098 : ( *lsf_SCh_ptr_fx ) = add( *lsf_SCh_ptr_fx, mult_r( ( *lsf_tmp_ptr1_fx ), ( *prd_ptr_fx++ ) ) ); /*x2.56*/
673 7098 : move16();
674 7098 : lsf_SCh_ptr_fx++;
675 : }
676 :
677 507 : lsf_tmp_ptr1_fx = lsf_tmp_ptr2_fx; /*x2.56*/
678 507 : *lsf_SCh_ptr_fx = mult_r( ( *lsf_tmp_ptr1_fx ), ( *prd_ptr_fx ) ); /*x2.56*/
679 507 : move16();
680 507 : lsf_tmp_ptr1_fx++;
681 507 : prd_ptr_fx++;
682 507 : *lsf_SCh_ptr_fx = add( mult_r( ( *lsf_tmp_ptr1_fx ), ( *prd_ptr_fx ) ), *lsf_SCh_ptr_fx ); /*x2.56*/
683 507 : move16();
684 :
685 507 : v_add_16( lsf_SCh_fx, lsf_mean_out_fx, lsf_SCh_fx, M ); /*x2.56*/
686 :
687 507 : return;
688 : }
689 :
690 : /*-------------------------------------------------------------------*
691 : * tdm_SCh_LSF_intra_pred_fx()
692 : *
693 : *
694 : *-------------------------------------------------------------------*/
695 :
696 236 : void tdm_SCh_LSF_intra_pred_fx(
697 : const Word32 element_brate, /* i : element bitrate Q0*/
698 : const Word16 *tdm_lsfQ_PCh_fx, /* i : primary channel LSFs x2.56*/
699 : Word16 *pred_lsf_SCh_fx /* o : predicted secondary channel LSFs x2.56*/
700 : )
701 : {
702 : Word16 fixed_beta;
703 :
704 236 : IF( LE_32( element_brate, IVAS_13k2 ) )
705 : {
706 0 : fixed_beta = 28508; // 0.87f in Q15
707 0 : move16();
708 : }
709 236 : ELSE IF( LE_32( element_brate, IVAS_16k4 ) )
710 : {
711 30 : fixed_beta = 30801; // 0.94f in Q15
712 30 : move16();
713 : }
714 206 : ELSE IF( element_brate <= IVAS_24k4 )
715 : {
716 28 : fixed_beta = 29818; // 0.91f in Q15
717 28 : move16();
718 : }
719 178 : ELSE IF( LE_32( element_brate, IVAS_32k ) )
720 : {
721 178 : fixed_beta = 30146; // 0.92f in Q15
722 178 : move16();
723 : }
724 : ELSE
725 : {
726 0 : fixed_beta = 29818; // 0.91f in Q15
727 0 : move16();
728 : }
729 :
730 236 : tdm_SCh_LSF_intra_pred_zero_bits_fx( tdm_lsfQ_PCh_fx, pred_lsf_SCh_fx, tdm_LSF_MEAN_PRED_QNT_fx, fixed_beta );
731 :
732 236 : tdm_SCh_LSF_intra_pred_tri_diag_mat_fx( pred_lsf_SCh_fx, tdm_LSF_MEAN_PRED_QNT_IN_fx, tdm_LSF_MEAN_PRED_QNT_OUT_fx, tdm_PRED_QNT_fixed_beta_prd_diag_3_fx );
733 :
734 236 : return;
735 : }
736 :
737 : /*-------------------------------------------------------------------*
738 : * tdm_SCh_LSF_intra_pred_one_bit_dec_fx()
739 : *
740 : *
741 : *-------------------------------------------------------------------*/
742 :
743 271 : static void tdm_SCh_LSF_intra_pred_one_bit_dec_fx(
744 : const Word16 *tdm_lsfQ_PCh_fx, /* i : primary channel LSFs x2.56*/
745 : Word16 *pred_lsf_SCh_fx, /* o : predicted secondary channel LSFs x2.56*/
746 : const Word16 *lsf_mean_fx, /* i : secondary channel mean LSFs x2.56*/
747 : const Word16 *Beta_Q_x_fx, /* i : beta quantization values Q15*/
748 : const Word16 beta_index_fx /* i : the quantization bits for beta (-1 if beta fixed) Q0*/
749 : )
750 : {
751 : Word16 i;
752 : Word16 beta_fx;
753 :
754 271 : beta_fx = Beta_Q_x_fx[beta_index_fx]; // Q15
755 271 : move16();
756 :
757 : /* pulling the LSFs closer to the avergae */
758 4607 : FOR( i = 0; i < M; i++ )
759 : {
760 4336 : pred_lsf_SCh_fx[i] = add( mult_r( beta_fx, tdm_lsfQ_PCh_fx[i] ), mult_r( sub( 32767 /*1.0f in Q15*/, beta_fx ), lsf_mean_fx[i] ) ); /*x2.56*/
761 4336 : move16();
762 : }
763 :
764 271 : return;
765 : }
766 :
767 : /*-------------------------------------------------------------------*
768 : * tdm_SCh_LSF_intra_pred_one_bit_enc_fx()
769 : *
770 : *
771 : *-------------------------------------------------------------------*/
772 :
773 130 : static void tdm_SCh_LSF_intra_pred_one_bit_enc_fx(
774 : const Word16 *lsf_SCh_fx, /* i : secondary channel LSFs x2.56*/
775 : const Word16 *tdm_lsfQ_PCh_fx, /* i : primary channel LSFs x2.56*/
776 : Word16 *pred_lsf_SCh_fx, /* o : predicted secondary channel LSFs x2.56*/
777 : const Word16 *lsf_mean_fx, /* i : secondary channel mean LSFs x2.56*/
778 : const Word16 *lsf_wgts_new_fx, /* i : Improved wgts for LSFs Q8*/
779 : const Word16 *Beta_Q_x_fx, /* i : beta quantization values Q15*/
780 : Word16 *beta_index /* o : the quantization bits for beta (-1 if beta fixed) Q0*/
781 : )
782 : {
783 : Word16 i;
784 :
785 : Word16 A_temp_fx[M];
786 : Word16 B_temp_fx[M];
787 130 : Word32 WD_fx[2] = { 0 };
788 130 : move32();
789 130 : move32();
790 :
791 2210 : FOR( i = 0; i < M; i++ )
792 : {
793 2080 : A_temp_fx[i] = sub( lsf_SCh_fx[i], lsf_mean_fx[i] ); /*x2.56*/
794 2080 : move16();
795 2080 : B_temp_fx[i] = sub( lsf_mean_fx[i], tdm_lsfQ_PCh_fx[i] ); /*x2.56*/
796 2080 : move16();
797 : }
798 :
799 2210 : FOR( i = 0; i < M; i++ )
800 : {
801 2080 : Word32 wgt_A_temp = Mpy_32_16_1( L_mult( A_temp_fx[i], A_temp_fx[i] ), lsf_wgts_new_fx[i] ); /*2*(x2.56)-7*/
802 2080 : Word32 wgt_B_temp = Mpy_32_16_1( L_mult( B_temp_fx[i], B_temp_fx[i] ), lsf_wgts_new_fx[i] ); /*2*(x2.56)-7*/
803 2080 : Word32 wgt_AB_temp = Mpy_32_16_1( L_mult( A_temp_fx[i], B_temp_fx[i] ), lsf_wgts_new_fx[i] ); /*2*(x2.56)-7*/
804 2080 : Word32 Beta_Q_x0 = L_mult( Beta_Q_x_fx[0], Beta_Q_x_fx[0] ); // Q31
805 2080 : Word32 Beta_Q_x1 = L_mult( Beta_Q_x_fx[1], Beta_Q_x_fx[1] ); // Q31
806 :
807 2080 : WD_fx[0] = L_add( WD_fx[0], L_add( L_add( wgt_A_temp, Mpy_32_16_1( L_shl( wgt_AB_temp, 1 ), Beta_Q_x_fx[0] ) ), Mpy_32_32( wgt_B_temp, Beta_Q_x0 ) ) ); /*2*(x2.56)-7*/
808 2080 : move32();
809 2080 : WD_fx[1] = L_add( WD_fx[1], L_add( L_add( wgt_A_temp, Mpy_32_16_1( L_shl( wgt_AB_temp, 1 ), Beta_Q_x_fx[1] ) ), Mpy_32_32( wgt_B_temp, Beta_Q_x1 ) ) ); /*2*(x2.56)-7*/
810 2080 : move32();
811 : }
812 :
813 130 : IF( LT_32( WD_fx[0], WD_fx[1] ) )
814 : {
815 129 : *beta_index = 0;
816 129 : move16();
817 : }
818 : ELSE
819 : {
820 1 : *beta_index = 1;
821 1 : move16();
822 : }
823 :
824 130 : tdm_SCh_LSF_intra_pred_one_bit_dec_fx( tdm_lsfQ_PCh_fx, pred_lsf_SCh_fx, tdm_LSF_MEAN_RE_USE_fx, Beta_Q_x_fx, *beta_index );
825 :
826 130 : return;
827 : }
828 :
829 : /*-------------------------------------------------------------------*
830 : * tdm_SCh_lsf_reuse_fx()
831 : *
832 : *
833 : *-------------------------------------------------------------------*/
834 :
835 271 : void tdm_SCh_lsf_reuse_fx(
836 : const Word16 enc_dec, /* i : encoder/decoder flag Q0*/
837 : const Word32 element_brate, /* i : element bitrate Q0*/
838 : Word16 lsf_new_fx[M], /* i/o: LSFs at the end of the frame x2.56*/
839 : Word16 lsp_new_fx[M], /* i/o: LSPs at the end of the frame Q15*/
840 : const Word16 tdm_lsfQ_PCh_fx[M], /* i : primary channel LSFs x2.56*/
841 : const Word16 lsf_wgts_fx[M], /* i : LSF weights Q8*/
842 : Word16 *beta_index /* i/o: quantization index Q0*/
843 : )
844 : {
845 : const Word16 *Beta_Q1bit_re_use_fx;
846 :
847 271 : IF( LE_32( element_brate, IVAS_13k2 ) )
848 : {
849 0 : Beta_Q1bit_re_use_fx = tdm_Beta_Q1bit_re_use_13k2_fx; /*Q15*/
850 : }
851 271 : ELSE IF( LE_32( element_brate, IVAS_16k4 ) )
852 : {
853 23 : Beta_Q1bit_re_use_fx = tdm_Beta_Q1bit_re_use_16k4_fx; /*Q15*/
854 : }
855 248 : ELSE IF( LE_32( element_brate, IVAS_32k ) )
856 : {
857 248 : Beta_Q1bit_re_use_fx = tdm_Beta_Q1bit_re_use_24k4_32k_fx; /*Q15*/
858 : }
859 : ELSE
860 : {
861 0 : Beta_Q1bit_re_use_fx = tdm_Beta_Q1bit_re_use_48k_fx; /*Q15*/
862 : }
863 :
864 271 : IF( enc_dec == ENC )
865 : {
866 130 : tdm_SCh_LSF_intra_pred_one_bit_enc_fx( lsf_new_fx, tdm_lsfQ_PCh_fx, lsf_new_fx, tdm_LSF_MEAN_RE_USE_fx, lsf_wgts_fx, Beta_Q1bit_re_use_fx, beta_index );
867 : }
868 : ELSE /* DEC */
869 : {
870 141 : tdm_SCh_LSF_intra_pred_one_bit_dec_fx( tdm_lsfQ_PCh_fx, lsf_new_fx, tdm_LSF_MEAN_RE_USE_fx, Beta_Q1bit_re_use_fx, *beta_index );
871 : }
872 :
873 271 : tdm_SCh_LSF_intra_pred_tri_diag_mat_fx( lsf_new_fx, tdm_LSF_MEAN_RE_USE_IN_fx, tdm_LSF_MEAN_RE_USE_OUT_fx, tdm_RE_USE_adaptive_beta_prd_diag_3_fx );
874 :
875 271 : lsf2lsp_fx( lsf_new_fx, lsp_new_fx, M, INT_FS_12k8 );
876 :
877 271 : return;
878 : }
|