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 "prot_fx.h"
36 : #include "ivas_prot_fx.h"
37 : #include "ivas_prot_rend_fx.h"
38 : #include "wmc_auto.h"
39 : #include "ivas_prot_fx.h"
40 :
41 :
42 : /*-------------------------------------------------------------------------*
43 : * ivas_ism_bitrate_switching_dec()
44 : *
45 : *
46 : *-------------------------------------------------------------------------*/
47 :
48 1013 : static ivas_error ivas_ism_bitrate_switching_dec_fx(
49 : Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
50 : const Word16 nchan_transport_old, /* i : last number of transport channels */
51 : const ISM_MODE last_ism_mode, /* i : last ISM mode */
52 : UWord16 *nSamplesRendered, /* o : number of samples rendered */
53 : Word16 *data /* o : output synthesis signal Q0*/
54 : )
55 : {
56 : ivas_error error;
57 : Word32 element_brate_tmp[MAX_NUM_OBJECTS];
58 : Word16 nSCE_old, nCPE_old;
59 : Word16 numCldfbAnalyses_old, numCldfbSyntheses_old, ism_mode;
60 : TC_BUFFER_MODE tc_buffer_mode_new;
61 : Word16 tc_nchan_tc_new;
62 : Word16 tc_nchan_allocate_new;
63 : Word16 tc_granularity_new;
64 : Word16 nchan_out_buff, nchan_out_buff_old;
65 : AUDIO_CONFIG intern_config_old;
66 : IVAS_OUTPUT_SETUP hIntSetupOld;
67 : RENDERER_TYPE renderer_type_old;
68 :
69 1013 : error = IVAS_ERR_OK;
70 1013 : move32();
71 1013 : nCPE_old = st_ivas->nCPE;
72 1013 : move16();
73 1013 : nSCE_old = st_ivas->nSCE;
74 1013 : move16();
75 :
76 : /* temporarily set the ism mode back to the old one, otherwise this can give wrong results*/
77 1013 : ism_mode = st_ivas->ism_mode;
78 1013 : move16();
79 1013 : st_ivas->ism_mode = last_ism_mode;
80 1013 : move16();
81 1013 : ivas_init_dec_get_num_cldfb_instances_fx( st_ivas, &numCldfbAnalyses_old, &numCldfbSyntheses_old );
82 1013 : st_ivas->ism_mode = ism_mode;
83 1013 : move16();
84 1013 : nchan_out_buff_old = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 );
85 :
86 1013 : IF( NE_32( ( error = ivas_ism_config_fx( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, st_ivas->nchan_ism, NULL, 0, NULL, NULL, element_brate_tmp, NULL, NULL, 0 ) ), IVAS_ERR_OK ) )
87 : {
88 0 : return error;
89 : }
90 :
91 1013 : st_ivas->nSCE = st_ivas->nchan_transport;
92 1013 : move16();
93 :
94 : /*-----------------------------------------------------------------*
95 : * Allocate, initialize, and configure SCE/CPE/MCT handles
96 : *-----------------------------------------------------------------*/
97 :
98 : /* st_ivas->hDecoderConfig->ivas_total_brate / st_ivas->nchan_transport */
99 : Word16 tmp, tmp_e;
100 : Word32 tmp_32;
101 1013 : tmp = BASOP_Util_Divide3216_Scale( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->nchan_transport, &tmp_e );
102 1013 : tmp = shr( tmp, sub( 15, tmp_e ) );
103 1013 : tmp_32 = L_deposit_l( tmp );
104 1013 : IF( NE_32( ( error = ivas_corecoder_dec_reconfig_fx( st_ivas, nSCE_old, nCPE_old, nchan_transport_old, 0, tmp_32, L_shl( tmp_32, 1 ) ) ), IVAS_ERR_OK ) )
105 : {
106 0 : return error;
107 : }
108 :
109 : /*-----------------------------------------------------------------*
110 : * HP20 memories
111 : *-----------------------------------------------------------------*/
112 1013 : IF( NE_32( ( error = ivas_hp20_dec_reconfig_fx( st_ivas, nchan_transport_old ) ), IVAS_ERR_OK ) )
113 : {
114 0 : return error;
115 : }
116 :
117 : /* save old IntSetup, might be needed for JBM flushing...*/
118 1013 : intern_config_old = st_ivas->intern_config;
119 1013 : move32();
120 1013 : hIntSetupOld = st_ivas->hIntSetup;
121 1013 : move32();
122 1013 : tc_granularity_new = 1;
123 1013 : move16();
124 1013 : renderer_type_old = st_ivas->renderer_type;
125 1013 : move32();
126 :
127 : /*-----------------------------------------------------------------*
128 : * Initialize the needed renderer struct and destroy the unnecessary renderer struct
129 : *-----------------------------------------------------------------*/
130 :
131 : /* select the renderer */
132 1013 : ivas_renderer_select( st_ivas );
133 :
134 1013 : ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->intern_config );
135 :
136 1013 : test();
137 1013 : IF( ( EQ_32( st_ivas->renderer_type, RENDERER_SBA_LINEAR_ENC ) ) && ( EQ_32( st_ivas->ism_mode, ISM_MODE_DISC ) ) )
138 : {
139 78 : ivas_output_init( &( st_ivas->hIntSetup ), st_ivas->hDecoderConfig->output_config );
140 : }
141 :
142 : {
143 1013 : test();
144 1013 : test();
145 : /* transfer subframe info from DirAC or ParamMC to central tc buffer */
146 : /* only do this if we are not having done everything already in the TC decoding part and having only played out from the TC buffer */
147 1013 : IF( EQ_32( last_ism_mode, ISM_MODE_PARAM ) && st_ivas->hSpatParamRendCom != NULL && NE_32( st_ivas->hTcBuffer->tc_buffer_mode, TC_BUFFER_MODE_BUFFER ) )
148 : {
149 254 : st_ivas->hTcBuffer->nb_subframes = st_ivas->hSpatParamRendCom->nb_subframes;
150 254 : move16();
151 254 : st_ivas->hTcBuffer->subframes_rendered = st_ivas->hSpatParamRendCom->subframes_rendered;
152 254 : move16();
153 254 : st_ivas->hTcBuffer->num_slots = st_ivas->hSpatParamRendCom->num_slots;
154 254 : move16();
155 254 : st_ivas->hTcBuffer->slots_rendered = st_ivas->hSpatParamRendCom->slots_rendered;
156 254 : move16();
157 254 : Copy( st_ivas->hSpatParamRendCom->subframe_nbslots, st_ivas->hTcBuffer->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
158 : }
159 :
160 : /* JBM: when granularity goes down (e.g. Discrete ISM with TD Obj Renderer -> ParamISM with binaural fastconv
161 : render what still fits in the new granularity */
162 1013 : 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 );
163 :
164 1013 : IF( LT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) )
165 : {
166 92 : IF( NE_32( ( error = ivas_jbm_dec_flush_renderer_fx( st_ivas, tc_granularity_new, renderer_type_old, intern_config_old, &hIntSetupOld, MC_MODE_NONE, last_ism_mode, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
167 : {
168 0 : return error;
169 : }
170 : }
171 : /* JBM: when granularity goes up set samples to discard at the beginning of the frame */
172 921 : ELSE IF( GT_16( tc_granularity_new, st_ivas->hTcBuffer->n_samples_granularity ) )
173 : {
174 92 : IF( NE_32( ( error = ivas_jbm_dec_set_discard_samples( st_ivas ) ), IVAS_ERR_OK ) )
175 : {
176 0 : return error;
177 : }
178 : }
179 : }
180 :
181 1013 : IF( NE_16( st_ivas->ism_mode, last_ism_mode ) )
182 : {
183 : /* EFAP handle */
184 311 : efap_free_data_fx( &st_ivas->hEFAPdata );
185 : }
186 :
187 : /*-----------------------------------------------------------------*
188 : * Switching between ParamISM and DiscISM
189 : *-----------------------------------------------------------------*/
190 :
191 : /* switching from ParamISM to DiscISM */
192 1013 : test();
193 1013 : IF( EQ_32( st_ivas->ism_mode, ISM_MODE_DISC ) && EQ_32( last_ism_mode, ISM_MODE_PARAM ) )
194 : {
195 : /* Deallocate the ParamISM struct */
196 157 : ivas_param_ism_dec_close_fx( &( st_ivas->hParamIsmDec ), &( st_ivas->hSpatParamRendCom ), st_ivas->hDecoderConfig->output_config );
197 :
198 157 : test();
199 157 : IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
200 : {
201 : /* close the parametric binaural renderer */
202 0 : ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin );
203 : /* Open the TD Binaural renderer */
204 0 : test();
205 0 : IF( st_ivas->hHrtfTD == NULL || st_ivas->hBinRendererTd == NULL )
206 : {
207 : Word16 SrcInd[MAX_NUM_TDREND_CHANNELS];
208 : Word16 num_src;
209 0 : IF( NE_32( ( error = ivas_td_binaural_open_fx( st_ivas, SrcInd, &num_src ) ), IVAS_ERR_OK ) )
210 : {
211 0 : return error;
212 : }
213 0 : IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
214 : {
215 0 : 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 ) )
216 : {
217 0 : return error;
218 : }
219 : }
220 : }
221 : }
222 : ELSE
223 : {
224 : /* close the ISM renderer and reinitialize */
225 157 : ivas_ism_renderer_close( &st_ivas->hIsmRendererData );
226 157 : IF( NE_32( ( error = ivas_ism_renderer_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
227 : {
228 0 : return error;
229 : }
230 : }
231 :
232 157 : IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) )
233 : {
234 : /* close the parametric binaural renderer */
235 92 : ivas_dirac_dec_close_binaural_data( st_ivas->hDiracDecBin );
236 :
237 : /* Open Crend Binaural renderer */
238 92 : IF( NE_32( ( error = ivas_rend_openCrend( &( st_ivas->hCrendWrapper ), st_ivas->intern_config, st_ivas->hOutSetup.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 ) )
239 :
240 0 : st_ivas->binaural_latency_ns = st_ivas->hCrendWrapper->binaural_latency_ns;
241 92 : move32();
242 : }
243 : }
244 :
245 : /* switching from Discrete ISM to ParamISM */
246 1013 : test();
247 1013 : IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && EQ_32( last_ism_mode, ISM_MODE_DISC ) )
248 : {
249 : /* Allocate and initialize the ParamISM struct */
250 154 : IF( NE_32( ( error = ivas_param_ism_dec_open_fx( st_ivas ) ), IVAS_ERR_OK ) )
251 : {
252 0 : return error;
253 : }
254 :
255 154 : test();
256 154 : IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED ) || EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
257 : {
258 : /* open the parametric binaural renderer */
259 0 : IF( NE_32( ( error = ivas_dirac_dec_binaural_copy_hrtfs_fx( &st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
260 : {
261 0 : return error;
262 : }
263 :
264 : #ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF
265 0 : IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, &( st_ivas->hHrtfParambin ) ) ), IVAS_ERR_OK ) )
266 : #else
267 : IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
268 : #endif
269 : {
270 0 : return error;
271 : }
272 :
273 : /* Close the TD Binaural renderer */
274 0 : ivas_td_binaural_close_fx( &st_ivas->hBinRendererTd );
275 :
276 0 : IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB ) )
277 : {
278 0 : ivas_reverb_close( &st_ivas->hReverb );
279 : }
280 : }
281 : ELSE
282 : {
283 : /* Close the ISM renderer */
284 154 : ivas_ism_renderer_close( &st_ivas->hIsmRendererData );
285 : }
286 :
287 154 : IF( EQ_32( st_ivas->hOutSetup.output_config, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR ) )
288 : {
289 : /* open the parametric binaural renderer */
290 92 : IF( NE_32( ( error = ivas_dirac_dec_binaural_copy_hrtfs_fx( &st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
291 : {
292 0 : return error;
293 : }
294 :
295 : #ifdef NONBE_FIX_991_PARAMBIN_BINARY_HRTF
296 92 : IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, &( st_ivas->hHrtfParambin ) ) ), IVAS_ERR_OK ) )
297 : #else
298 : IF( NE_32( ( error = ivas_dirac_dec_init_binaural_data_fx( st_ivas, st_ivas->hHrtfParambin ) ), IVAS_ERR_OK ) )
299 : #endif
300 : {
301 0 : return error;
302 : }
303 :
304 : /* close the crend binaural renderer */
305 92 : ivas_rend_closeCrend( &( st_ivas->hCrendWrapper ), ( st_ivas->hSplitBinRend == NULL ) ? 1 : st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses );
306 : }
307 : }
308 :
309 : /*-----------------------------------------------------------------*
310 : * CLDFB instances
311 : *-----------------------------------------------------------------*/
312 :
313 1013 : IF( NE_32( ( error = ivas_cldfb_dec_reconfig_fx( st_ivas, nchan_transport_old, numCldfbAnalyses_old, numCldfbSyntheses_old ) ), IVAS_ERR_OK ) )
314 : {
315 0 : return error;
316 : }
317 :
318 : /*-----------------------------------------------------------------*
319 : * floating-point output audio buffers
320 : *-----------------------------------------------------------------*/
321 :
322 : {
323 1013 : nchan_out_buff = ivas_get_nchan_buffers_dec_fx( st_ivas, -1, -1 );
324 :
325 1013 : IF( NE_32( ( error = ivas_output_buff_dec_fx( st_ivas->p_output_fx, nchan_out_buff_old, nchan_out_buff ) ), IVAS_ERR_OK ) )
326 : {
327 0 : return error;
328 : }
329 : }
330 :
331 : /*-----------------------------------------------------------------*
332 : * JBM TC buffers
333 : *-----------------------------------------------------------------*/
334 : {
335 : Word16 tc_nchan_full_new;
336 : DECODER_TC_BUFFER_HANDLE hTcBuffer;
337 :
338 1013 : hTcBuffer = st_ivas->hTcBuffer;
339 1013 : tc_buffer_mode_new = ivas_jbm_dec_get_tc_buffer_mode( st_ivas );
340 1013 : tc_nchan_tc_new = ivas_jbm_dec_get_num_tc_channels_fx( st_ivas );
341 1013 : tc_nchan_allocate_new = tc_nchan_tc_new;
342 1013 : move16();
343 1013 : tc_nchan_full_new = tc_nchan_tc_new;
344 1013 : move16();
345 :
346 1013 : test();
347 1013 : test();
348 1013 : test();
349 1013 : test();
350 1013 : if ( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) && ( NE_32( st_ivas->renderer_type, RENDERER_MONO_DOWNMIX ) && NE_32( st_ivas->renderer_type, RENDERER_DISABLE ) && NE_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC ) && NE_32( st_ivas->renderer_type, RENDERER_BINAURAL_PARAMETRIC_ROOM ) ) )
351 : {
352 71 : tc_nchan_full_new = 0;
353 71 : move16();
354 : }
355 :
356 : /* reconfigure buffer */
357 1013 : test();
358 1013 : test();
359 1013 : test();
360 1013 : IF( NE_32( hTcBuffer->tc_buffer_mode, tc_buffer_mode_new ) || NE_16( hTcBuffer->nchan_transport_jbm, tc_nchan_tc_new ) ||
361 : NE_16( hTcBuffer->nchan_buffer_full, tc_nchan_full_new ) || NE_16( hTcBuffer->nchan_transport_internal, tc_nchan_allocate_new ) )
362 : {
363 311 : 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 ) )
364 : {
365 0 : return error;
366 : }
367 : }
368 :
369 : /* transfer subframe info from central tc buffer to ParamMC or McMASA (DirAC) */
370 1013 : IF( st_ivas->hSpatParamRendCom != NULL )
371 : {
372 251 : st_ivas->hSpatParamRendCom->nb_subframes = st_ivas->hTcBuffer->nb_subframes;
373 251 : move16();
374 251 : st_ivas->hSpatParamRendCom->subframes_rendered = st_ivas->hTcBuffer->subframes_rendered;
375 251 : move16();
376 251 : st_ivas->hSpatParamRendCom->num_slots = st_ivas->hTcBuffer->num_slots;
377 251 : move16();
378 251 : st_ivas->hSpatParamRendCom->slots_rendered = st_ivas->hTcBuffer->slots_rendered;
379 251 : move16();
380 :
381 251 : Copy( st_ivas->hTcBuffer->subframe_nbslots, st_ivas->hSpatParamRendCom->subframe_nbslots, MAX_JBM_SUBFRAMES_5MS );
382 : }
383 : }
384 :
385 1013 : return error;
386 : }
387 :
388 : /*-------------------------------------------------------------------------
389 : * ivas_ism_dec_config()
390 : *
391 : * - select ISM format mode
392 : * - reconfigure the ISM format decoder
393 : *-------------------------------------------------------------------------*/
394 :
395 92501 : ivas_error ivas_ism_dec_config_fx(
396 : Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
397 : const ISM_MODE last_ism_mode, /* i/o: last ISM mode */
398 : UWord16 *nSamplesRendered, /* o : number of samples flushed when the renderer granularity changes */
399 : Word16 *data /* o : output synthesis signal Q0*/
400 : )
401 : {
402 : Word32 ivas_total_brate;
403 : ivas_error error;
404 : Word16 nchan_transport_old;
405 :
406 92501 : error = IVAS_ERR_OK;
407 92501 : move32();
408 92501 : ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
409 92501 : move32();
410 : /* Assumes that num of input objects are constant */
411 92501 : nchan_transport_old = st_ivas->nchan_ism;
412 92501 : move16();
413 :
414 92501 : if ( EQ_32( last_ism_mode, ISM_MODE_PARAM ) )
415 : {
416 15745 : nchan_transport_old = MAX_PARAM_ISM_WAVE;
417 15745 : move16();
418 : }
419 :
420 92501 : test();
421 92501 : test();
422 92501 : test();
423 92501 : IF( !st_ivas->bfi && NE_32( ivas_total_brate, IVAS_SID_5k2 ) && ( ivas_total_brate != FRAME_NO_DATA ) )
424 : {
425 : /* select ISM format mode */
426 91951 : st_ivas->ism_mode = ivas_ism_mode_select( st_ivas->nchan_ism, ivas_total_brate );
427 91951 : move32();
428 91951 : st_ivas->nchan_transport = st_ivas->nchan_ism;
429 91951 : move16();
430 :
431 91951 : IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
432 : {
433 15649 : st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE;
434 15649 : move16();
435 15649 : if ( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
436 : {
437 513 : st_ivas->hDecoderConfig->nchan_out = st_ivas->nchan_ism;
438 513 : move16();
439 : }
440 : }
441 :
442 91951 : IF( st_ivas->ini_active_frame != 0 )
443 : {
444 : /* ISM bit-rate switching */
445 91883 : test();
446 91883 : IF( ( NE_16( st_ivas->ism_mode, last_ism_mode ) ) || ( NE_32( st_ivas->hDecoderConfig->ivas_total_brate, st_ivas->hDecoderConfig->last_ivas_total_brate ) ) )
447 : {
448 1007 : IF( NE_16( ( error = ivas_ism_bitrate_switching_dec_fx( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
449 : {
450 0 : return error;
451 : }
452 : }
453 : }
454 : }
455 550 : ELSE IF( !st_ivas->bfi && EQ_32( ivas_total_brate, IVAS_SID_5k2 ) )
456 : {
457 550 : st_ivas->nchan_transport = st_ivas->nchan_ism;
458 550 : move16();
459 550 : IF( EQ_32( st_ivas->ism_mode, ISM_MODE_PARAM ) )
460 : {
461 107 : st_ivas->nchan_transport = MAX_PARAM_ISM_WAVE;
462 107 : move16();
463 107 : if ( EQ_32( st_ivas->hDecoderConfig->output_config, IVAS_AUDIO_CONFIG_EXTERNAL ) )
464 : {
465 7 : st_ivas->hDecoderConfig->nchan_out = st_ivas->nchan_ism;
466 7 : move16();
467 : }
468 : }
469 :
470 : /* ISM mode switching */
471 550 : IF( NE_32( st_ivas->ism_mode, last_ism_mode ) )
472 : {
473 6 : IF( NE_16( ( error = ivas_ism_bitrate_switching_dec_fx( st_ivas, nchan_transport_old, last_ism_mode, nSamplesRendered, data ) ), IVAS_ERR_OK ) )
474 : {
475 0 : return error;
476 : }
477 : }
478 : }
479 :
480 92501 : SWITCH( st_ivas->nchan_ism )
481 : {
482 18984 : case 1:
483 18984 : st_ivas->transport_config = IVAS_AUDIO_CONFIG_ISM1;
484 18984 : move32();
485 18984 : BREAK;
486 16097 : case 2:
487 16097 : st_ivas->transport_config = IVAS_AUDIO_CONFIG_ISM2;
488 16097 : move32();
489 16097 : BREAK;
490 16285 : case 3:
491 16285 : st_ivas->transport_config = IVAS_AUDIO_CONFIG_ISM3;
492 16285 : move32();
493 16285 : BREAK;
494 41135 : case 4:
495 41135 : st_ivas->transport_config = IVAS_AUDIO_CONFIG_ISM4;
496 41135 : move32();
497 41135 : BREAK;
498 0 : default:
499 0 : st_ivas->transport_config = IVAS_AUDIO_CONFIG_INVALID;
500 0 : move32();
501 0 : BREAK;
502 : }
503 92501 : return error;
504 : }
|