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