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 <assert.h>
34 : #include <stdint.h>
35 : #include "options.h"
36 : #include <math.h>
37 : #include "cnst.h"
38 : #include "ivas_cnst.h"
39 : #include "rom_com.h"
40 : #include "prot_fx.h"
41 : #include "ivas_prot_rend_fx.h"
42 : #include "ivas_rom_com.h"
43 : #include "wmc_auto.h"
44 : #include "ivas_prot_fx.h"
45 :
46 :
47 : /*-----------------------------------------------------------------------*
48 : * Local function prototypes
49 : *-----------------------------------------------------------------------*/
50 :
51 : static ivas_error ivas_mc_dec_reconfig_fx( Decoder_Struct *st_ivas, UWord16 *nSamplesRendered, Word16 *data );
52 :
53 :
54 : /*--------------------------------------------------------------------------*
55 : * ivas_mct_dec()
56 : *
57 : * Multi-channel Coding Tool (MCT) decoding routine
58 : *--------------------------------------------------------------------------*/
59 :
60 98420 : ivas_error ivas_mct_dec_fx(
61 : Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
62 : Word32 *output_fx[], /* o : output synthesis signal Q11*/
63 : const Word16 output_frame, /* i : output frame length per channel */
64 : const Word16 nb_bits_metadata /* i : number of metadata bits */
65 : )
66 : {
67 : Word16 nCPE, cpe_id;
68 : MCT_DEC_HANDLE hMCT;
69 : CPE_DEC_HANDLE hCPE;
70 : Word16 param[MCT_MAX_BLOCKS][CPE_CHANNELS][DEC_NPRM_DIV * NB_DIV];
71 : Word16 param_lpc[MCT_MAX_BLOCKS][CPE_CHANNELS][NPRM_LPC_NEW];
72 : Word16 p_param[MCT_MAX_BLOCKS][CPE_CHANNELS][NB_DIV];
73 : Word16 nTnsBitsTCX10[MCT_MAX_BLOCKS][CPE_CHANNELS][NB_DIV];
74 : Word16 fUseTns[MCT_MAX_BLOCKS][CPE_CHANNELS][NB_DIV];
75 : STnsData tnsData[MCT_MAX_BLOCKS][CPE_CHANNELS][NB_DIV];
76 : Word16 Aq_fx[MCT_MAX_BLOCKS][CPE_CHANNELS][( NB_SUBFR16k + 1 ) * ( M + 1 )]; // Q12
77 : Word32 output_lfe_ch_fx[L_FRAME48k];
78 98420 : Word16 q_output = 11;
79 : Word16 n, i;
80 :
81 : Word32 *x_fx[CPE_CHANNELS][NB_DIV]; //(Q(31 - x_e)
82 : Word16 x_len[CPE_CHANNELS][NB_DIV];
83 98420 : set16_fx( x_len[0], 0, NB_DIV );
84 98420 : set16_fx( x_len[1], 0, NB_DIV );
85 : Decoder_State **sts;
86 : Word32 *p_output_orig_fx[2];
87 : Word32 synth_fx_32[CPE_CHANNELS][L_FRAME_PLUS];
88 : Word16 synth_fx[CPE_CHANNELS][L_FRAME_PLUS]; //(Q_synth)
89 : Word32 ivas_total_brate;
90 : ivas_error error;
91 98420 : Word16 e_sig[CPE_CHANNELS] = { 15, 15 };
92 98420 : move16();
93 98420 : move16();
94 :
95 98420 : push_wmops( "ivas_mct_dec" );
96 :
97 98420 : error = IVAS_ERR_OK;
98 98420 : move32();
99 98420 : nCPE = st_ivas->nCPE;
100 98420 : move16();
101 98420 : hMCT = st_ivas->hMCT;
102 :
103 98420 : ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
104 98420 : move32();
105 :
106 98420 : test();
107 98420 : test();
108 98420 : test();
109 98420 : test();
110 98420 : IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && ( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) || EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) )
111 : {
112 : /* save LFE channel */
113 26872 : Copy32( output_fx[LFE_CHANNEL], output_lfe_ch_fx, output_frame ); // Q11
114 : }
115 :
116 98420 : IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) && ( st_ivas->bfi == 0 ) )
117 : {
118 : /* get the number of channels from the signalled MC LS setup */
119 25931 : n = ivas_mc_ls_setup_get_num_channels_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( st_ivas->transport_config ) );
120 :
121 25931 : IF( NE_16( n, st_ivas->nchan_transport ) )
122 : {
123 : /* IVAS_fmToDo: more work needed for switching the number of transport channels */
124 0 : return IVAS_ERROR( IVAS_ERR_INTERNAL_FATAL, "Error: wrong number of transport channels signalled in MC format!" );
125 : }
126 : }
127 :
128 359864 : FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
129 : {
130 : /*initialize param_lpc buffer*/
131 784332 : FOR( n = 0; n < CPE_CHANNELS; n++ )
132 : {
133 522888 : set16_fx( param_lpc[cpe_id][n], 0, NPRM_LPC_NEW );
134 : }
135 :
136 261444 : set32_fx( &output_fx[0][0], 0, L_FRAME48k );
137 261444 : set32_fx( &output_fx[1][0], 0, L_FRAME48k );
138 261444 : IF( NE_32( ( error = ivas_cpe_dec_fx( st_ivas, cpe_id, &output_fx[0], output_frame, 0 ) ), IVAS_ERR_OK ) )
139 : {
140 0 : return error;
141 : }
142 :
143 261444 : if ( cpe_id == 0 )
144 : {
145 98420 : st_ivas->hCPE[0]->hCoreCoder[0]->total_brate = ivas_total_brate; /* set high enough to read the whole side-info; total_brate is rewritten later in ivas_mdct_core_invQ() */
146 98420 : move32();
147 : }
148 :
149 261444 : IF( st_ivas->bfi == 0 )
150 : {
151 257737 : ivas_mdct_dec_side_bits_frame_channel_fx( st_ivas->hCPE[cpe_id], param_lpc[cpe_id], p_param[cpe_id], st_ivas->hCPE[0]->hCoreCoder[0], nTnsBitsTCX10[cpe_id], param[cpe_id], 1,
152 257737 : (Word16) GT_16( i_mult( add( cpe_id, 1 ), CPE_CHANNELS ), hMCT->nchan_out_woLFE ) );
153 :
154 257737 : st_ivas->BER_detect = s_or( st_ivas->BER_detect, st_ivas->hCPE[cpe_id]->hCoreCoder[0]->BER_detect );
155 257737 : test();
156 257737 : st_ivas->BER_detect = s_or( st_ivas->BER_detect, st_ivas->hCPE[cpe_id]->hCoreCoder[1]->BER_detect );
157 257737 : test();
158 : }
159 : }
160 :
161 : /* MCT side bits decoder */
162 98420 : ivas_mct_side_bits_fx( hMCT, st_ivas->hCPE, nCPE, st_ivas->hCPE[0]->hCoreCoder[0], st_ivas->bfi, st_ivas->hCPE[0]->hCoreCoder[0]->bit_stream, ivas_total_brate, nb_bits_metadata );
163 :
164 : /* in case of switching from an SID frame (with ACELP core) to MCT, buffer of L_FRAME_PLUS samples is needed -> use synth[] as a temporary buffer */
165 98420 : IF( st_ivas->hCPE[0]->hCoreCoder[0]->last_core == ACELP_CORE )
166 : {
167 9 : FOR( n = 0; n < CPE_CHANNELS; n++ )
168 : {
169 6 : p_output_orig_fx[n] = output_fx[n];
170 6 : output_fx[n] = synth_fx_32[n];
171 : }
172 : }
173 :
174 359864 : FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
175 : {
176 261444 : st_ivas->hCPE[cpe_id]->hCoreCoder[0]->BER_detect = s_or( st_ivas->hCPE[cpe_id]->hCoreCoder[0]->BER_detect, st_ivas->BER_detect );
177 261444 : move16();
178 261444 : st_ivas->hCPE[cpe_id]->hCoreCoder[1]->BER_detect = s_or( st_ivas->hCPE[cpe_id]->hCoreCoder[1]->BER_detect, st_ivas->BER_detect );
179 261444 : move16();
180 :
181 784332 : FOR( n = 0; n < CPE_CHANNELS; n++ )
182 : {
183 522888 : x_fx[n][0] = output_fx[n + ( cpe_id * CPE_CHANNELS )]; // Q11
184 522888 : move16();
185 522888 : x_fx[n][1] = output_fx[n + ( cpe_id * CPE_CHANNELS )] + ( L_FRAME48k / 2 ); // Q11
186 522888 : move16();
187 :
188 522888 : set32_fx( x_fx[n][0], 0, L_FRAME48k / 2 );
189 522888 : set32_fx( x_fx[n][1], 0, L_FRAME48k / 2 );
190 : }
191 :
192 261444 : ivas_mdct_core_invQ_fx( st_ivas->hCPE[cpe_id], nTnsBitsTCX10[cpe_id], p_param[cpe_id], param_lpc[cpe_id], param[cpe_id],
193 261444 : fUseTns[cpe_id], tnsData[cpe_id], x_fx, 20, x_fx, 20, x_len, Aq_fx[cpe_id], NULL, 1 );
194 :
195 :
196 261444 : st_ivas->BER_detect = s_or( st_ivas->BER_detect, st_ivas->hCPE[cpe_id]->hCoreCoder[0]->BER_detect );
197 261444 : move16();
198 261444 : st_ivas->BER_detect = s_or( st_ivas->BER_detect, st_ivas->hCPE[cpe_id]->hCoreCoder[1]->BER_detect );
199 261444 : move16();
200 : }
201 :
202 :
203 : /* MCT core decoder */
204 : Word16 q_x[MAX_TRANSPORT_CHANNELS];
205 98420 : ivas_mct_core_dec( hMCT, st_ivas->hCPE, nCPE, output_fx, q_x );
206 : // Scaling output buffer back to Q11
207 :
208 :
209 : /* for sba to stereo output disable any further processing for TCs > 2 as it is not needed*/
210 98420 : test();
211 98420 : IF( ( st_ivas->sba_dirac_stereo_flag != 0 ) && NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
212 : {
213 4940 : FOR( cpe_id = 1; cpe_id < nCPE; cpe_id++ )
214 : {
215 7410 : FOR( n = 0; n < CPE_CHANNELS; n++ )
216 : {
217 4940 : st_ivas->hCPE[cpe_id]->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_IGNORE;
218 4940 : move16();
219 : }
220 : }
221 : }
222 :
223 : Word32 Aq_fx_32[6][2][102];
224 : /* MCT reconstruction and CoreCoder updates */
225 359864 : FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
226 : {
227 261444 : hCPE = st_ivas->hCPE[cpe_id];
228 :
229 784332 : FOR( n = 0; n < CPE_CHANNELS; n++ )
230 : {
231 522888 : Copy_Scale_sig_16_32_DEPREC( Aq_fx[cpe_id][n], Aq_fx_32[cpe_id][n], 102, Q16 - Q12 ); // Q16
232 522888 : x_fx[n][0] = output_fx[n + ( cpe_id * CPE_CHANNELS )]; // Q11
233 522888 : x_fx[n][1] = output_fx[n + ( cpe_id * CPE_CHANNELS )] + ( L_FRAME48k / 2 ); // Q11
234 522888 : move16();
235 522888 : move16();
236 : }
237 :
238 261444 : ivas_mdct_core_tns_ns_fx( hCPE, fUseTns[cpe_id], tnsData[cpe_id], x_fx, Aq_fx_32[cpe_id], 1, 20 );
239 : }
240 :
241 :
242 98420 : test();
243 98420 : test();
244 98420 : IF( EQ_16( st_ivas->renderer_type, RENDERER_MC ) )
245 : {
246 : /* Equalization in MDCT Domain */
247 6504 : ivas_ls_setup_conversion_process_mdct_fx( st_ivas, output_fx );
248 : }
249 91916 : ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_MC_PARAMMC ) && ( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) ) )
250 : {
251 : Word16 x_all_e[MAX_CICP_CHANNELS][NB_DIV];
252 340 : FOR( i = 0; i < MAX_CICP_CHANNELS; i++ )
253 : {
254 320 : set16_fx( x_all_e[i], 0, NB_DIV );
255 : }
256 : Word32 *x_all_fx[MAX_CICP_CHANNELS][NB_DIV]; //(Q(31 - x_all_e)
257 60 : FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
258 : {
259 120 : FOR( n = 0; n < CPE_CHANNELS; n++ )
260 : {
261 80 : x_all_fx[n + ( cpe_id * CPE_CHANNELS )][0] = output_fx[n + ( cpe_id * CPE_CHANNELS )]; // Q11
262 80 : x_all_fx[n + ( cpe_id * CPE_CHANNELS )][1] = output_fx[n + ( cpe_id * CPE_CHANNELS )] + ( L_FRAME48k / 2 ); // Q11
263 80 : x_all_e[n + ( cpe_id * CPE_CHANNELS )][1] = 20;
264 80 : move16();
265 80 : x_all_e[n + ( cpe_id * CPE_CHANNELS )][0] = 20;
266 80 : move16();
267 : }
268 : }
269 :
270 20 : ivas_ls_setup_conversion_process_mdct_param_mc_fx( st_ivas, x_all_fx, x_all_e );
271 :
272 60 : FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
273 : {
274 120 : FOR( n = 0; n < CPE_CHANNELS; n++ )
275 : {
276 80 : Scale_sig32( x_all_fx[n + ( cpe_id * CPE_CHANNELS )][0], ( L_FRAME48k / 2 ), sub( x_all_e[n + ( cpe_id * CPE_CHANNELS )][0], 20 ) ); // Q11
277 80 : Scale_sig32( x_all_fx[n + ( cpe_id * CPE_CHANNELS )][1], ( L_FRAME48k / 2 ), sub( x_all_e[n + ( cpe_id * CPE_CHANNELS )][1], 20 ) ); // Q11
278 : }
279 : }
280 : }
281 :
282 359864 : FOR( cpe_id = 0; cpe_id < nCPE; cpe_id++ )
283 : {
284 261444 : hCPE = st_ivas->hCPE[cpe_id];
285 261444 : sts = hCPE->hCoreCoder;
286 :
287 784332 : FOR( n = 0; n < CPE_CHANNELS; n++ )
288 : {
289 522888 : x_fx[n][0] = output_fx[n + ( cpe_id * CPE_CHANNELS )]; // Q11
290 522888 : x_fx[n][1] = output_fx[n + ( cpe_id * CPE_CHANNELS )] + ( L_FRAME48k / 2 ); // Q11
291 : }
292 261444 : Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[0]->old_Aq_12_8_fx, hCPE->hCoreCoder[0]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[0]->old_Aq_12_8_fx[0], 1 ) ) ) ) );
293 261444 : Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[1]->old_Aq_12_8_fx, hCPE->hCoreCoder[1]->old_Aq_12_8_fx_32, add( M, 1 ), sub( 28, sub( 15, norm_s( sub( hCPE->hCoreCoder[1]->old_Aq_12_8_fx[0], 1 ) ) ) ) );
294 261444 : ivas_mdct_core_reconstruct_fx( hCPE, x_fx, synth_fx, fUseTns[cpe_id], 1, q_output, e_sig );
295 : Word16 hdrm;
296 261444 : hdrm = getScaleFactor16( synth_fx[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX );
297 261444 : IF( hdrm != 0 )
298 : {
299 254393 : hdrm = sub( hdrm, 1 );
300 254393 : Scale_sig( synth_fx[0], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX, hdrm );
301 254393 : e_sig[0] = sub( e_sig[0], hdrm );
302 254393 : move16();
303 : }
304 261444 : hdrm = getScaleFactor16( synth_fx[1], hCPE->hCoreCoder[0]->hTcxDec->L_frameTCX );
305 261444 : IF( hdrm != 0 )
306 : {
307 196998 : hdrm = sub( hdrm, 1 );
308 196998 : Scale_sig( synth_fx[1], hCPE->hCoreCoder[1]->hTcxDec->L_frameTCX, hdrm );
309 196998 : e_sig[1] = sub( e_sig[1], hdrm );
310 196998 : move16();
311 : }
312 :
313 784332 : FOR( n = 0; n < CPE_CHANNELS; n++ )
314 : {
315 522888 : IF( hCPE->hCoreCoder[n]->hBPF )
316 : {
317 0 : hCPE->hCoreCoder[n]->hBPF->pst_mem_deemp_err_fx = extract_l( L_shr( hCPE->hCoreCoder[n]->mem_error, sub( Q16, sub( hCPE->hCoreCoder[n]->Q_syn2, 1 ) ) ) );
318 0 : Scale_sig( hCPE->hCoreCoder[n]->hBPF->pst_old_syn_fx, NBPSF_PIT_MAX, sub( hCPE->hCoreCoder[n]->Q_syn2, 1 ) );
319 0 : move16();
320 : }
321 : }
322 :
323 : /* set pointers back */
324 261444 : test();
325 261444 : IF( cpe_id == 0 && st_ivas->hCPE[0]->hCoreCoder[0]->last_core == ACELP_CORE )
326 : {
327 9 : FOR( n = 0; n < CPE_CHANNELS; n++ )
328 : {
329 6 : output_fx[n] = p_output_orig_fx[n];
330 : }
331 : }
332 :
333 :
334 : /*----------------------------------------------------------------*
335 : * CoreCoder Post-processing and updates
336 : *----------------------------------------------------------------*/
337 :
338 784332 : FOR( n = 0; n < CPE_CHANNELS; n++ )
339 : {
340 522888 : test();
341 522888 : test();
342 522888 : IF( ( st_ivas->sba_dirac_stereo_flag != 0 ) && ( NE_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) || GE_16( cpe_id, sub( nCPE, 2 ) ) ) )
343 : {
344 19764 : Copy_Scale_sig_16_32_no_sat( synth_fx[n], synth_fx_32[n], output_frame, sub( Q11, ( sub( 15, e_sig[n] ) ) ) ); // Q11
345 19764 : Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[n]->hHQ_core->old_out_fx, hCPE->hCoreCoder[n]->hHQ_core->old_out_fx32, output_frame, sub( Q11, hCPE->hCoreCoder[n]->hHQ_core->Q_old_wtda ) );
346 19764 : ivas_post_proc_fx( NULL, hCPE, n, synth_fx_32[n], NULL, output_frame, 1, Q11 );
347 19764 : Copy_Scale_sig_32_16( synth_fx_32[n], synth_fx[n], output_frame, sub( sub( 15, e_sig[n] ), Q11 ) ); // Q0
348 : }
349 :
350 : /* Postprocessing for ACELP/MDCT core switching and synchronization */
351 : Word16 output_mem_fx[L_FRAME48k];
352 522888 : IF( hCPE->output_mem_fx[1] != NULL )
353 : {
354 24984 : Copy_Scale_sig_32_16( hCPE->output_mem_fx[1], output_mem_fx, NS2SA_FX2( sts[n]->output_Fs, 3125000 ), -Q11 );
355 : }
356 : ELSE
357 : {
358 497904 : set16_fx( output_mem_fx, 0, NS2SA_FX2( sts[n]->output_Fs, 3125000 ) );
359 : }
360 :
361 522888 : Word16 Q_synth = sub( 15, e_sig[n] );
362 522888 : move16();
363 :
364 : Word16 dirac_stereo_flag;
365 522888 : test();
366 522888 : IF( NE_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) || GE_16( cpe_id, sub( nCPE, 2 ) ) )
367 : {
368 461688 : dirac_stereo_flag = st_ivas->sba_dirac_stereo_flag;
369 : }
370 : ELSE
371 : {
372 61200 : dirac_stereo_flag = 0;
373 : }
374 522888 : IF( NE_32( ( error = core_switching_post_dec_ivas_fx( sts[n], synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], output_mem_fx, 0, output_frame, 0 /*core_switching_flag*/, dirac_stereo_flag, -1, hCPE->last_element_mode, &Q_synth ) ), IVAS_ERR_OK ) )
375 : {
376 0 : return error;
377 : }
378 522888 : Copy_Scale_sig_16_32_no_sat( synth_fx[n], output_fx[( cpe_id * CPE_CHANNELS ) + n], output_frame, sub( Q11, Q_synth ) ); // Q11
379 : /* Save synthesis for HQ FEC */
380 : Word32 output_fx_[L_FRAME48k];
381 522888 : Copy32( output_fx[( cpe_id * CPE_CHANNELS ) + n], output_fx_, L_FRAME48k ); // Q11
382 522888 : Scale_sig32( output_fx_, L_FRAME48k, Q16 - Q11 ); // Q11 -> Q16
383 522888 : Copy_Scale_sig32_16( sts[n]->prev_synth_buffer32_fx, sts[n]->prev_synth_buffer_fx, NS2SA( 48000, DELAY_BWE_TOTAL_NS - DELAY_CLDFB_NS ), -Q11 ); // Q11 -> Q0
384 522888 : sts[n]->q_prev_synth_buffer_fx = 0;
385 522888 : move16();
386 :
387 522888 : save_synthesis_hq_fec_fx( sts[n], NULL, output_fx_, output_frame, 0, hCPE );
388 :
389 : /* CoreCoder common updates */
390 522888 : ivas_updt_dec_common_fx( hCPE->hCoreCoder[n], NORMAL_HQ_CORE, -1, output_fx[( cpe_id * CPE_CHANNELS ) + n], 11 );
391 :
392 : } /* n_channels loop */
393 :
394 784332 : FOR( n = 0; n < 2; n++ )
395 : {
396 522888 : IF( hCPE->hCoreCoder[n] )
397 : {
398 522888 : Copy_Scale_sig_16_32_no_sat( hCPE->hCoreCoder[n]->delay_buf_out_fx, hCPE->hCoreCoder[n]->delay_buf_out32_fx, HQ_DELTA_MAX * HQ_DELAY_COMP, Q11 ); // Q0 -> Q11
399 : }
400 : }
401 :
402 : /* synthesis synchronization between stereo modes */
403 261444 : test();
404 261444 : test();
405 261444 : IF( ( st_ivas->sba_dirac_stereo_flag == 0 ) || ( EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) && LT_16( cpe_id, sub( nCPE, 2 ) ) ) )
406 : {
407 251562 : synchro_synthesis_fx( ivas_total_brate, hCPE, output_fx + imult1616( cpe_id, CPE_CHANNELS ), output_frame, 0, Q11 );
408 : }
409 : }
410 :
411 : /* move channels after LFE to correct output for multi-channel MCT */
412 98420 : test();
413 98420 : test();
414 98420 : IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && ( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) || EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) )
415 : {
416 : Word32 tmp[L_FRAME48k];
417 :
418 : /*save center channel output*/
419 26872 : Copy32( output_fx[hMCT->nchan_out_woLFE - 1], tmp, output_frame ); // Q11
420 :
421 94880 : FOR( n = hMCT->nchan_out_woLFE - 1; n >= LFE_CHANNEL; n-- )
422 : {
423 68008 : Copy32( output_fx[n - 1], output_fx[n + 1], output_frame ); // Q11
424 : }
425 26872 : Copy32( tmp, output_fx[LFE_CHANNEL - 1], output_frame ); // Q11
426 :
427 : /* save LFE channel */
428 26872 : Copy32( output_lfe_ch_fx, output_fx[LFE_CHANNEL], output_frame ); // Q11
429 : }
430 :
431 98420 : pop_wmops();
432 98420 : return error;
433 : }
434 :
435 :
436 : /*-------------------------------------------------------------------------
437 : * create_mct_dec()
438 : *
439 : * Create, allocate and initialize IVAS decoder MCT handle
440 : *-------------------------------------------------------------------------*/
441 915 : ivas_error create_mct_dec_fx(
442 : Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
443 : )
444 : {
445 : MCT_DEC_HANDLE hMCT;
446 : Word16 n;
447 : Word32 cp_bitrate;
448 : Word16 max_blocks;
449 : Word16 cpe_id;
450 :
451 : /*--------------------------------------------------------- --------*
452 : * Allocate MCT handle
453 : *-----------------------------------------------------------------*/
454 :
455 915 : IF( ( hMCT = (MCT_DEC_HANDLE) malloc( sizeof( MCT_DEC_DATA ) ) ) == NULL )
456 : {
457 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for CPE\n" ) );
458 : }
459 :
460 : /*-----------------------------------------------------------------*
461 : * Allocate MCT BlockData handles
462 : *-----------------------------------------------------------------*/
463 :
464 : /* Determine active channels */
465 915 : test();
466 915 : test();
467 915 : test();
468 915 : test();
469 915 : IF( ( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) || EQ_16( st_ivas->ivas_format, SBA_FORMAT ) || EQ_16( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
470 : {
471 569 : hMCT->nchan_out_woLFE = st_ivas->nchan_transport;
472 569 : move16();
473 569 : if ( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
474 : {
475 162 : hMCT->nchan_out_woLFE = add( hMCT->nchan_out_woLFE, st_ivas->nchan_ism );
476 162 : move16();
477 : }
478 : }
479 346 : ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) )
480 : {
481 335 : hMCT->nchan_out_woLFE = sub( st_ivas->nchan_transport, st_ivas->hTransSetup.num_lfe );
482 335 : move16();
483 : }
484 11 : ELSE IF( EQ_16( st_ivas->ivas_format, MC_FORMAT ) && EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
485 : {
486 11 : hMCT->nchan_out_woLFE = sub( st_ivas->nchan_transport, st_ivas->hTransSetup.num_lfe );
487 11 : move16();
488 : }
489 : ELSE
490 : {
491 0 : assert( !"IVAS format currently not supported for MCT" );
492 : }
493 :
494 915 : cp_bitrate = L_shl( Mult_32_16( st_ivas->hDecoderConfig->ivas_total_brate, div_s( 1, hMCT->nchan_out_woLFE ) ), 1 );
495 :
496 915 : IF( EQ_16( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
497 : {
498 162 : cp_bitrate = L_shl( Mult_32_16( st_ivas->hDecoderConfig->ivas_total_brate, div_s( 1, st_ivas->nchan_transport ) ), 1 );
499 : }
500 :
501 : /* indicate LFE for appropriate core-coder channel */
502 3477 : FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
503 : {
504 7686 : FOR( n = 0; n < CPE_CHANNELS; n++ )
505 : {
506 5124 : st_ivas->hCPE[cpe_id]->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_REGULAR;
507 5124 : move32();
508 : }
509 : }
510 :
511 : /* in case we have an uneven number of transport channels, indicate last channel ID as inactive */
512 915 : if ( hMCT->nchan_out_woLFE % 2 )
513 : {
514 670 : st_ivas->hCPE[st_ivas->nCPE - 1]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE;
515 670 : move32();
516 : }
517 :
518 : /*Initialize MCT block data */
519 915 : max_blocks = shr( hMCT->nchan_out_woLFE, 1 );
520 :
521 2807 : FOR( n = 0; n < max_blocks; n++ )
522 : {
523 1892 : IF( ( hMCT->hBlockData[n] = (MCT_DEC_BLOCK_DATA_HANDLE) malloc( sizeof( MCT_DEC_BLOCK_DATA ) ) ) == NULL )
524 : {
525 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MCT block data structure\n" ) );
526 : }
527 :
528 : /*Initialize all parameters to zero*/
529 1892 : hMCT->hBlockData[n]->ch1 = 0;
530 1892 : hMCT->hBlockData[n]->ch2 = 0;
531 1892 : move16();
532 1892 : move16();
533 : /*-----------------------------------------------------------------*
534 : * MDCT stereo initialization
535 : *-----------------------------------------------------------------*/
536 :
537 1892 : IF( ( hMCT->hBlockData[n]->hStereoMdct = (STEREO_MDCT_DEC_DATA_HANDLE) malloc( sizeof( STEREO_MDCT_DEC_DATA ) ) ) == NULL )
538 : {
539 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MDCT Stereo \n" ) );
540 : }
541 :
542 1892 : initMdctStereoDecData_fx( hMCT->hBlockData[n]->hStereoMdct, st_ivas->hCPE[0]->hCoreCoder[0]->igf, st_ivas->hCPE[0]->hCoreCoder[0]->hIGFDec->igfData.igfInfo.grid, cp_bitrate, SWB );
543 1892 : hMCT->hBlockData[n]->hStereoMdct->use_itd = 0;
544 1892 : hMCT->hBlockData[n]->hStereoMdct->reverse_dmx = 0;
545 1892 : move16();
546 1892 : move16();
547 1892 : hMCT->hBlockData[n]->hStereoMdct->smooth_ratio_fx = ONE_IN_Q26; // Q26
548 1892 : move32();
549 : }
550 4513 : FOR( ; n < MCT_MAX_BLOCKS; n++ )
551 : {
552 3598 : hMCT->hBlockData[n] = NULL;
553 : }
554 :
555 : /*-----------------------------------------------------------------*
556 : * Initializations
557 : *-----------------------------------------------------------------*/
558 :
559 915 : hMCT->currBlockDataCnt = 0;
560 915 : move16();
561 :
562 : /*Initialize bits required to signal channel-pair index*/
563 : // hMCT->bitsChannelPairIndex = max( 1, (Word16) ( floorf( ( logf( (float) hMCT->nchan_out_woLFE * ( hMCT->nchan_out_woLFE - 1 ) / 2 - 1 ) * INV_LOG_2 ) ) + 1 ) );
564 915 : hMCT->bitsChannelPairIndex = s_max( 1, add( floor_log_2( sub( shr( imult1616( hMCT->nchan_out_woLFE, sub( hMCT->nchan_out_woLFE, 1 ) ), 1 ), 1 ) ), 1 ) );
565 :
566 915 : set16_fx( hMCT->chBitRatios, 0, MCT_MAX_CHANNELS );
567 915 : set16_fx( hMCT->lowE_ch, 0, MCT_MAX_CHANNELS );
568 :
569 915 : st_ivas->hMCT = hMCT;
570 :
571 915 : return IVAS_ERR_OK;
572 : }
573 :
574 : /*-------------------------------------------------------------------------
575 : * mct_dec_reconfigure()
576 : *
577 : * Reconfigure IVAS decoder MCT handle
578 : *-------------------------------------------------------------------------*/
579 :
580 429 : ivas_error mct_dec_reconfigure_fx(
581 : Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
582 : const UWord16 b_nchan_change /* i : flag indicating different channel count */
583 : )
584 : {
585 : MCT_DEC_HANDLE hMCT;
586 : Decoder_State *st;
587 : Word16 n, cpe_id, max_blocks;
588 : Word32 cp_bitrate, L_tmp;
589 : Word16 tmp_exp, tmp;
590 :
591 429 : hMCT = st_ivas->hMCT;
592 :
593 : /*-----------------------------------------------------------------*
594 : * Allocate and initialize MCT BlockData handles
595 : *-----------------------------------------------------------------*/
596 429 : IF( b_nchan_change )
597 : {
598 : /* Determine active channels */
599 147 : test();
600 147 : test();
601 147 : test();
602 147 : test();
603 147 : IF( ( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_PARAMMC ) ) || EQ_32( st_ivas->ivas_format, SBA_FORMAT ) || EQ_32( st_ivas->ivas_format, SBA_ISM_FORMAT ) )
604 : {
605 139 : hMCT->nchan_out_woLFE = st_ivas->nchan_transport;
606 139 : move16();
607 139 : IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
608 : {
609 45 : hMCT->nchan_out_woLFE = add( hMCT->nchan_out_woLFE, st_ivas->nchan_ism );
610 45 : move16();
611 : }
612 : }
613 8 : ELSE IF( EQ_32( st_ivas->mc_mode, MC_MODE_MCT ) )
614 : {
615 7 : hMCT->nchan_out_woLFE = sub( st_ivas->nchan_transport, st_ivas->hTransSetup.num_lfe );
616 7 : move16();
617 : }
618 1 : ELSE IF( EQ_32( st_ivas->ivas_format, MC_FORMAT ) && EQ_32( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
619 : {
620 1 : hMCT->nchan_out_woLFE = sub( st_ivas->nchan_transport, st_ivas->hTransSetup.num_lfe );
621 1 : move16();
622 : }
623 : ELSE
624 : {
625 0 : assert( !"IVAS format currently not supported for MCT" );
626 : }
627 : }
628 :
629 : /* indicate LFE for appropriate core-coder channel */
630 1613 : FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
631 : {
632 3552 : FOR( n = 0; n < CPE_CHANNELS; n++ )
633 : {
634 2368 : st_ivas->hCPE[cpe_id]->hCoreCoder[n]->mct_chan_mode = MCT_CHAN_MODE_REGULAR;
635 2368 : move32();
636 : }
637 : }
638 :
639 : /* in case we have an uneven number of transport channels, indicate last channel ID as inactive */
640 429 : IF( hMCT->nchan_out_woLFE % 2 )
641 : {
642 339 : st_ivas->hCPE[st_ivas->nCPE - 1]->hCoreCoder[1]->mct_chan_mode = MCT_CHAN_MODE_IGNORE;
643 339 : move32();
644 : }
645 :
646 429 : tmp = BASOP_Util_Divide3216_Scale( st_ivas->hDecoderConfig->ivas_total_brate, hMCT->nchan_out_woLFE, &tmp_exp );
647 429 : cp_bitrate = L_shl( tmp, add( tmp_exp, 2 ) );
648 :
649 429 : IF( EQ_32( st_ivas->ism_mode, ISM_SBA_MODE_DISC ) )
650 : {
651 74 : tmp = BASOP_Util_Divide3216_Scale( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, &tmp_exp );
652 74 : cp_bitrate = L_shl( tmp, add( tmp_exp, 2 ) );
653 : }
654 :
655 : /* set correct nominal bitrates and igf config already here, otherwise we
656 : * run into a number of problems */
657 1613 : FOR( cpe_id = 0; cpe_id < st_ivas->nCPE; cpe_id++ )
658 : {
659 1184 : st_ivas->hCPE[cpe_id]->element_brate = cp_bitrate;
660 1184 : move32();
661 3552 : FOR( n = 0; n < CPE_CHANNELS; n++ )
662 : {
663 2368 : st = st_ivas->hCPE[cpe_id]->hCoreCoder[n];
664 :
665 2368 : st->total_brate = st_ivas->hCPE[cpe_id]->element_brate;
666 2368 : move32();
667 :
668 2368 : IF( NE_32( st->mct_chan_mode, MCT_CHAN_MODE_IGNORE ) )
669 : {
670 : /* st->bits_frame_nominal = (int16_t) ( st_ivas->hCPE[cpe_id]->element_brate / FRAMES_PER_SEC ); */
671 2029 : st->bits_frame_nominal = extract_l( Mpy_32_32( st_ivas->hCPE[cpe_id]->element_brate, ONE_BY_FRAMES_PER_SEC_Q31 ) );
672 2029 : move16();
673 2029 : st->igf = getIgfPresent_fx( st->element_mode, L_mult0( st->bits_frame_nominal, FRAMES_PER_SEC ), st->bwidth, st->rf_flag ); // no floating point so directly pluggable
674 2029 : move16();
675 :
676 2029 : IF( st->igf )
677 : {
678 1182 : IGFDecSetMode_ivas_fx( st->hIGFDec, st_ivas->hCPE[cpe_id]->element_brate, st->bwidth, st->element_mode, -1, -1, st->rf_flag );
679 : }
680 : }
681 : }
682 : }
683 :
684 : /*Initialize MCT block data */
685 : /* max_blocks = hMCT->nchan_out_woLFE / 2; */
686 429 : max_blocks = shr( hMCT->nchan_out_woLFE, 1 );
687 :
688 1274 : FOR( n = 0; n < max_blocks; n++ )
689 : {
690 845 : IF( b_nchan_change )
691 : {
692 311 : IF( hMCT->hBlockData[n] == NULL )
693 : {
694 103 : IF( ( hMCT->hBlockData[n] = (MCT_DEC_BLOCK_DATA_HANDLE) malloc( sizeof( MCT_BLOCK_DATA ) ) ) == NULL )
695 : {
696 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MCT block data structure\n" ) );
697 : }
698 :
699 : /*Initialize all parameters to zero*/
700 103 : hMCT->hBlockData[n]->ch1 = 0;
701 103 : move16();
702 103 : hMCT->hBlockData[n]->ch2 = 0;
703 103 : move16();
704 :
705 : /* MDCT stereo initialization */
706 103 : IF( ( hMCT->hBlockData[n]->hStereoMdct = (STEREO_MDCT_DEC_DATA_HANDLE) malloc( sizeof( STEREO_MDCT_ENC_DATA ) ) ) == NULL )
707 : {
708 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for MDCT Stereo \n" ) );
709 : }
710 : }
711 : }
712 :
713 845 : initMdctStereoDecData_fx( hMCT->hBlockData[n]->hStereoMdct, st_ivas->hCPE[0]->hCoreCoder[0]->igf, st_ivas->hCPE[0]->hCoreCoder[0]->hIGFDec->igfData.igfInfo.grid, cp_bitrate, st_ivas->hCPE[0]->hCoreCoder[0]->bwidth );
714 :
715 845 : hMCT->hBlockData[n]->hStereoMdct->use_itd = 0;
716 845 : move16();
717 : }
718 :
719 2158 : FOR( ; n < MCT_MAX_BLOCKS; n++ )
720 : {
721 : /* deallocate no longer needed blocks */
722 1729 : IF( hMCT->hBlockData[n] != NULL )
723 : {
724 93 : IF( hMCT->hBlockData[n]->hStereoMdct != NULL )
725 : {
726 93 : free( hMCT->hBlockData[n]->hStereoMdct );
727 93 : hMCT->hBlockData[n]->hStereoMdct = NULL;
728 : }
729 :
730 93 : free( hMCT->hBlockData[n] );
731 93 : hMCT->hBlockData[n] = NULL;
732 : }
733 : }
734 :
735 : /*-----------------------------------------------------------------*
736 : * Initializations
737 : *-----------------------------------------------------------------*/
738 :
739 429 : IF( b_nchan_change )
740 : {
741 147 : hMCT->currBlockDataCnt = 0;
742 147 : move16();
743 :
744 : /*Initialize bits required to signal channel-pair index*/
745 :
746 : Word32 log_tmp;
747 147 : L_tmp = L_sub( L_shr( L_mult0( hMCT->nchan_out_woLFE, sub( hMCT->nchan_out_woLFE, 1 ) ), 1 ), 1 );
748 147 : tmp_exp = norm_l( L_tmp );
749 147 : L_tmp = L_shl( L_tmp, tmp_exp );
750 147 : log_tmp = BASOP_Util_Log2( L_tmp ); // ( 31 - tmp_exp )
751 147 : log_tmp = L_add( log_tmp, L_shl( sub( Q31, tmp_exp ), Q25 ) ); // Q25
752 : // scale down from Q25 to Q0
753 :
754 147 : tmp = extract_l( L_shr( log_tmp, Q25 ) );
755 147 : tmp = add( tmp, 1 );
756 147 : hMCT->bitsChannelPairIndex = s_max( 1, tmp );
757 147 : move16();
758 :
759 147 : set16_fx( hMCT->chBitRatios, 0, MCT_MAX_CHANNELS );
760 147 : set16_fx( hMCT->lowE_ch, 0, MCT_MAX_CHANNELS );
761 : }
762 :
763 429 : return IVAS_ERR_OK;
764 : }
765 :
766 :
767 : /*-------------------------------------------------------------------------
768 : * create_mct_dec_close()
769 : *
770 : * Close IVAS decoder MCT handle
771 : *-------------------------------------------------------------------------*/
772 :
773 1355 : void ivas_mct_dec_close(
774 : MCT_DEC_HANDLE *hMCT /* i/o: MCT decoder structure */
775 : )
776 : {
777 : Word16 n, maxBlocks;
778 :
779 1355 : test();
780 1355 : IF( hMCT == NULL || *hMCT == NULL )
781 : {
782 440 : return;
783 : }
784 :
785 915 : maxBlocks = shr( ( *hMCT )->nchan_out_woLFE, 1 );
786 :
787 2817 : FOR( n = 0; n < maxBlocks; n++ )
788 : {
789 1902 : IF( ( *hMCT )->hBlockData[n] != NULL )
790 : {
791 1902 : IF( ( *hMCT )->hBlockData[n]->hStereoMdct != NULL )
792 : {
793 1902 : free( ( *hMCT )->hBlockData[n]->hStereoMdct );
794 1902 : ( *hMCT )->hBlockData[n]->hStereoMdct = NULL;
795 : }
796 :
797 1902 : free( ( *hMCT )->hBlockData[n] );
798 1902 : ( *hMCT )->hBlockData[n] = NULL;
799 : }
800 : }
801 :
802 915 : free( *hMCT );
803 915 : *hMCT = NULL;
804 :
805 915 : return;
806 : }
807 :
808 :
809 : /*-------------------------------------------------------------------------
810 : * ivas_mc_dec_config()
811 : *
812 : * - read transported MC LS setup
813 : * - select MC format mode
814 : * - reconfigure the MC format decoder
815 : *-------------------------------------------------------------------------*/
816 :
817 : /*! r : MC format mode */
818 48468 : ivas_error ivas_mc_dec_config_fx(
819 : Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
820 : const Word16 idx, /* i : LS config. index */
821 : UWord16 *nSamplesRendered, /* o : samples flushed from last frame (JBM) */
822 : Word16 *data /* o : output synthesis signal */
823 : )
824 : {
825 : AUDIO_CONFIG signaled_config;
826 : MC_MODE last_mc_mode;
827 : ivas_error error;
828 :
829 : /* store last frame MC mode */
830 48468 : last_mc_mode = st_ivas->mc_mode;
831 48468 : move16();
832 :
833 48468 : IF( st_ivas->bfi == 0 )
834 : {
835 : /* set transported MC LS setup */
836 48468 : signaled_config = ivas_mc_map_ls_setup_to_output_config_fx( idx );
837 :
838 48468 : if ( st_ivas->ini_frame == 0 )
839 : {
840 81 : st_ivas->transport_config = signaled_config;
841 81 : move32();
842 : }
843 :
844 : /* select MC format mode */
845 48468 : st_ivas->mc_mode = ivas_mc_mode_select_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( signaled_config ), st_ivas->hDecoderConfig->ivas_total_brate );
846 48468 : move32();
847 :
848 : /* MC format switching */
849 48468 : IF( st_ivas->ini_frame != 0 )
850 : {
851 48387 : test();
852 : #ifdef FIX_1052_EXT_OUTPUT
853 48387 : IF( NE_32( st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->hDecoderConfig->ivas_total_brate ) || last_mc_mode != st_ivas->mc_mode )
854 : #else
855 : IF( NE_32( st_ivas->hDecoderConfig->last_ivas_total_brate, st_ivas->hDecoderConfig->ivas_total_brate ) || st_ivas->transport_config != signaled_config || last_mc_mode != st_ivas->mc_mode )
856 : #endif
857 : {
858 1065 : IF( st_ivas->hRenderConfig )
859 : {
860 2770 : FOR( Word16 i = 0; i < 4; i++ )
861 : {
862 2216 : st_ivas->hRenderConfig->directivity_fx[( i * 3 ) + 2] = shl_sat( st_ivas->hRenderConfig->directivity_fx[( i * 3 ) + 2], 9 ); // Q15
863 2216 : move16();
864 : }
865 : }
866 1065 : IF( NE_32( ( error = ivas_mc_dec_reconfig_fx( st_ivas, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
867 : {
868 0 : return error;
869 : }
870 1065 : IF( st_ivas->hRenderConfig )
871 : {
872 2770 : FOR( Word16 i = 0; i < 4; i++ )
873 : {
874 2216 : st_ivas->hRenderConfig->directivity_fx[( i * 3 ) + 2] = shr( st_ivas->hRenderConfig->directivity_fx[( i * 3 ) + 2], 9 ); // Q15
875 2216 : move16();
876 : }
877 : }
878 : }
879 : }
880 :
881 48468 : st_ivas->transport_config = signaled_config;
882 48468 : move32();
883 : }
884 :
885 48468 : return IVAS_ERR_OK;
886 : }
887 :
888 :
889 : /*-------------------------------------------------------------------------
890 : * ivas_mc_dec_reconfig()
891 : *
892 : * reconfigure the MC format decoder
893 : *-------------------------------------------------------------------------*/
894 :
895 1065 : static ivas_error ivas_mc_dec_reconfig_fx(
896 : Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
897 : UWord16 *nSamplesRendered, /* o : number of samples flushed from the last frame (JBM) */
898 : Word16 *data /* o : output synthesis signal */
899 : )
900 : {
901 : Word16 nchan_transport_old, nSCE_old, nCPE_old, sba_dirac_stereo_flag_old, nchan_hp20_old;
902 : Word16 numCldfbAnalyses_old, numCldfbSyntheses_old;
903 : Word32 new_brate_SCE, new_brate_CPE, ivas_total_brate;
904 : RENDERER_TYPE renderer_type_old;
905 : Decoder_State *st;
906 : ivas_error error;
907 : MC_MODE mc_mode, last_mc_mode;
908 : TC_BUFFER_MODE tc_buffer_mode_new;
909 : Word16 tc_nchan_tc_new;
910 : Word16 tc_nchan_allocate_new;
911 : Word16 tc_granularity_new;
912 : AUDIO_CONFIG intern_config_old;
913 : IVAS_OUTPUT_SETUP hIntSetupOld;
914 : Word16 nchan_out_buff_old, nchan_out_buff;
915 :
916 1065 : error = IVAS_ERR_OK;
917 1065 : move32();
918 1065 : ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
919 1065 : move32();
920 1065 : nchan_transport_old = st_ivas->nchan_transport;
921 1065 : move16();
922 1065 : nchan_out_buff_old = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 );
923 1065 : last_mc_mode = ivas_mc_mode_select_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( st_ivas->transport_config ), st_ivas->hDecoderConfig->last_ivas_total_brate ); /* NB: this assumes that LS config remains the same between frames */
924 :
925 : /* temporally set the current mc_mode back to the previous one to make sure the following call to
926 : ivas_init_dec_get_num_cldfb_instances() returns the correct counts */
927 1065 : mc_mode = st_ivas->mc_mode;
928 1065 : move32();
929 1065 : st_ivas->mc_mode = last_mc_mode;
930 1065 : move32();
931 1065 : ivas_init_dec_get_num_cldfb_instances_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
932 :
933 1065 : st_ivas->mc_mode = mc_mode;
934 1065 : move32();
935 :
936 1065 : nSCE_old = st_ivas->nSCE;
937 1065 : move16();
938 1065 : nCPE_old = st_ivas->nCPE;
939 1065 : move16();
940 1065 : sba_dirac_stereo_flag_old = st_ivas->sba_dirac_stereo_flag;
941 1065 : move16();
942 :
943 : /* special handling needed for the hp20 buffers for McMASA */
944 1065 : IF( EQ_16( last_mc_mode, MC_MODE_MCMASA ) )
945 : {
946 274 : nchan_hp20_old = getNumChanSynthesis( st_ivas );
947 : }
948 : ELSE
949 : {
950 791 : nchan_hp20_old = nchan_transport_old;
951 791 : move16();
952 : }
953 1065 : st_ivas->sba_dirac_stereo_flag = ivas_get_sba_dirac_stereo_flag( st_ivas );
954 1065 : move16();
955 :
956 : /* save old IntSetup, might be needed for JBM flushing...*/
957 1065 : intern_config_old = st_ivas->intern_config;
958 1065 : move32();
959 1065 : hIntSetupOld = st_ivas->hIntSetup;
960 1065 : tc_granularity_new = 1;
961 1065 : move16();
962 :
963 : /* renderer might have changed, reselect */
964 1065 : renderer_type_old = st_ivas->renderer_type;
965 1065 : move32();
966 1065 : ivas_renderer_select( st_ivas );
967 :
968 : /* side effect of the renderer selection can be a changed internal config */
969 1065 : ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config );
970 :
971 : /* transfer subframe info from DirAC or ParamMC to central tc buffer */
972 :
973 1065 : if ( st_ivas->hTcBuffer->tc_buffer_mode != TC_BUFFER_MODE_BUFFER )
974 : {
975 1031 : test();
976 1031 : IF( EQ_16( last_mc_mode, MC_MODE_PARAMMC ) )
977 : {
978 331 : st_ivas->hTcBuffer->nb_subframes = st_ivas->hParamMC->nb_subframes;
979 331 : move16();
980 331 : st_ivas->hTcBuffer->subframes_rendered = st_ivas->hParamMC->subframes_rendered;
981 331 : move16();
982 331 : st_ivas->hTcBuffer->num_slots = st_ivas->hParamMC->num_slots;
983 331 : move16();
984 331 : st_ivas->hTcBuffer->slots_rendered = st_ivas->hParamMC->slots_rendered;
985 331 : move16();
986 331 : Copy( st_ivas->hParamMC->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
987 : }
988 700 : ELSE IF( EQ_16( last_mc_mode, MC_MODE_MCMASA ) && st_ivas->hSpatParamRendCom != NULL )
989 : {
990 265 : st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes;
991 265 : move16();
992 265 : st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered;
993 265 : move16();
994 265 : st_ivas->hTcBuffer->num_slots = st_ivas->hSpatParamRendCom->num_slots;
995 265 : move16();
996 265 : st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered;
997 265 : move16();
998 265 : Copy( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
999 : }
1000 : }
1001 :
1002 : /* JBM: when granularity goes down (e.g. MCT with CREND -> ParamMC with binaural fastconv
1003 : render what still fits in the new granularity */
1004 1065 : tc_granularity_new = ivas_jbm_dec_get_render_granularity( st_ivas->renderer_type, st_ivas->ivas_format, st_ivas->mc_mode, st_ivas->hDecoderConfig->output_Fs );
1005 1065 : move16();
1006 1065 : IF( LT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) )
1007 : {
1008 157 : IF( NE_32( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, last_mc_mode, ISM_MODE_NONE, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
1009 : {
1010 0 : return error;
1011 : }
1012 : }
1013 : /* JBM: when granularity goes up set samples to discard at the beginning of the frame */
1014 908 : ELSE IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) )
1015 : {
1016 162 : IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) )
1017 : {
1018 0 : return error;
1019 : }
1020 : }
1021 1065 : IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) )
1022 : {
1023 465 : st_ivas->nchan_transport = ivas_mc_ls_setup_get_num_channels_fx( ivas_mc_map_output_config_to_mc_ls_setup_fx( st_ivas->transport_config ) );
1024 465 : move16();
1025 465 : st_ivas->nSCE = 0;
1026 465 : move16();
1027 465 : st_ivas->nCPE = shr( st_ivas->nchan_transport, 1 );
1028 465 : move16();
1029 :
1030 465 : IF( NE_16( last_mc_mode, MC_MODE_MCT ) )
1031 : {
1032 : /*De-allocate handles for other MC modes*/
1033 306 : IF( st_ivas->hParamMC != NULL )
1034 : {
1035 173 : ivas_param_mc_dec_close_fx( &st_ivas->hParamMC );
1036 :
1037 : /* remove ls conversion if it was allocated by ParamMC */
1038 173 : ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion );
1039 : }
1040 :
1041 306 : IF( EQ_16( last_mc_mode, MC_MODE_PARAMUPMIX ) )
1042 : {
1043 3 : ivas_mc_paramupmix_dec_close( &( st_ivas->hMCParamUpmix ) );
1044 3 : ivas_ls_setup_conversion_close_fx( &( st_ivas->hLsSetUpConversion ) );
1045 : }
1046 :
1047 : /* De-allocate McMasa-related handles */
1048 306 : ivas_masa_dec_close_fx( &( st_ivas->hMasa ) );
1049 :
1050 306 : ivas_qmetadata_close_fx( &st_ivas->hQMetaData );
1051 306 : IF( st_ivas->hDirAC != NULL )
1052 : {
1053 132 : ivas_dirac_rend_close_fx( &( st_ivas->hDirACRend ) );
1054 132 : ivas_spat_hSpatParamRendCom_close_fx( &( st_ivas->hSpatParamRendCom ) );
1055 132 : ivas_dirac_dec_close_fx( &( st_ivas->hDirAC ) );
1056 132 : vbap_free_data_fx( &( st_ivas->hVBAPdata ) );
1057 : }
1058 :
1059 : /* init LS conversion if the renderer type asks for it */
1060 306 : test();
1061 306 : IF( EQ_16( st_ivas->renderer_type, RENDERER_MC ) && st_ivas->hLsSetUpConversion == NULL )
1062 : {
1063 62 : IF( NE_32( ( error = ivas_ls_setup_conversion_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
1064 : {
1065 0 : return error;
1066 : }
1067 : }
1068 : }
1069 : }
1070 600 : ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
1071 : {
1072 7 : st_ivas->nSCE = 0;
1073 7 : move16();
1074 7 : st_ivas->nCPE = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS / 2;
1075 7 : move16();
1076 7 : st_ivas->nchan_transport = MC_PARAMUPMIX_MAX_TRANSPORT_CHANS;
1077 7 : move16();
1078 :
1079 7 : IF( NE_16( last_mc_mode, MC_MODE_PARAMUPMIX ) )
1080 : {
1081 : /*De-allocate handles for other MC modes*/
1082 7 : IF( st_ivas->hParamMC != NULL )
1083 : {
1084 1 : ivas_param_mc_dec_close_fx( &st_ivas->hParamMC );
1085 :
1086 : /* remove ls conversion if it was allocated by ParamMC */
1087 1 : ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion );
1088 : }
1089 :
1090 7 : ivas_masa_dec_close_fx( &( st_ivas->hMasa ) );
1091 7 : ivas_qmetadata_close_fx( &st_ivas->hQMetaData );
1092 :
1093 : /* init LS conversion if the renderer type asks for it */
1094 7 : test();
1095 7 : IF( ( EQ_16( st_ivas->renderer_type, RENDERER_MC ) ) && st_ivas->hLsSetUpConversion == NULL )
1096 : {
1097 1 : IF( ( error = ivas_ls_setup_conversion_open_fx( st_ivas ) ) != IVAS_ERR_OK )
1098 : {
1099 0 : return error;
1100 : }
1101 : }
1102 :
1103 7 : IF( ( error = ivas_mc_paramupmix_dec_open( st_ivas ) ) != IVAS_ERR_OK )
1104 : {
1105 0 : return error;
1106 : }
1107 : }
1108 : }
1109 593 : ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) )
1110 : {
1111 334 : IF( NE_16( last_mc_mode, MC_MODE_PARAMMC ) )
1112 : {
1113 : /* remove old ls conversion for MCT if open, gets reopened correctly within ivas_param_mc_dec_open when needed */
1114 269 : test();
1115 269 : IF( EQ_16( renderer_type_old, RENDERER_MC ) && st_ivas->hLsSetUpConversion != NULL )
1116 : {
1117 37 : ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion );
1118 : }
1119 :
1120 269 : IF( NE_32( ( error = ivas_param_mc_dec_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
1121 : {
1122 0 : return error;
1123 : }
1124 : }
1125 : ELSE
1126 : {
1127 65 : IF( NE_32( ( error = ivas_param_mc_dec_reconfig_fx( st_ivas ) ), IVAS_ERR_OK ) )
1128 : {
1129 0 : return error;
1130 : }
1131 : }
1132 :
1133 : /* De-allocate McMasa-related handles */
1134 334 : ivas_masa_dec_close_fx( &( st_ivas->hMasa ) );
1135 334 : ivas_qmetadata_close_fx( &st_ivas->hQMetaData );
1136 :
1137 334 : IF( st_ivas->hDirAC != NULL )
1138 : {
1139 92 : ivas_dirac_rend_close_fx( &( st_ivas->hDirACRend ) );
1140 92 : ivas_spat_hSpatParamRendCom_close_fx( &( st_ivas->hSpatParamRendCom ) );
1141 92 : ivas_dirac_dec_close_fx( &( st_ivas->hDirAC ) );
1142 92 : vbap_free_data_fx( &( st_ivas->hVBAPdata ) );
1143 : }
1144 :
1145 334 : IF( EQ_16( last_mc_mode, MC_MODE_MCT ) )
1146 : {
1147 175 : test();
1148 175 : IF( st_ivas->hMCT != NULL && LE_16( st_ivas->nchan_transport, CPE_CHANNELS ) )
1149 : {
1150 170 : ivas_mct_dec_close( &st_ivas->hMCT );
1151 : }
1152 : }
1153 159 : ELSE IF( EQ_16( last_mc_mode, MC_MODE_PARAMUPMIX ) )
1154 : {
1155 0 : ivas_mc_paramupmix_dec_close( &( st_ivas->hMCParamUpmix ) );
1156 : }
1157 :
1158 : /* LFE handle */
1159 334 : ivas_lfe_dec_close_fx( &( st_ivas->hLFE ) );
1160 : }
1161 259 : ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) )
1162 : {
1163 259 : ivas_mcmasa_setNumTransportChannels_fx( &( st_ivas->nchan_transport ), &( st_ivas->element_mode_init ), ivas_total_brate );
1164 :
1165 259 : IF( NE_16( last_mc_mode, MC_MODE_MCMASA ) )
1166 : {
1167 215 : IF( NE_32( ( error = ivas_qmetadata_open_fx( &( st_ivas->hQMetaData ) ) ), IVAS_ERR_OK ) )
1168 : {
1169 0 : return error;
1170 : }
1171 : }
1172 :
1173 259 : IF( NE_32( ( error = ivas_mcmasa_dec_reconfig( st_ivas ) ), IVAS_ERR_OK ) )
1174 : {
1175 0 : return error;
1176 : }
1177 :
1178 : /* LS conversion */
1179 259 : IF( st_ivas->hLsSetUpConversion != NULL )
1180 : {
1181 41 : ivas_ls_setup_conversion_close_fx( &st_ivas->hLsSetUpConversion );
1182 : }
1183 :
1184 259 : ivas_mc_paramupmix_dec_close( &( st_ivas->hMCParamUpmix ) );
1185 :
1186 259 : IF( st_ivas->hParamMC != NULL )
1187 : {
1188 94 : ivas_param_mc_dec_close_fx( &st_ivas->hParamMC );
1189 94 : st_ivas->hParamMC = NULL;
1190 : }
1191 :
1192 259 : IF( EQ_16( last_mc_mode, MC_MODE_MCT ) )
1193 : {
1194 121 : ivas_mct_dec_close( &st_ivas->hMCT );
1195 : }
1196 :
1197 : /* LFE handle */
1198 259 : ivas_lfe_dec_close_fx( &( st_ivas->hLFE ) );
1199 : }
1200 :
1201 1065 : IF( NE_16( st_ivas->mc_mode, MC_MODE_MCMASA ) )
1202 : {
1203 806 : IF( EQ_16( st_ivas->nchan_transport, 1 ) )
1204 : {
1205 0 : st_ivas->element_mode_init = IVAS_SCE;
1206 : }
1207 : ELSE
1208 : {
1209 806 : st_ivas->element_mode_init = IVAS_CPE_MDCT;
1210 : }
1211 806 : move16();
1212 : }
1213 :
1214 : /*-----------------------------------------------------------------*
1215 : * Reconfigure core coder
1216 : *-----------------------------------------------------------------*/
1217 :
1218 : /* special case: MCT->ParamMC with more than 2 TC, CPE 1 stays, but has the wrong mct_chan_mode in channel 1
1219 : and might have IGF static memory not allocated and the bit stream index list not set,
1220 : set correct mct_chan_mode and init missing static mem (IGF, HQ) and some config (TNS) do it here since it is _very_ MC specific */
1221 1065 : test();
1222 1065 : test();
1223 1065 : IF( EQ_16( last_mc_mode, MC_MODE_MCT ) && EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) && GT_16( st_ivas->nchan_transport, CPE_CHANNELS ) )
1224 : {
1225 5 : st = st_ivas->hCPE[1]->hCoreCoder[1];
1226 :
1227 5 : IF( EQ_16( st_ivas->nchan_transport, 3 ) )
1228 : {
1229 5 : st->mct_chan_mode = MCT_CHAN_MODE_IGNORE;
1230 : }
1231 : ELSE
1232 : {
1233 0 : st->mct_chan_mode = MCT_CHAN_MODE_REGULAR;
1234 : }
1235 5 : move32();
1236 :
1237 5 : IF( st->hIGFDec == NULL )
1238 : {
1239 0 : IF( ( st->hIGFDec = (IGF_DEC_INSTANCE_HANDLE) malloc( sizeof( IGFDEC_INSTANCE ) ) ) == NULL )
1240 : {
1241 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for IGF\n" ) );
1242 : }
1243 :
1244 0 : st->igf = 0;
1245 0 : move16();
1246 0 : init_igf_dec( st->hIGFDec );
1247 : }
1248 :
1249 5 : IF( st->hHQ_core == NULL )
1250 : {
1251 0 : IF( ( st->hHQ_core = (HQ_DEC_HANDLE) malloc( sizeof( HQ_DEC_DATA ) ) ) == NULL )
1252 : {
1253 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for HQ core\n" ) );
1254 : }
1255 :
1256 : /* HQ core initialization */
1257 0 : HQ_core_dec_init_fx( st->hHQ_core );
1258 : }
1259 :
1260 : /* check if we have a doubly used hTxcCfg, if so, allocate a distint one for the old MCT LFE channel */
1261 5 : IF( st->hTcxCfg == st_ivas->hCPE[1]->hCoreCoder[0]->hTcxCfg )
1262 : {
1263 0 : IF( ( st->hTcxCfg = (TCX_CONFIG_HANDLE) malloc( sizeof( TCX_config ) ) ) == NULL )
1264 : {
1265 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for hTcxCfg\n" ) );
1266 : }
1267 : }
1268 :
1269 5 : st->hTcxCfg->fIsTNSAllowed = getTnsAllowed( ivas_total_brate, st->igf, st->element_mode );
1270 5 : move16();
1271 : }
1272 1065 : IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) )
1273 : {
1274 : UWord8 separateChannelEnabled;
1275 : Word16 separateChannelIndex;
1276 259 : ivas_mcmasa_set_separate_channel_mode_fx( &separateChannelEnabled, &separateChannelIndex, ivas_total_brate );
1277 259 : ivas_mcmasa_split_brate_fx( separateChannelEnabled, ivas_total_brate, st_ivas->nSCE, st_ivas->nCPE, &new_brate_SCE, &new_brate_CPE );
1278 : }
1279 806 : ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) )
1280 : {
1281 465 : new_brate_SCE = 0;
1282 465 : move32();
1283 : Word16 temp_e;
1284 465 : Word32 L_temp = BASOP_Util_Divide3232_Scale_newton( ivas_total_brate, sub( st_ivas->nchan_transport, 1 ), &temp_e );
1285 465 : L_temp = L_shr( L_temp, sub( 31, temp_e ) );
1286 465 : new_brate_CPE = L_shl( L_temp, 1 ) /*CPE_CHANNELS*/;
1287 : }
1288 341 : ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
1289 : {
1290 7 : new_brate_SCE = 0;
1291 7 : move32();
1292 : Word16 temp_e;
1293 7 : Word32 L_temp = BASOP_Util_Divide3232_Scale_newton( ivas_total_brate, sub( st_ivas->nchan_transport, 1 ), &temp_e );
1294 7 : L_temp = L_shr( L_temp, sub( 31, temp_e ) );
1295 7 : new_brate_CPE = L_shl( L_temp, 1 ) /*CPE_CHANNELS*/;
1296 : }
1297 : ELSE
1298 : {
1299 334 : new_brate_SCE = 0; /* ivas_total_brate / st_ivas->nchan_transport;*/
1300 334 : move32();
1301 : Word16 temp_e;
1302 334 : Word32 L_temp = BASOP_Util_Divide3232_Scale_newton( ivas_total_brate, st_ivas->nchan_transport, &temp_e );
1303 334 : L_temp = L_shr( L_temp, sub( 31, temp_e ) );
1304 334 : new_brate_CPE = L_shl( L_temp, 1 ) /*CPE_CHANNELS*/;
1305 : }
1306 :
1307 1065 : test();
1308 1065 : test();
1309 1065 : IF( NE_32( ( error = ivas_corecoder_dec_reconfig_fx( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, sba_dirac_stereo_flag_old, new_brate_SCE, new_brate_CPE ) ), IVAS_ERR_OK ) )
1310 : {
1311 0 : return error;
1312 : }
1313 1065 : IF( EQ_16( last_mc_mode, MC_MODE_MCT ) && EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) && GT_16( st_ivas->nchan_transport, CPE_CHANNELS ) )
1314 : {
1315 5 : st = st_ivas->hCPE[1]->hCoreCoder[1];
1316 :
1317 : /* TCX-LTP */
1318 5 : IF( st->hTcxLtpDec == NULL )
1319 : {
1320 0 : IF( ( st->hTcxLtpDec = (TCX_LTP_DEC_HANDLE) malloc( sizeof( TCX_LTP_DEC_DATA ) ) ) == NULL )
1321 : {
1322 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for TCX-LTP handle\n" ) );
1323 : }
1324 0 : tcxltp_dec_init_fx( st->hTcxLtpDec, 0, st->last_codec_mode, st->element_mode, st->pit_max, st->sr_core );
1325 : }
1326 : }
1327 :
1328 : /*-----------------------------------------------------------------*
1329 : * re-configure HP20 memories
1330 : *-----------------------------------------------------------------*/
1331 1065 : IF( NE_32( ( error = ivas_hp20_dec_reconfig_fx( st_ivas, nchan_hp20_old ) ), IVAS_ERR_OK ) )
1332 : {
1333 0 : return error;
1334 : }
1335 :
1336 : #ifndef NONBE_1360_LFE_DELAY
1337 : /*-----------------------------------------------------------------*
1338 : * Allocate the LFE handle that is coded separately after the allocation of the core coders
1339 : *-----------------------------------------------------------------*/
1340 :
1341 : test();
1342 : test();
1343 : IF( ( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) || EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) && st_ivas->hLFE == NULL )
1344 : {
1345 : #ifdef NONBE_FIX_MC_LFE_LPF
1346 : Word32 delay_ns = st_ivas->binaural_latency_ns;
1347 : #else
1348 : Word32 binauralization_delay_ns = st_ivas->binaural_latency_ns;
1349 : #endif
1350 : move32();
1351 : IF( st_ivas->hBinRenderer != NULL )
1352 : {
1353 : IF( st_ivas->hBinRenderer->render_lfe )
1354 : {
1355 : /* Account for filterbank delay */
1356 : #ifdef NONBE_FIX_MC_LFE_LPF
1357 : delay_ns = L_add( delay_ns, IVAS_FB_DEC_DELAY_NS );
1358 : #else
1359 : binauralization_delay_ns = L_add( binauralization_delay_ns, IVAS_FB_DEC_DELAY_NS );
1360 : #endif
1361 : }
1362 : ELSE
1363 : {
1364 : #ifdef NONBE_FIX_MC_LFE_LPF
1365 : delay_ns = 0;
1366 : #else
1367 : binauralization_delay_ns = 0;
1368 : #endif
1369 : move32();
1370 : }
1371 : }
1372 : #ifdef NONBE_FIX_MC_LFE_LPF
1373 : ELSE
1374 : {
1375 : IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) && ( st_ivas->cldfbSynDec[0] != NULL ) )
1376 : {
1377 : delay_ns = L_add( delay_ns, IVAS_FB_DEC_DELAY_NS );
1378 : }
1379 : }
1380 : #endif
1381 :
1382 : #ifdef NONBE_FIX_MC_LFE_LPF
1383 : IF( NE_32( ( error = ivas_create_lfe_dec_fx( &st_ivas->hLFE, st_ivas->hDecoderConfig->output_Fs, delay_ns ) ), IVAS_ERR_OK ) )
1384 : #else
1385 : IF( NE_32( ( error = ivas_create_lfe_dec_fx( &st_ivas->hLFE, st_ivas->hDecoderConfig->output_Fs, binauralization_delay_ns ) ), IVAS_ERR_OK ) )
1386 : #endif
1387 : {
1388 : return error;
1389 : }
1390 :
1391 : set32_fx( st_ivas->hLFE->prevsynth_buf_fx, 0, LFE_PLC_BUFLEN );
1392 : set32_fx( st_ivas->hLFE->prior_out_buffer_fx, 0, L_FRAME48k );
1393 : }
1394 : #endif
1395 :
1396 : /*-----------------------------------------------------------------*
1397 : * Reconfigure renderers
1398 : *-----------------------------------------------------------------*/
1399 :
1400 1065 : IF( EQ_16( st_ivas->mc_mode, MC_MODE_MCMASA ) )
1401 : {
1402 259 : test();
1403 259 : test();
1404 259 : IF( ( NE_16( st_ivas->renderer_type, RENDERER_DISABLE ) ) && ( NE_16( st_ivas->renderer_type, RENDERER_MCMASA_MONO_STEREO ) ) )
1405 : {
1406 251 : IF( st_ivas->hDirAC != NULL )
1407 : {
1408 : /* reconfigure existing DirAC dec */
1409 251 : IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_RECONFIGURE ) ), IVAS_ERR_OK ) )
1410 : {
1411 0 : return error;
1412 : }
1413 : }
1414 : ELSE
1415 : {
1416 : /* init a new DirAC dec */
1417 0 : IF( NE_32( ( error = ivas_dirac_dec_config_fx( st_ivas, DIRAC_OPEN ) ), IVAS_ERR_OK ) )
1418 : {
1419 0 : return error;
1420 : }
1421 : }
1422 : }
1423 8 : ELSE IF( EQ_16( st_ivas->renderer_type, RENDERER_DISABLE ) && st_ivas->hDirAC != NULL )
1424 : {
1425 0 : ivas_dirac_rend_close_fx( &( st_ivas->hDirACRend ) );
1426 0 : ivas_spat_hSpatParamRendCom_close_fx( &( st_ivas->hSpatParamRendCom ) );
1427 0 : ivas_dirac_dec_close_fx( &( st_ivas->hDirAC ) );
1428 0 : vbap_free_data_fx( &( st_ivas->hVBAPdata ) );
1429 : }
1430 : }
1431 :
1432 1065 : IF( NE_16( renderer_type_old, st_ivas->renderer_type ) )
1433 : {
1434 : AUDIO_CONFIG output_config;
1435 :
1436 628 : output_config = st_ivas->hDecoderConfig->output_config;
1437 628 : move32();
1438 :
1439 : /* binaural renderers*/
1440 628 : test();
1441 628 : test();
1442 628 : test();
1443 628 : test();
1444 628 : test();
1445 628 : test();
1446 628 : test();
1447 628 : test();
1448 628 : IF( EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_16( output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
1449 : {
1450 : /* remove unneeded binaural renderers */
1451 419 : test();
1452 419 : test();
1453 419 : IF( st_ivas->hBinRenderer != NULL && ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) && NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) )
1454 : {
1455 143 : ivas_binRenderer_close_fx( &st_ivas->hBinRenderer );
1456 : #ifdef FIX_1068_ASAN_IN_MC_2_BINAURAL_ROOM_IR
1457 143 : test();
1458 143 : IF( ( st_ivas->hDecoderConfig->Opt_Headrotation || st_ivas->hDecoderConfig->Opt_ExternalOrientation ) )
1459 : {
1460 7 : efap_free_data_fx( &st_ivas->hEFAPdata );
1461 : }
1462 : #endif
1463 : }
1464 :
1465 419 : test();
1466 419 : test();
1467 419 : test();
1468 419 : test();
1469 419 : test();
1470 419 : IF( ( st_ivas->hCrendWrapper != NULL ) && ( st_ivas->hCrendWrapper->hCrend[0] != NULL ) && ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV ) && NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) && ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) || NE_16( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) ) ) )
1471 : {
1472 151 : ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses );
1473 : }
1474 :
1475 419 : test();
1476 419 : IF( st_ivas->hBinRendererTd != NULL && ( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) ) )
1477 : {
1478 6 : ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd );
1479 : }
1480 :
1481 419 : IF( st_ivas->hDiracDecBin[0] != NULL )
1482 : {
1483 231 : test();
1484 231 : test();
1485 231 : IF( NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && NE_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) && NE_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
1486 : {
1487 119 : ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin );
1488 : }
1489 : }
1490 :
1491 : /* init necessary new renderers */
1492 419 : test();
1493 419 : test();
1494 419 : test();
1495 419 : test();
1496 419 : test();
1497 419 : IF( st_ivas->hBinRenderer == NULL && ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_FASTCONV_ROOM ) ) )
1498 : {
1499 145 : IF( ( error = ivas_binRenderer_open_fx( st_ivas ) ) != IVAS_ERR_OK )
1500 : {
1501 0 : return error;
1502 : }
1503 : }
1504 274 : ELSE IF( st_ivas->hBinRendererTd == NULL && EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_OBJECTS_TD ) )
1505 8 : {
1506 : Word16 num_src;
1507 : Word16 SrcInd[MAX_NUM_TDREND_CHANNELS];
1508 :
1509 8 : IF( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, &num_src ) ) != IVAS_ERR_OK )
1510 : {
1511 0 : return error;
1512 : }
1513 8 : IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
1514 : {
1515 4 : IF( NE_32( ( error = ivas_reverb_open_fx( &st_ivas->hReverb, st_ivas->hHrtfStatistics, st_ivas->hRenderConfig, st_ivas->hDecoderConfig->output_Fs ) ), IVAS_ERR_OK ) )
1516 : {
1517 0 : return error;
1518 : }
1519 : }
1520 8 : IF( EQ_16( st_ivas->hIntSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
1521 : {
1522 0 : IF( ( error = ivas_rend_initCrendWrapper( &st_ivas->hCrendWrapper, 1 ) ) != IVAS_ERR_OK )
1523 : {
1524 0 : return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend Wrapper\n" );
1525 : }
1526 :
1527 0 : st_ivas->hCrendWrapper->hCrend[0] = NULL;
1528 0 : st_ivas->hCrendWrapper->hHrtfCrend = NULL;
1529 0 : IF( ( st_ivas->hCrendWrapper->hCrend[0] = (CREND_HANDLE) malloc( sizeof( CREND_DATA ) ) ) == NULL )
1530 : {
1531 0 : return IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for Crend\n" );
1532 : }
1533 : }
1534 : }
1535 266 : ELSE IF( st_ivas->hCrendWrapper == NULL && ( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_MIXER_CONV_ROOM ) ) )
1536 : {
1537 154 : IF( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hDecoderConfig->output_config, st_ivas->hRenderConfig, st_ivas->hSetOfHRTF, st_ivas->hHrtfStatistics, st_ivas->hDecoderConfig->output_Fs, ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses ) ) != IVAS_ERR_OK )
1538 : {
1539 0 : return error;
1540 : }
1541 154 : st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns;
1542 154 : move32();
1543 : }
1544 : }
1545 : }
1546 : /*-----------------------------------------------------------------*
1547 : * CLDFB instances
1548 : *-----------------------------------------------------------------*/
1549 :
1550 1065 : IF( NE_32( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ) ), IVAS_ERR_OK ) )
1551 : {
1552 0 : return error;
1553 : }
1554 :
1555 : #ifdef NONBE_1360_LFE_DELAY
1556 : /*-----------------------------------------------------------------*
1557 : * Allocate the LFE handle that is coded separately after the allocation of the core coders
1558 : *-----------------------------------------------------------------*/
1559 : #ifdef NONBE_1360_LFE_DELAY
1560 1065 : test();
1561 1065 : IF( ( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) || EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) )
1562 : #else
1563 : test();
1564 : test();
1565 : IF( ( EQ_16( st_ivas->mc_mode, MC_MODE_MCT ) || EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) ) && st_ivas->hLFE == NULL )
1566 : #endif
1567 : {
1568 : #ifdef NONBE_FIX_MC_LFE_LPF
1569 : #ifdef NONBE_1360_LFE_DELAY
1570 : Word32 delay_ns;
1571 472 : IF( NE_16( st_ivas->hIntSetup.index_lfe[0], -1 ) )
1572 : {
1573 472 : delay_ns = st_ivas->binaural_latency_ns;
1574 : }
1575 : ELSE
1576 : {
1577 0 : delay_ns = 0;
1578 : }
1579 : #else
1580 : Word32 delay_ns = st_ivas->binaural_latency_ns;
1581 : #endif
1582 : #else
1583 : Word32 binauralization_delay_ns = st_ivas->binaural_latency_ns;
1584 : #endif
1585 472 : move32();
1586 472 : IF( st_ivas->hBinRenderer != NULL )
1587 : {
1588 2 : IF( st_ivas->hBinRenderer->render_lfe )
1589 : {
1590 : /* Account for filterbank delay */
1591 : #ifdef NONBE_FIX_MC_LFE_LPF
1592 2 : delay_ns = L_add( delay_ns, IVAS_FB_DEC_DELAY_NS );
1593 : #else
1594 : binauralization_delay_ns = L_add( binauralization_delay_ns, IVAS_FB_DEC_DELAY_NS );
1595 : #endif
1596 : }
1597 : ELSE
1598 : {
1599 : #ifdef NONBE_FIX_MC_LFE_LPF
1600 0 : delay_ns = 0;
1601 : #else
1602 : binauralization_delay_ns = 0;
1603 : #endif
1604 0 : move32();
1605 : }
1606 : }
1607 : #ifdef NONBE_FIX_MC_LFE_LPF
1608 : ELSE
1609 : {
1610 470 : IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) && ( st_ivas->cldfbSynDec[0] != NULL ) )
1611 : {
1612 4 : delay_ns = L_add( delay_ns, IVAS_FB_DEC_DELAY_NS );
1613 : }
1614 : }
1615 : #endif
1616 :
1617 : #ifdef NONBE_1360_LFE_DELAY
1618 472 : IF( st_ivas->hLFE != NULL )
1619 : {
1620 162 : IF( NE_32( st_ivas->hLFE->delay_ns, delay_ns ) )
1621 : {
1622 3 : ivas_lfe_dec_close_fx( &( st_ivas->hLFE ) );
1623 : }
1624 : }
1625 : #endif
1626 :
1627 : #ifdef NONBE_1360_LFE_DELAY
1628 472 : IF( st_ivas->hLFE == NULL )
1629 : {
1630 : #endif
1631 : #ifdef NONBE_FIX_MC_LFE_LPF
1632 313 : IF( NE_32( ( error = ivas_create_lfe_dec_fx( &st_ivas->hLFE, st_ivas->hDecoderConfig->output_Fs, delay_ns ) ), IVAS_ERR_OK ) )
1633 : #else
1634 : IF( NE_32( ( error = ivas_create_lfe_dec_fx( &st_ivas->hLFE, st_ivas->hDecoderConfig->output_Fs, binauralization_delay_ns ) ), IVAS_ERR_OK ) )
1635 : #endif
1636 : {
1637 0 : return error;
1638 : }
1639 :
1640 313 : set32_fx( st_ivas->hLFE->prevsynth_buf_fx, 0, LFE_PLC_BUFLEN );
1641 313 : set32_fx( st_ivas->hLFE->prior_out_buffer_fx, 0, L_FRAME48k );
1642 : #ifdef NONBE_1360_LFE_DELAY
1643 : }
1644 : #endif
1645 : }
1646 : #endif
1647 :
1648 : /*-----------------------------------------------------------------*
1649 : * JBM TC buffers
1650 : *-----------------------------------------------------------------*/
1651 :
1652 : {
1653 : Word16 tc_nchan_full_new;
1654 : DECODER_TC_BUFFER_HANDLE hTcBuffer;
1655 :
1656 1065 : hTcBuffer = st_ivas->hTcBuffer;
1657 1065 : tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas );
1658 1065 : tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
1659 1065 : tc_nchan_allocate_new = tc_nchan_tc_new;
1660 1065 : move16();
1661 1065 : tc_nchan_full_new = tc_nchan_tc_new;
1662 1065 : move16();
1663 :
1664 1065 : test();
1665 1065 : test();
1666 1065 : IF( EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) || EQ_16( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) || EQ_16( st_ivas->renderer_type, RENDERER_STEREO_PARAMETRIC ) )
1667 : {
1668 127 : tc_nchan_allocate_new = BINAURAL_CHANNELS * 2;
1669 127 : move16();
1670 127 : tc_nchan_full_new = tc_nchan_allocate_new;
1671 127 : move16();
1672 : }
1673 :
1674 1065 : test();
1675 1065 : test();
1676 1065 : IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMMC ) && NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) && NE_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) )
1677 : {
1678 332 : tc_nchan_full_new = 0;
1679 332 : move16();
1680 : }
1681 733 : ELSE IF( EQ_16( st_ivas->mc_mode, MC_MODE_PARAMUPMIX ) )
1682 : {
1683 7 : tc_nchan_allocate_new = MC_PARAMUPMIX_MAX_INPUT_CHANS;
1684 7 : move16();
1685 7 : tc_buffer_mode_new = TC_BUFFER_MODE_RENDERER;
1686 7 : move32();
1687 7 : test();
1688 7 : IF( EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_STEREO ) || EQ_16( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_MONO ) )
1689 : {
1690 1 : tc_buffer_mode_new = TC_BUFFER_MODE_BUFFER;
1691 1 : move32();
1692 1 : tc_nchan_tc_new = st_ivas->hDecoderConfig->nchan_out;
1693 1 : move16();
1694 1 : tc_nchan_allocate_new = tc_nchan_tc_new;
1695 1 : move16();
1696 : }
1697 7 : tc_nchan_full_new = tc_nchan_allocate_new;
1698 7 : move16();
1699 : }
1700 :
1701 : /* reconfigure buffer */
1702 1065 : test();
1703 1065 : test();
1704 1065 : test();
1705 1065 : test();
1706 1065 : IF( NE_16( hTcBuffer->tc_buffer_mode, tc_buffer_mode_new ) || NE_16( hTcBuffer->nchan_transport_jbm, tc_nchan_tc_new ) ||
1707 : NE_16( hTcBuffer->nchan_buffer_full, tc_nchan_full_new ) || NE_16( hTcBuffer->nchan_transport_internal, tc_nchan_allocate_new ) ||
1708 : NE_16( tc_granularity_new, hTcBuffer->n_samples_granularity ) )
1709 : {
1710 822 : IF( NE_32( ( error = ivas_jbm_dec_tc_buffer_reconfigure_fx( st_ivas, tc_buffer_mode_new, tc_nchan_tc_new, tc_nchan_allocate_new, tc_nchan_full_new, tc_granularity_new ) ), IVAS_ERR_OK ) )
1711 : {
1712 0 : return error;
1713 : }
1714 : }
1715 : /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */
1716 1065 : IF( st_ivas->hSpatParamRendCom != NULL )
1717 : {
1718 257 : st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes;
1719 257 : move16();
1720 257 : st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered;
1721 257 : move16();
1722 257 : st_ivas->hSpatParamRendCom->num_slots = st_ivas->hTcBuffer->num_slots;
1723 257 : move16();
1724 257 : st_ivas->hSpatParamRendCom->slots_rendered = st_ivas->hTcBuffer->slots_rendered;
1725 257 : move16();
1726 257 : Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
1727 : }
1728 808 : ELSE IF( st_ivas->hParamMC != NULL )
1729 : {
1730 334 : st_ivas->hParamMC->nb_subframes = st_ivas->hTcBuffer->nb_subframes;
1731 334 : move16();
1732 334 : st_ivas->hParamMC->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered;
1733 334 : move16();
1734 334 : st_ivas->hParamMC->num_slots = st_ivas->hTcBuffer->num_slots;
1735 334 : move16();
1736 334 : st_ivas->hParamMC->slots_rendered = st_ivas->hTcBuffer->slots_rendered;
1737 334 : move16();
1738 334 : Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hParamMC->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
1739 : }
1740 : }
1741 :
1742 :
1743 : /*-----------------------------------------------------------------*
1744 : * floating-point output audio buffers
1745 : *-----------------------------------------------------------------*/
1746 :
1747 1065 : nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 );
1748 :
1749 1065 : IF( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) )
1750 : {
1751 0 : return error;
1752 : }
1753 1065 : return error;
1754 : }
|