Line data Source code
1 : /******************************************************************************************************
2 :
3 : (C) 2022-2026 IVAS codec Public Collaboration with portions copyright Dolby International AB, Ericsson AB,
4 : Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
5 : Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
6 : Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
7 : contributors to this repository. All Rights Reserved.
8 :
9 : This software is protected by copyright law and by international treaties.
10 : The IVAS codec Public Collaboration consisting of Dolby International AB, Ericsson AB,
11 : Fraunhofer-Gesellschaft zur Foerderung der angewandten Forschung e.V., Huawei Technologies Co. LTD.,
12 : Koninklijke Philips N.V., Nippon Telegraph and Telephone Corporation, Nokia Technologies Oy, Orange,
13 : Panasonic Holdings Corporation, Qualcomm Technologies, Inc., VoiceAge Corporation, and other
14 : contributors to this repository retain full ownership rights in their respective contributions in
15 : the software. This notice grants no license of any kind, including but not limited to patent
16 : license, nor is any license granted by implication, estoppel or otherwise.
17 :
18 : Contributors are required to enter into the IVAS codec Public Collaboration agreement before making
19 : contributions.
20 :
21 : This software is provided "AS IS", without any express or implied warranties. The software is in the
22 : development stage. It is intended exclusively for experts who have experience with such software and
23 : solely for the purpose of inspection. All implied warranties of non-infringement, merchantability
24 : and fitness for a particular purpose are hereby disclaimed and excluded.
25 :
26 : Any dispute, controversy or claim arising under or in relation to providing this software shall be
27 : submitted to and settled by the final, binding jurisdiction of the courts of Munich, Germany in
28 : accordance with the laws of the Federal Republic of Germany excluding its conflict of law rules and
29 : the United Nations Convention on Contracts on the International Sales of Goods.
30 :
31 : *******************************************************************************************************/
32 :
33 : #include <stdint.h>
34 : #include "options.h"
35 : #include "cnst.h"
36 : #include "ivas_cnst.h"
37 : #include "rom_com.h"
38 : #include "prot.h"
39 : #include "ivas_prot.h"
40 : #include "ivas_prot_rend.h"
41 : #include "ivas_rom_com.h"
42 : #include <math.h>
43 : #ifdef DEBUGGING
44 : #include "debug.h"
45 : #endif
46 : #include "wmc_auto.h"
47 :
48 :
49 : /*-----------------------------------------------------------------------*
50 : * Local function prototypes
51 : *-----------------------------------------------------------------------*/
52 :
53 :
54 : static void ivas_dec_tc_buffer_playout( Decoder_Struct *st_ivas, const uint16_t nSamplesAsked, uint16_t *nSamplesRendered, float *output[] );
55 :
56 : static void ivas_jbm_dec_copy_masa_meta_to_buffer( Decoder_Struct *st_ivas );
57 :
58 : static void ivas_jbm_masa_sf_to_slot_map( Decoder_Struct *st_ivas, const int16_t nCldfbTs );
59 :
60 :
61 : /*--------------------------------------------------------------------------*
62 : * ivas_dec_feed_tc_to_renderer()
63 : *
64 : * Feed decoded transport channels to the IVAS renderer routine
65 : * + digest TC channels in ParamISM and ParamMC
66 : *--------------------------------------------------------------------------*/
67 :
68 716075 : void ivas_dec_feed_tc_to_renderer(
69 : Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
70 : const int16_t nSamplesForRendering, /* i : number of TC samples available for rendering */
71 : int16_t *nSamplesResidual /* o : number of samples not fitting into the renderer grid and buffer for the next call*/
72 : )
73 : {
74 : float tmp_buf[MAX_JBM_L_FRAME48k];
75 : float *p_data_f[FOA_CHANNELS + MAX_NUM_OBJECTS];
76 : int16_t n, n_render_timeslots, n_ch_cldfb, ch;
77 : DECODER_TC_BUFFER_HANDLE hTcBuffer;
78 :
79 716075 : hTcBuffer = st_ivas->hTcBuffer;
80 716075 : n_ch_cldfb = hTcBuffer->nchan_transport_rend - hTcBuffer->nchan_buffer_full;
81 :
82 716075 : if ( st_ivas->hDecoderConfig->Opt_tsm )
83 : {
84 : int16_t n_samples_still_available;
85 : int16_t n_ch_full_copy, n_ch_res_copy;
86 :
87 148659 : n_samples_still_available = hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered;
88 148659 : hTcBuffer->n_samples_buffered = n_samples_still_available + nSamplesForRendering + hTcBuffer->n_samples_discard;
89 148659 : hTcBuffer->n_samples_available = hTcBuffer->n_samples_granularity * ( hTcBuffer->n_samples_buffered / hTcBuffer->n_samples_granularity );
90 148659 : *nSamplesResidual = hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_available;
91 148659 : n_ch_full_copy = min( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full );
92 148659 : n_ch_res_copy = hTcBuffer->nchan_transport_rend - hTcBuffer->nchan_buffer_full;
93 :
94 718148 : for ( ch = 0; ch < n_ch_full_copy; ch++ )
95 : {
96 569489 : mvr2r( hTcBuffer->tc[ch], tmp_buf, nSamplesForRendering );
97 569489 : set_zero( hTcBuffer->tc[ch], hTcBuffer->n_samples_discard );
98 569489 : mvr2r( hTcBuffer->tc_buffer_old[ch], hTcBuffer->tc[ch] + hTcBuffer->n_samples_discard, n_samples_still_available );
99 569489 : mvr2r( tmp_buf, hTcBuffer->tc[ch] + n_samples_still_available + hTcBuffer->n_samples_discard, nSamplesForRendering - *nSamplesResidual );
100 569489 : mvr2r( tmp_buf + nSamplesForRendering - *nSamplesResidual, hTcBuffer->tc_buffer_old[ch], *nSamplesResidual );
101 : }
102 :
103 148659 : if ( n_ch_res_copy > 0 )
104 : {
105 20519 : for ( ; ch < hTcBuffer->nchan_transport_rend; ch++ )
106 : {
107 14544 : p_data_f[ch] = hTcBuffer->tc[ch];
108 14544 : mvr2r( hTcBuffer->tc[ch], tmp_buf, nSamplesForRendering );
109 14544 : mvr2r( hTcBuffer->tc_buffer_old[ch], p_data_f[ch], n_samples_still_available );
110 14544 : mvr2r( tmp_buf, p_data_f[ch] + n_samples_still_available, nSamplesForRendering - *nSamplesResidual );
111 14544 : mvr2r( tmp_buf + nSamplesForRendering - *nSamplesResidual, hTcBuffer->tc_buffer_old[ch], *nSamplesResidual );
112 : }
113 : }
114 :
115 148659 : n_render_timeslots = hTcBuffer->n_samples_available / hTcBuffer->n_samples_granularity;
116 : }
117 : else
118 : {
119 603026 : for ( n = 0; n < n_ch_cldfb; n++ )
120 : {
121 35610 : p_data_f[n] = &st_ivas->p_output_f[n][0];
122 : }
123 :
124 567416 : ch = max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full );
125 2736445 : for ( n = 0; n < ch; n++ )
126 : {
127 2169029 : hTcBuffer->tc[n] = st_ivas->p_output_f[n]; /* note: buffers needed in the TD decorellator */
128 : }
129 :
130 567416 : hTcBuffer->n_samples_buffered = nSamplesForRendering;
131 567416 : hTcBuffer->n_samples_available = hTcBuffer->n_samples_buffered;
132 567416 : *nSamplesResidual = 0;
133 :
134 567416 : n_render_timeslots = DEFAULT_JBM_CLDFB_TIMESLOTS;
135 : }
136 :
137 : /* CLDFB analysis for ParamMC/ParamISM */
138 716075 : if ( st_ivas->ivas_format == ISM_FORMAT && st_ivas->ism_mode == ISM_MODE_PARAM && ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) )
139 : {
140 6758 : ivas_param_ism_dec_digest_tc( st_ivas, n_render_timeslots, p_data_f );
141 : }
142 709317 : else if ( st_ivas->ivas_format == MC_FORMAT && st_ivas->mc_mode == MC_MODE_PARAMMC && hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_RENDERER )
143 : {
144 15707 : ivas_param_mc_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, p_data_f );
145 : }
146 :
147 716075 : hTcBuffer->n_samples_rendered = 0;
148 716075 : hTcBuffer->subframes_rendered = 0;
149 :
150 716075 : return;
151 : }
152 :
153 :
154 : /*--------------------------------------------------------------------------*
155 : * ivas_dec_render()
156 : *
157 : * Principal IVAS internal rendering routine
158 : *--------------------------------------------------------------------------*/
159 :
160 795921 : ivas_error ivas_dec_render(
161 : Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
162 : const uint16_t nSamplesAsked, /* i : number of samples wanted */
163 : uint16_t *nSamplesRendered, /* o : number of samples rendered */
164 : uint16_t *nSamplesAvailableNext, /* o : number of samples still available in the rendering pipeline */
165 : const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */
166 : void *data /* o : output synthesis signal */
167 : )
168 : {
169 : int16_t n, nchan_out;
170 : int16_t nchan_transport_rend;
171 : int16_t nchan_remapped;
172 : int32_t output_Fs;
173 : AUDIO_CONFIG output_config;
174 : int16_t nSamplesAskedLocal;
175 : ivas_error error;
176 : float *p_output[MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS];
177 : float *p_tc[MAX_TRANSPORT_CHANNELS + MAX_NUM_OBJECTS];
178 : int16_t nchan_out_syn_output;
179 :
180 795921 : push_wmops( "ivas_dec_render" );
181 : /*----------------------------------------------------------------*
182 : * Initialization of local vars after struct has been set
183 : *----------------------------------------------------------------*/
184 :
185 795921 : output_Fs = st_ivas->hDecoderConfig->output_Fs;
186 795921 : nchan_out = st_ivas->hDecoderConfig->nchan_out;
187 795921 : nchan_transport_rend = st_ivas->hTcBuffer->nchan_transport_rend;
188 795921 : output_config = st_ivas->hDecoderConfig->output_config;
189 795921 : nSamplesAskedLocal = nSamplesAsked + st_ivas->hTcBuffer->n_samples_discard;
190 :
191 16714341 : for ( n = 0; n < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; n++ )
192 : {
193 15918420 : p_output[n] = st_ivas->p_output_f[n];
194 : }
195 :
196 795921 : if ( !st_ivas->hDecoderConfig->Opt_tsm )
197 : {
198 9748072 : for ( n = 0; n < MAX_INTERN_CHANNELS; n++ )
199 : {
200 9174656 : st_ivas->hTcBuffer->tc[n] = p_output[n];
201 : }
202 : }
203 :
204 4065806 : for ( n = 0; n < st_ivas->hTcBuffer->nchan_buffer_full; n++ )
205 : {
206 3269885 : p_tc[n] = &st_ivas->hTcBuffer->tc[n][st_ivas->hTcBuffer->n_samples_rendered];
207 : }
208 :
209 : /*----------------------------------------------------------------*
210 : * Update combined orientation access index
211 : *----------------------------------------------------------------*/
212 :
213 795921 : if ( st_ivas->hCombinedOrientationData != NULL )
214 : {
215 : /* take the discard samples into account here to make sure head rotation stays on the correct 5ms grid */
216 339906 : st_ivas->hCombinedOrientationData->cur_subframe_samples_rendered_start -= st_ivas->hTcBuffer->n_samples_discard;
217 :
218 339906 : ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData );
219 : }
220 :
221 : /*----------------------------------------------------------------*
222 : * Rendering
223 : *----------------------------------------------------------------*/
224 :
225 795921 : *nSamplesRendered = min( st_ivas->hTcBuffer->n_samples_available, nSamplesAskedLocal );
226 :
227 795921 : if ( st_ivas->ivas_format == UNDEFINED_FORMAT )
228 : {
229 0 : assert( 0 );
230 : }
231 795921 : else if ( st_ivas->hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_BUFFER )
232 : {
233 153394 : ivas_dec_tc_buffer_playout( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output );
234 : }
235 642527 : else if ( st_ivas->ivas_format == MONO_FORMAT || st_ivas->ivas_format == STEREO_FORMAT )
236 : {
237 : /* Rendering */
238 3044 : if ( st_ivas->renderer_type == RENDERER_MC )
239 : {
240 0 : ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc, p_output );
241 : }
242 3044 : else if ( st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX )
243 : {
244 1000 : ivas_apply_non_diegetic_panning( p_tc[0], p_output, st_ivas->hDecoderConfig->non_diegetic_pan_gain, *nSamplesRendered );
245 : }
246 2044 : else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC )
247 : {
248 2044 : ivas_stereo2sba( p_tc, p_output, *nSamplesRendered );
249 : }
250 : }
251 639483 : else if ( st_ivas->ivas_format == ISM_FORMAT )
252 : {
253 : /* Rendering */
254 96075 : if ( st_ivas->ism_mode == ISM_MODE_PARAM )
255 : {
256 22194 : if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC )
257 : {
258 12693 : ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, st_ivas->nchan_transport, p_output );
259 : }
260 9501 : else if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC )
261 : {
262 9501 : ivas_param_ism_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output );
263 :
264 9501 : if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC )
265 : {
266 : /* Convert CICP19 -> Ambisonics */
267 7458 : ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0.f );
268 : }
269 : }
270 : }
271 : else /* ISM_MODE_DISC */
272 : {
273 : /* Loudspeaker or Ambisonics rendering */
274 73881 : if ( st_ivas->renderer_type == RENDERER_TD_PANNING || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM )
275 : {
276 : /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */
277 21558 : ivas_ism_render_sf( st_ivas, st_ivas->renderer_type, p_output, *nSamplesRendered );
278 : }
279 52323 : else if ( st_ivas->renderer_type == RENDERER_NON_DIEGETIC_DOWNMIX )
280 : {
281 1500 : ivas_apply_non_diegetic_panning( p_tc[0], p_output, st_ivas->hDecoderConfig->non_diegetic_pan_gain, *nSamplesRendered );
282 : }
283 : #ifdef DEBUGGING
284 : else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV )
285 : #else
286 50823 : else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC )
287 : #endif
288 : {
289 : /* Convert to Ambisonics */
290 7843 : ivas_ism2sba_sf( p_tc, p_output, st_ivas->hIsmRendererData, st_ivas->nchan_transport, *nSamplesRendered, st_ivas->hTcBuffer->n_samples_rendered, st_ivas->hIntSetup.ambisonics_order );
291 : }
292 :
293 : /* Binaural rendering */
294 73881 : if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD )
295 : {
296 42980 : if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
297 : {
298 9342 : if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK )
299 : {
300 0 : return error;
301 : }
302 : }
303 : else
304 : {
305 33638 : if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK )
306 : {
307 0 : return error;
308 : }
309 : }
310 : }
311 30901 : else if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM )
312 : {
313 11458 : if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL,
314 11458 : NULL, NULL, st_ivas->hTcBuffer, p_output, p_output, *nSamplesRendered, output_Fs, 0 ) ) != IVAS_ERR_OK )
315 : {
316 0 : return error;
317 : }
318 : }
319 : }
320 : }
321 543408 : else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT )
322 : {
323 292885 : nchan_remapped = nchan_transport_rend;
324 :
325 : /* Loudspeakers, Ambisonics or Binaural rendering */
326 292885 : if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC )
327 : {
328 129308 : ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output );
329 : }
330 163577 : else if ( st_ivas->ivas_format == MASA_FORMAT )
331 : {
332 28080 : if ( st_ivas->renderer_type == RENDERER_DIRAC )
333 : {
334 28080 : ivas_dirac_dec_render( st_ivas, nchan_remapped, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output );
335 : }
336 : }
337 : else
338 : {
339 135497 : if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK )
340 : {
341 0 : return error;
342 : }
343 : }
344 : }
345 250523 : else if ( st_ivas->ivas_format == MASA_ISM_FORMAT )
346 : {
347 66724 : nchan_remapped = st_ivas->nchan_transport;
348 :
349 66724 : if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC )
350 : {
351 56404 : if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC )
352 : {
353 29659 : if ( ( error = ivas_omasa_dirac_td_binaural( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output ) ) != IVAS_ERR_OK )
354 : {
355 0 : return error;
356 : }
357 : }
358 : else
359 : {
360 26745 : ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output );
361 : }
362 : }
363 10320 : else if ( st_ivas->renderer_type == RENDERER_DIRAC )
364 : {
365 9818 : ivas_omasa_dirac_rend( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output );
366 : }
367 502 : else if ( st_ivas->renderer_type == RENDERER_OMASA_OBJECT_EXT || st_ivas->renderer_type == RENDERER_OMASA_MIX_EXT )
368 : {
369 502 : ivas_dec_tc_buffer_playout( st_ivas, nSamplesAskedLocal, nSamplesRendered, p_output );
370 502 : ivas_omasa_rearrange_channels( p_output, st_ivas->nchan_ism, *nSamplesRendered );
371 : }
372 : }
373 183799 : else if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
374 : {
375 74464 : nchan_remapped = nchan_transport_rend;
376 :
377 : /* Loudspeakers, Ambisonics or Binaural rendering */
378 74464 : if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
379 : {
380 60976 : if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV )
381 : {
382 48230 : if ( ( error = ivas_osba_dirac_td_binaural( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK )
383 : {
384 0 : return error;
385 : }
386 : }
387 12746 : else if ( st_ivas->renderer_type == RENDERER_OSBA_STEREO )
388 : {
389 : /* shift SBA channels to avoid overwrite by ISM upmix in 1 object case and non-TSM unified channel memory*/
390 1400 : if ( st_ivas->nchan_ism == 1 && st_ivas->hDecoderConfig->Opt_tsm == 0 )
391 : {
392 0 : mvr2r( p_tc[2], p_output[3], *nSamplesRendered );
393 0 : mvr2r( p_tc[1], p_output[2], *nSamplesRendered );
394 0 : p_tc[1] = p_output[2];
395 0 : p_tc[2] = p_output[3];
396 : }
397 :
398 : /* render objects */
399 1400 : ivas_ism_render_sf( st_ivas, st_ivas->renderer_type, p_output, *nSamplesRendered );
400 :
401 : /* add already rendered SBA part */
402 1400 : ivas_osba_stereo_add_channels( p_tc, p_output, st_ivas->hSbaIsmData->gain_bed, nchan_out, st_ivas->nchan_ism, *nSamplesRendered );
403 : }
404 11346 : else if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM )
405 : {
406 8946 : if ( ( error = ivas_osba_render_sf( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK )
407 : {
408 0 : return error;
409 : }
410 : }
411 2400 : else if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) /*EXT output = individual objects + HOA3*/
412 : {
413 2400 : if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, &p_output[st_ivas->nchan_ism] ) ) != IVAS_ERR_OK )
414 : {
415 0 : return error;
416 : }
417 :
418 9000 : for ( n = 0; n < st_ivas->nchan_ism; n++ )
419 : {
420 6600 : mvr2r( p_tc[n], p_output[n], *nSamplesRendered );
421 : }
422 : }
423 : else
424 : {
425 0 : if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK )
426 : {
427 0 : return error;
428 : }
429 : }
430 : }
431 13488 : else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM )
432 : {
433 9248 : ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output );
434 27744 : for ( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ )
435 : {
436 18496 : v_multc( p_output[n], 2.0f, p_output[n], *nSamplesRendered );
437 : }
438 : }
439 : else
440 : {
441 4240 : if ( ( error = ivas_sba_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK )
442 : {
443 0 : return error;
444 : }
445 :
446 4240 : if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL )
447 : {
448 : #ifdef DEBUGGING
449 : assert( st_ivas->ism_mode == ISM_MODE_NONE );
450 : #endif
451 10200 : for ( n = st_ivas->hIntSetup.nchan_out_woLFE - 1; n >= 0; n-- )
452 : {
453 9600 : mvr2r( p_output[n], p_output[n + st_ivas->nchan_ism], *nSamplesRendered );
454 : }
455 3000 : for ( n = 0; n < st_ivas->nchan_ism; n++ )
456 : {
457 2400 : set_zero( p_output[n], *nSamplesRendered );
458 : }
459 : }
460 43520 : for ( n = 0; n < st_ivas->hDecoderConfig->nchan_out; n++ )
461 : {
462 39280 : v_multc( p_output[n], 2.0f, p_output[n], *nSamplesRendered );
463 : }
464 : }
465 : }
466 109335 : else if ( st_ivas->ivas_format == MC_FORMAT )
467 : {
468 109335 : if ( st_ivas->mc_mode == MC_MODE_MCT )
469 : {
470 76295 : int16_t crendInPlaceRotation = FALSE;
471 :
472 76295 : if ( st_ivas->transport_config != st_ivas->intern_config && ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_FOA || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA2 || st_ivas->intern_config == IVAS_AUDIO_CONFIG_HOA3 ) )
473 : {
474 5774 : if ( ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) < ( st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe ) )
475 : {
476 5774 : crendInPlaceRotation = TRUE;
477 5774 : ivas_mc2sba( st_ivas->hTransSetup, p_tc, p_output, *nSamplesRendered, st_ivas->hIntSetup.ambisonics_order, GAIN_LFE );
478 : }
479 : }
480 :
481 : /* Rendering */
482 76295 : if ( st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV || st_ivas->renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM )
483 : {
484 19540 : if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
485 : {
486 11124 : if ( ( error = ivas_rend_crendProcessSubframesSplitBin( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, ( st_ivas->hSplitBinRend == NULL ) ? NULL : &st_ivas->hSplitBinRend->splitrend.multiBinPoseData, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData,
487 11124 : &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs ) ) != IVAS_ERR_OK )
488 : {
489 0 : return error;
490 : }
491 : }
492 : else
493 : {
494 27956 : if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, st_ivas->intern_config, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData,
495 27956 : &st_ivas->hIntSetup, st_ivas->hEFAPdata, st_ivas->hTcBuffer, crendInPlaceRotation ? p_output : p_tc, p_output, *nSamplesRendered, output_Fs, 0 ) ) != IVAS_ERR_OK )
496 : {
497 0 : return error;
498 : }
499 :
500 13978 : ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output );
501 : }
502 : }
503 56755 : else if ( st_ivas->renderer_type == RENDERER_MC )
504 : {
505 4404 : ivas_ls_setup_conversion( st_ivas, st_ivas->nchan_transport, *nSamplesRendered, p_tc, p_output );
506 : }
507 52351 : else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC )
508 : {
509 490 : ivas_mc2sba( st_ivas->hIntSetup, p_tc, p_output, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0.f );
510 : }
511 51861 : else if ( st_ivas->renderer_type == RENDERER_BINAURAL_OBJECTS_TD )
512 : {
513 51861 : if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
514 : {
515 48717 : if ( ( error = ivas_td_binaural_renderer_sf_splitBinaural( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK )
516 : {
517 0 : return error;
518 : }
519 : }
520 : else
521 : {
522 3144 : if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, *nSamplesRendered ) ) != IVAS_ERR_OK )
523 : {
524 0 : return error;
525 : }
526 :
527 3144 : ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_tc, p_output );
528 : }
529 : }
530 : }
531 33040 : else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX )
532 : {
533 7954 : ivas_mc_paramupmix_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_tc, p_output );
534 :
535 : /* Rendering */
536 7954 : if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV || st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ) && !st_ivas->hDecoderConfig->Opt_Headrotation )
537 : {
538 : /* handled in CLDFB domain already */
539 160 : if ( output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
540 : {
541 160 : ivas_binaural_add_LFE( st_ivas, *nSamplesRendered, p_output, p_output );
542 : }
543 : }
544 7794 : else if ( st_ivas->renderer_type == RENDERER_MC )
545 : {
546 0 : ivas_ls_setup_conversion( st_ivas, MC_PARAMUPMIX_MAX_INPUT_CHANS, *nSamplesRendered, p_output, p_output );
547 : }
548 7794 : else if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC )
549 : {
550 10 : ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0.f );
551 : }
552 : }
553 25086 : else if ( st_ivas->mc_mode == MC_MODE_PARAMMC )
554 : {
555 15806 : ivas_param_mc_dec_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output );
556 : }
557 9280 : else if ( st_ivas->mc_mode == MC_MODE_MCMASA )
558 : {
559 9280 : nchan_remapped = st_ivas->nchan_transport;
560 :
561 9280 : if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC )
562 : {
563 7401 : ivas_dirac_dec_binaural_render( st_ivas, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, nchan_remapped, p_output );
564 : }
565 1879 : else if ( st_ivas->renderer_type == RENDERER_DIRAC || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC ) /* rendering to CICPxx and Ambisonics */
566 : {
567 1879 : ivas_dirac_dec_render( st_ivas, nchan_remapped, nSamplesAskedLocal, nSamplesRendered, nSamplesAvailableNext, p_output );
568 :
569 1879 : if ( st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC )
570 : {
571 : /* we still need to copy the separate channel if available */
572 290 : if ( st_ivas->hOutSetup.separateChannelEnabled )
573 : {
574 25 : mvr2r( p_tc[LFE_CHANNEL - 1], p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered );
575 : }
576 :
577 290 : ivas_mc2sba( st_ivas->hIntSetup, p_output, p_output, *nSamplesRendered, st_ivas->hOutSetup.ambisonics_order, 0.f );
578 : }
579 1589 : else if ( st_ivas->intern_config == IVAS_AUDIO_CONFIG_5_1 && ( output_config == IVAS_AUDIO_CONFIG_5_1_2 || output_config == IVAS_AUDIO_CONFIG_5_1_4 || output_config == IVAS_AUDIO_CONFIG_7_1 ) )
580 : {
581 0 : for ( n = st_ivas->hIntSetup.nchan_out_woLFE + st_ivas->hIntSetup.num_lfe; n < st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe; n++ )
582 : {
583 0 : set_zero( p_output[n], *nSamplesRendered );
584 : }
585 : }
586 : }
587 :
588 : /* copy discrete C and TD LFE from internal TC to output */
589 9280 : if ( st_ivas->hOutSetup.separateChannelEnabled )
590 : {
591 304 : if ( output_config == IVAS_AUDIO_CONFIG_5_1 || output_config == IVAS_AUDIO_CONFIG_7_1 ||
592 155 : output_config == IVAS_AUDIO_CONFIG_5_1_4 || output_config == IVAS_AUDIO_CONFIG_7_1_4 ||
593 155 : output_config == IVAS_AUDIO_CONFIG_5_1_2 || ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe > 0 ) )
594 : {
595 149 : mvr2r( p_tc[LFE_CHANNEL], p_output[LFE_CHANNEL], *nSamplesRendered );
596 149 : mvr2r( p_tc[LFE_CHANNEL - 1], p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered );
597 : }
598 155 : else if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM && st_ivas->hOutSetup.num_lfe == 0 )
599 : {
600 0 : mvr2r( p_tc[LFE_CHANNEL - 1], p_output[st_ivas->hOutSetup.separateChannelIndex], *nSamplesRendered );
601 : }
602 : }
603 : }
604 : }
605 :
606 : /*----------------------------------------------------------------*
607 : * Write IVAS output channels
608 : * - compensation for saturation
609 : * - float to integer conversion
610 : *----------------------------------------------------------------*/
611 :
612 795921 : st_ivas->hTcBuffer->n_samples_available -= *nSamplesRendered;
613 795921 : st_ivas->hTcBuffer->n_samples_rendered += *nSamplesRendered;
614 :
615 : /* update global combined orientation start index */
616 795921 : ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, *nSamplesRendered );
617 :
618 795921 : if ( st_ivas->hTcBuffer->n_samples_discard > 0 )
619 : {
620 1380 : for ( n = 0; n < min( MAX_OUTPUT_CHANNELS, ivas_get_nchan_buffers_dec( st_ivas, st_ivas->sba_analysis_order, st_ivas->hDecoderConfig->ivas_total_brate ) ); n++ )
621 : {
622 1174 : p_output[n] += st_ivas->hTcBuffer->n_samples_discard;
623 : }
624 206 : *nSamplesRendered -= st_ivas->hTcBuffer->n_samples_discard;
625 206 : st_ivas->hTcBuffer->n_samples_discard = 0;
626 : }
627 :
628 795921 : if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
629 : {
630 260465 : nchan_out_syn_output = BINAURAL_CHANNELS * st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses;
631 : #ifdef TMP_1342_WORKAROUND_DEC_FLUSH_BROKEN_IN_SR
632 260465 : if ( st_ivas->flushing )
633 : {
634 250 : nchan_out_syn_output = BINAURAL_CHANNELS;
635 : }
636 : #endif
637 : }
638 : else
639 : {
640 535456 : nchan_out_syn_output = nchan_out;
641 : }
642 :
643 795921 : if ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 )
644 : {
645 535456 : if ( st_ivas->ivas_format != MONO_FORMAT )
646 : {
647 : #ifndef DISABLE_LIMITER
648 530306 : ivas_limiter_dec( st_ivas->hLimiter, p_output, nchan_out, *nSamplesRendered, st_ivas->BER_detect );
649 : #endif
650 : }
651 : }
652 :
653 795921 : switch ( pcm_resolution )
654 : {
655 535706 : case PCM_INT16:
656 : #ifdef DEBUGGING
657 : st_ivas->noClipping +=
658 : #endif
659 535706 : ivas_syn_output( p_output, *nSamplesRendered, nchan_out_syn_output, (int16_t *) data );
660 :
661 535706 : break;
662 260215 : case PCM_FLOAT32:
663 260215 : ivas_buffer_deinterleaved_to_interleaved( p_output, (float *) data, nchan_out_syn_output, *nSamplesRendered );
664 260215 : break;
665 0 : default:
666 0 : error = IVAS_ERR_UNKNOWN;
667 0 : break;
668 : }
669 :
670 795921 : *nSamplesAvailableNext = st_ivas->hTcBuffer->n_samples_available;
671 :
672 795921 : pop_wmops();
673 795921 : return IVAS_ERR_OK;
674 : }
675 :
676 :
677 : /*--------------------------------------------------------------------------*
678 : * ivas_jbm_dec_flush_renderer()
679 : *
680 : * Flush samples if renderer granularity changes on a bitrate change in JBM
681 : *--------------------------------------------------------------------------*/
682 :
683 529 : ivas_error ivas_jbm_dec_flush_renderer(
684 : Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
685 : const int16_t tc_granularity_new, /* i : new renderer granularity */
686 : const RENDERER_TYPE renderer_type_old, /* i : old renderer type */
687 : const AUDIO_CONFIG intern_config_old, /* i : old internal config */
688 : const IVAS_OUTPUT_SETUP_HANDLE hIntSetupOld, /* i : old internal output setup */
689 : const MC_MODE mc_mode_old, /* i : old MC mode */
690 : const ISM_MODE ism_mode_old, /* i : old ISM mode */
691 : uint16_t *nSamplesRendered, /* o : number of samples flushed */
692 : const PCM_RESOLUTION pcm_resolution, /* i : type for the decoded PCM resolution */
693 : void *data /* o : output synthesis signal */
694 : )
695 : {
696 : ivas_error error;
697 : int16_t n_samples_still_available;
698 : int16_t n_slots_still_available;
699 : int16_t n_samples_to_render;
700 : int16_t ch_idx;
701 : int16_t n_samples_granularity;
702 : DECODER_TC_BUFFER_HANDLE hTcBuffer;
703 : float *p_output[MAX_LS_CHANNELS + MAX_NUM_OBJECTS];
704 :
705 529 : if ( !st_ivas->hDecoderConfig->Opt_tsm )
706 : {
707 0 : return IVAS_ERR_OK;
708 : }
709 :
710 11109 : for ( ch_idx = 0; ch_idx < MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS; ch_idx++ )
711 : {
712 10580 : p_output[ch_idx] = st_ivas->p_output_f[ch_idx];
713 : }
714 :
715 529 : *nSamplesRendered = 0;
716 529 : hTcBuffer = st_ivas->hTcBuffer;
717 529 : n_samples_granularity = hTcBuffer->n_samples_granularity;
718 :
719 : /* get number of possible slots in new granularity */
720 529 : n_samples_still_available = hTcBuffer->n_samples_buffered - hTcBuffer->n_samples_rendered;
721 529 : n_slots_still_available = n_samples_still_available / tc_granularity_new;
722 529 : *nSamplesRendered = n_slots_still_available * tc_granularity_new;
723 529 : n_samples_to_render = *nSamplesRendered;
724 529 : n_samples_still_available -= n_samples_to_render;
725 529 : assert( n_samples_still_available < tc_granularity_new );
726 :
727 : /* update combined orientation access index */
728 529 : ivas_combined_orientation_set_to_start_index( st_ivas->hCombinedOrientationData );
729 :
730 529 : if ( n_slots_still_available )
731 : {
732 : /* render available full slots (with new lower granularity) */
733 1290 : for ( ch_idx = 0; ch_idx < max( hTcBuffer->nchan_transport_rend, hTcBuffer->nchan_buffer_full ); ch_idx++ )
734 : {
735 : /* move it at the beginning of the TC buffer with zero padding */
736 1085 : mvr2r( hTcBuffer->tc_buffer_old[ch_idx], hTcBuffer->tc[ch_idx], n_samples_to_render );
737 1085 : set_zero( hTcBuffer->tc[ch_idx] + n_samples_to_render, hTcBuffer->n_samples_granularity - n_samples_to_render );
738 : }
739 :
740 : /* simple change of the slot info */
741 205 : hTcBuffer->num_slots = 1;
742 205 : hTcBuffer->nb_subframes = 1;
743 205 : hTcBuffer->subframes_rendered = 0;
744 205 : hTcBuffer->slots_rendered = 0;
745 205 : hTcBuffer->subframe_nbslots[0] = 1;
746 205 : hTcBuffer->n_samples_buffered = n_samples_granularity + n_samples_still_available;
747 205 : hTcBuffer->n_samples_available = 0;
748 205 : hTcBuffer->n_samples_flushed = n_samples_to_render;
749 205 : hTcBuffer->n_samples_rendered = 0;
750 :
751 :
752 205 : if ( st_ivas->ivas_format == ISM_FORMAT )
753 : {
754 79 : if ( ism_mode_old == ISM_MODE_DISC )
755 : {
756 : /* Binaural rendering */
757 79 : if ( renderer_type_old == RENDERER_BINAURAL_OBJECTS_TD )
758 : {
759 72 : if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, n_samples_granularity ) ) != IVAS_ERR_OK )
760 : {
761 0 : return error;
762 : }
763 : }
764 7 : else if ( renderer_type_old == RENDERER_BINAURAL_MIXER_CONV_ROOM )
765 : {
766 : /* Convert to CICPxx; used also for ISM->CICP19->binaural_room rendering */
767 7 : set_f( st_ivas->hIsmRendererData->interpolator, 1.0f, n_samples_granularity );
768 :
769 7 : ivas_ism_render_sf( st_ivas, renderer_type_old, p_output, n_samples_granularity );
770 :
771 7 : if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, IVAS_AUDIO_CONFIG_7_1_4, IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR, st_ivas->hDecoderConfig, NULL,
772 7 : NULL, NULL, hTcBuffer, p_output, p_output, n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ) != IVAS_ERR_OK )
773 : {
774 0 : return error;
775 : }
776 : }
777 : }
778 : else
779 : {
780 0 : return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong ISM_MODE in VoIP renderer flushing!" );
781 : }
782 : }
783 126 : else if ( st_ivas->ivas_format == MC_FORMAT )
784 : {
785 2 : if ( mc_mode_old == MC_MODE_MCT )
786 : {
787 2 : int16_t crendInPlaceRotation = FALSE;
788 :
789 2 : if ( st_ivas->transport_config != intern_config_old && ( intern_config_old == IVAS_AUDIO_CONFIG_FOA || intern_config_old == IVAS_AUDIO_CONFIG_HOA2 || intern_config_old == IVAS_AUDIO_CONFIG_HOA3 ) )
790 : {
791 1 : if ( ( st_ivas->hTransSetup.nchan_out_woLFE + st_ivas->hTransSetup.num_lfe ) < ( hIntSetupOld->nchan_out_woLFE + hIntSetupOld->num_lfe ) )
792 : {
793 1 : crendInPlaceRotation = TRUE;
794 1 : ivas_mc2sba( st_ivas->hTransSetup, hTcBuffer->tc, p_output, n_samples_granularity, hIntSetupOld->ambisonics_order, GAIN_LFE );
795 : }
796 : }
797 2 : if ( renderer_type_old == RENDERER_BINAURAL_MIXER_CONV || renderer_type_old == RENDERER_BINAURAL_MIXER_CONV_ROOM )
798 : {
799 1 : if ( ( error = ivas_rend_crendProcessSubframe( st_ivas->hCrendWrapper, intern_config_old, st_ivas->hOutSetup.output_config, st_ivas->hDecoderConfig, st_ivas->hCombinedOrientationData,
800 1 : hIntSetupOld, st_ivas->hEFAPdata, hTcBuffer, crendInPlaceRotation ? p_output : hTcBuffer->tc, p_output, n_samples_granularity, st_ivas->hDecoderConfig->output_Fs, 0 ) ) != IVAS_ERR_OK )
801 : {
802 0 : return error;
803 : }
804 :
805 1 : ivas_binaural_add_LFE( st_ivas, n_samples_granularity, hTcBuffer->tc, p_output );
806 : }
807 1 : else if ( renderer_type_old == RENDERER_BINAURAL_OBJECTS_TD )
808 : {
809 1 : if ( ( error = ivas_td_binaural_renderer_sf( st_ivas, p_output, n_samples_granularity ) ) != IVAS_ERR_OK )
810 : {
811 0 : return error;
812 : }
813 :
814 1 : ivas_binaural_add_LFE( st_ivas, n_samples_granularity, hTcBuffer->tc, p_output );
815 : }
816 : else
817 : {
818 0 : return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong renderer in MCT VoIP renderer flushing!" );
819 : }
820 : }
821 : else
822 : {
823 0 : return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong MC_MODE in VoIP renderer flushing!" );
824 : }
825 : }
826 124 : else if ( st_ivas->ivas_format == MASA_ISM_FORMAT || st_ivas->ivas_format == MASA_FORMAT )
827 : {
828 101 : if ( ism_mode_old == ISM_MASA_MODE_DISC )
829 : {
830 : float *tc_local[MAX_NUM_OBJECTS];
831 : int16_t last_dirac_md_idx;
832 : uint16_t nSamplesAvailableNext;
833 : ISM_MODE ism_mode_orig;
834 : RENDERER_TYPE renderer_type_orig;
835 : int32_t ivas_total_brate;
836 :
837 : /* copy from ISM delay buffer to the correct place in TCs */
838 505 : for ( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ )
839 : {
840 404 : tc_local[ch_idx] = &hTcBuffer->tc[ch_idx + 2][hTcBuffer->n_samples_rendered];
841 404 : mvr2r( st_ivas->hMasaIsmData->delayBuffer[ch_idx], tc_local[ch_idx], st_ivas->hMasaIsmData->delayBuffer_size );
842 : }
843 :
844 : /* to render flushed samples, use configuration from the last received frame */
845 101 : ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
846 101 : renderer_type_orig = st_ivas->renderer_type;
847 101 : ism_mode_orig = st_ivas->ism_mode;
848 101 : st_ivas->ism_mode = ism_mode_old;
849 101 : st_ivas->renderer_type = renderer_type_old;
850 101 : st_ivas->hDecoderConfig->ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate;
851 101 : last_dirac_md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[st_ivas->hSpatParamRendCom->slots_rendered - 1];
852 :
853 : /* transfer adapted sf info from hTcBuffer to DirAC */
854 101 : st_ivas->hSpatParamRendCom->nb_subframes = 1;
855 101 : st_ivas->hSpatParamRendCom->subframes_rendered = 0;
856 101 : st_ivas->hSpatParamRendCom->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME;
857 101 : st_ivas->hSpatParamRendCom->slots_rendered = 0;
858 101 : st_ivas->hSpatParamRendCom->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME;
859 101 : set_s( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available );
860 :
861 101 : if ( ( error = ivas_omasa_dirac_td_binaural( st_ivas, (uint16_t) hTcBuffer->n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, CPE_CHANNELS, p_output ) ) != IVAS_ERR_OK )
862 : {
863 0 : return error;
864 : }
865 :
866 : /* restore original configuration */
867 101 : st_ivas->ism_mode = ism_mode_orig;
868 101 : st_ivas->renderer_type = renderer_type_orig;
869 101 : st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate;
870 : }
871 : }
872 23 : else if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
873 : {
874 23 : if ( ism_mode_old == ISM_SBA_MODE_DISC )
875 : {
876 : float *tc_local[MAX_TRANSPORT_CHANNELS];
877 : int16_t last_spar_md_idx;
878 : int16_t last_dirac_md_idx;
879 : uint16_t nSamplesAvailableNext;
880 : ISM_MODE ism_mode_orig;
881 : RENDERER_TYPE renderer_type_orig;
882 : int32_t ivas_total_brate;
883 :
884 : /* to render flushed samples, use configuration from the last received frame */
885 23 : ivas_total_brate = st_ivas->hDecoderConfig->ivas_total_brate;
886 23 : renderer_type_orig = st_ivas->renderer_type;
887 23 : ism_mode_orig = st_ivas->ism_mode;
888 23 : st_ivas->ism_mode = ism_mode_old;
889 23 : st_ivas->renderer_type = renderer_type_old;
890 23 : st_ivas->hDecoderConfig->ivas_total_brate = st_ivas->hDecoderConfig->last_ivas_total_brate;
891 23 : last_spar_md_idx = st_ivas->hSpar->render_to_md_map[st_ivas->hSpar->slots_rendered - 1];
892 23 : last_dirac_md_idx = st_ivas->hSpatParamRendCom->render_to_md_map[st_ivas->hSpatParamRendCom->slots_rendered - 1];
893 : #ifdef DEBUGGING
894 : assert( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV );
895 : #endif
896 :
897 : /* copy from ISM delay buffer to the correct place in TCs */
898 69 : for ( ch_idx = 0; ch_idx < st_ivas->nchan_ism; ch_idx++ )
899 : {
900 46 : tc_local[ch_idx] = &st_ivas->hTcBuffer->tc[ch_idx][hTcBuffer->n_samples_rendered];
901 46 : mvr2r( st_ivas->hSbaIsmData->delayBuffer[ch_idx], tc_local[ch_idx], st_ivas->hSbaIsmData->delayBuffer_size );
902 : }
903 :
904 : /* transfer adapted sf info from hTcBuffer to SPAR and DirAC */
905 23 : st_ivas->hSpar->nb_subframes = 1;
906 23 : st_ivas->hSpar->subframes_rendered = 0;
907 23 : st_ivas->hSpar->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME;
908 23 : st_ivas->hSpar->slots_rendered = 0;
909 23 : st_ivas->hSpar->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME;
910 23 : st_ivas->hSpatParamRendCom->nb_subframes = 1;
911 23 : st_ivas->hSpatParamRendCom->subframes_rendered = 0;
912 23 : st_ivas->hSpatParamRendCom->subframe_nbslots[0] = JBM_CLDFB_SLOTS_IN_SUBFRAME;
913 23 : st_ivas->hSpatParamRendCom->slots_rendered = 0;
914 23 : st_ivas->hSpatParamRendCom->num_slots = JBM_CLDFB_SLOTS_IN_SUBFRAME;
915 :
916 : /* also adapt md maps, just use the last index */
917 23 : set_s( st_ivas->hSpar->render_to_md_map, last_spar_md_idx, n_slots_still_available );
918 23 : set_s( st_ivas->hSpatParamRendCom->render_to_md_map, last_dirac_md_idx, n_slots_still_available );
919 :
920 : /* render the last subframe */
921 23 : if ( ( error = ivas_osba_dirac_td_binaural( st_ivas, (uint16_t) n_samples_granularity, nSamplesRendered, &nSamplesAvailableNext, p_output ) ) != IVAS_ERR_OK )
922 : {
923 0 : return error;
924 : }
925 :
926 : /* restore original configuration */
927 23 : st_ivas->ism_mode = ism_mode_orig;
928 23 : st_ivas->renderer_type = renderer_type_orig;
929 23 : st_ivas->hDecoderConfig->ivas_total_brate = ivas_total_brate;
930 : }
931 : }
932 : else
933 : {
934 0 : return IVAS_ERROR( IVAS_ERR_WRONG_MODE, "Wrong IVAS format in VoIP renderer flushing!" );
935 : }
936 :
937 205 : hTcBuffer->n_samples_rendered = hTcBuffer->n_samples_granularity;
938 : }
939 :
940 : /* update global combined orientation start index */
941 529 : ivas_combined_orientation_update_start_index( st_ivas->hCombinedOrientationData, *nSamplesRendered );
942 :
943 529 : *nSamplesRendered = n_samples_to_render;
944 :
945 : /* Only write out the valid data*/
946 529 : if ( is_split_rendering_enabled( st_ivas->hDecoderConfig, st_ivas->hRenderConfig ) == 0 )
947 : {
948 529 : if ( st_ivas->ivas_format != MONO_FORMAT )
949 : {
950 : #ifndef DISABLE_LIMITER
951 529 : ivas_limiter_dec( st_ivas->hLimiter, p_output, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered, st_ivas->BER_detect );
952 : #endif
953 : }
954 : }
955 :
956 529 : switch ( pcm_resolution )
957 : {
958 529 : case PCM_INT16:
959 : #ifdef DEBUGGING
960 : st_ivas->noClipping +=
961 : #endif
962 529 : ivas_syn_output( p_output, *nSamplesRendered, st_ivas->hDecoderConfig->nchan_out, (int16_t *) data );
963 529 : break;
964 0 : case PCM_FLOAT32:
965 0 : ivas_buffer_deinterleaved_to_interleaved( p_output, (float *) data, st_ivas->hDecoderConfig->nchan_out, *nSamplesRendered );
966 0 : break;
967 0 : default:
968 0 : error = IVAS_ERR_UNKNOWN;
969 0 : break;
970 : }
971 :
972 529 : return IVAS_ERR_OK;
973 : }
974 :
975 :
976 : /*--------------------------------------------------------------------------*
977 : * ivas_jbm_dec_set_discard_samples()
978 : *
979 : * Set number of samples to discard in the first subframe
980 : * if the renderer granularity changes on a bitrate change in JBM processing
981 : *--------------------------------------------------------------------------*/
982 :
983 1305 : ivas_error ivas_jbm_dec_set_discard_samples(
984 : Decoder_Struct *st_ivas /* i/o: main IVAS decoder structre */
985 : )
986 : {
987 : int16_t nMaxSlotsPerSubframe, nSlotsInFirstSubframe;
988 :
989 : /* render first frame with front zero padding and discarding those samples */
990 1305 : nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / st_ivas->hTcBuffer->n_samples_granularity;
991 1305 : nSlotsInFirstSubframe = nMaxSlotsPerSubframe - st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1];
992 :
993 1305 : if ( nSlotsInFirstSubframe > 0 )
994 : {
995 206 : st_ivas->hTcBuffer->n_samples_discard = ( nMaxSlotsPerSubframe - nSlotsInFirstSubframe ) * st_ivas->hTcBuffer->n_samples_granularity;
996 : /* set last subframes number to max to ensure correct continuation */
997 206 : st_ivas->hTcBuffer->subframe_nbslots[st_ivas->hTcBuffer->nb_subframes - 1] = nMaxSlotsPerSubframe;
998 : }
999 :
1000 1305 : return IVAS_ERR_OK;
1001 : }
1002 :
1003 :
1004 : /*--------------------------------------------------------------------------*
1005 : * ivas_dec_get_adapted_linear_interpolator()
1006 : *
1007 : * Get an interpolator that is adapted to (time scale modified) IVAS frame
1008 : *--------------------------------------------------------------------------*/
1009 :
1010 40007 : void ivas_dec_get_adapted_linear_interpolator(
1011 : const int16_t default_interp_length, /* i : default length of the (full-frame) interpolator */
1012 : const int16_t interp_length, /* i : length of the interpolator to be created */
1013 : float *interpolator /* o : the interpolator */
1014 : )
1015 : {
1016 : int16_t segment_len, idx;
1017 : float dec;
1018 : #ifdef DEBUGGING
1019 : assert( default_interp_length % 2 == 0 );
1020 : #endif
1021 :
1022 40007 : segment_len = ( default_interp_length >> 1 );
1023 40007 : dec = 1.0f / default_interp_length;
1024 :
1025 40007 : interpolator[interp_length - 1] = 1.0f;
1026 1818122 : for ( idx = interp_length - 2; idx >= segment_len; idx-- )
1027 : {
1028 1778115 : interpolator[idx] = max( 0.0f, interpolator[idx + 1] - dec );
1029 : }
1030 :
1031 40007 : if ( interpolator[idx + 1] > 0.0f )
1032 : {
1033 39954 : dec = interpolator[idx + 1] / ( segment_len + 1 );
1034 1769554 : for ( ; idx >= 0; idx-- )
1035 : {
1036 1729600 : interpolator[idx] = interpolator[idx + 1] - dec;
1037 : }
1038 : }
1039 : else
1040 : {
1041 53 : set_f( interpolator, 0.0f, idx + 1 );
1042 : }
1043 :
1044 40007 : return;
1045 : }
1046 :
1047 :
1048 : /*--------------------------------------------------------------------------*
1049 : * ivas_dec_get_adapted_subframes()
1050 : *
1051 : * Get an interpolator that is adapted to (time scale modified) IVAS frame
1052 : *--------------------------------------------------------------------------*/
1053 :
1054 605841 : void ivas_dec_get_adapted_subframes(
1055 : const int16_t nCldfbTs, /* i : number of time slots in the current frame */
1056 : int16_t *subframe_nbslots, /* i/o: subframe grid */
1057 : int16_t *nb_subframes /* i/o: number of subframes in the frame */
1058 : )
1059 : {
1060 : uint16_t nSlotsInLastSubframe, nSlotsInFirstSubframe;
1061 605841 : uint16_t nCldfbSlotsLocal = nCldfbTs;
1062 :
1063 : /* get last subframe size from previous frame, determine how many slots have to be processed
1064 : in the first subframe (i.e. potential leftover of a 5ms subframe) */
1065 605841 : nSlotsInFirstSubframe = ( PARAM_MC_MAX_NSLOTS_IN_SUBFRAME - subframe_nbslots[*nb_subframes - 1] );
1066 605841 : *nb_subframes = 0;
1067 605841 : if ( nSlotsInFirstSubframe > 0 )
1068 : {
1069 44482 : *nb_subframes = 1;
1070 44482 : nCldfbSlotsLocal -= nSlotsInFirstSubframe;
1071 : }
1072 :
1073 605841 : *nb_subframes += (int16_t) ceilf( (float) nCldfbSlotsLocal / (float) PARAM_MC_MAX_NSLOTS_IN_SUBFRAME );
1074 605841 : nSlotsInLastSubframe = nCldfbSlotsLocal % PARAM_MC_MAX_NSLOTS_IN_SUBFRAME;
1075 :
1076 605841 : set_s( subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS );
1077 605841 : set_s( subframe_nbslots, PARAM_MC_MAX_NSLOTS_IN_SUBFRAME, *nb_subframes );
1078 :
1079 605841 : if ( nSlotsInFirstSubframe > 0 )
1080 : {
1081 44482 : subframe_nbslots[0] = nSlotsInFirstSubframe;
1082 : }
1083 :
1084 605841 : if ( nSlotsInLastSubframe > 0 )
1085 : {
1086 44670 : subframe_nbslots[*nb_subframes - 1] = nSlotsInLastSubframe;
1087 : }
1088 :
1089 605841 : return;
1090 : }
1091 :
1092 :
1093 : /*--------------------------------------------------------------------------*
1094 : * ivas_dec_get_md_map()
1095 : *
1096 : * Get an meta data map adapted to (time scale modified) IVAS frame
1097 : *--------------------------------------------------------------------------*/
1098 :
1099 496125 : void ivas_dec_get_md_map(
1100 : const int16_t default_len, /* i : default frame length in metadata slots */
1101 : const int16_t len, /* i : length of the modified frames in metadata slots */
1102 : const int16_t subframe_len, /* i : default length of a subframe */
1103 : const int16_t offset, /* i : current read offset into the MD buffer */
1104 : const int16_t buf_len, /* i : length of the metadata buffer */
1105 : int16_t *map /* o : metadata index map */
1106 : )
1107 : {
1108 : int16_t jbm_segment_len, map_idx, src_idx, src_idx_map;
1109 : float dec, src_idx_f;
1110 :
1111 : #ifdef DEBUGGING
1112 : assert( default_len % 2 == 0 );
1113 : #endif
1114 496125 : jbm_segment_len = ( default_len >> 1 );
1115 496125 : dec = 1.0f / default_len;
1116 :
1117 4473099 : for ( map_idx = len - 1, src_idx = default_len - 1; map_idx >= jbm_segment_len; map_idx--, src_idx-- )
1118 : {
1119 3976974 : src_idx_map = max( 0, src_idx / subframe_len );
1120 3976974 : map[map_idx] = ( offset + src_idx_map ) % buf_len;
1121 : }
1122 :
1123 : /* changed part (first segment), interpolate index to parameters
1124 : (we do not want to interpolate and smooth acutal direction/diffuseness values even more) */
1125 496125 : if ( src_idx >= 0 )
1126 : {
1127 495638 : dec = ( (float) ( src_idx + 1 ) ) / ( (float) jbm_segment_len );
1128 495638 : src_idx_f = (float) ( src_idx + 1 ) - dec;
1129 4460742 : for ( ; map_idx >= 0; map_idx-- )
1130 : {
1131 3965104 : src_idx = max( 0, ( (int16_t) round_f( src_idx_f ) ) / subframe_len );
1132 3965104 : map[map_idx] = ( offset + src_idx ) % buf_len;
1133 3965104 : src_idx_f -= dec;
1134 : }
1135 : }
1136 : else
1137 : {
1138 487 : set_s( map, offset, map_idx + 1 );
1139 : }
1140 :
1141 496125 : return;
1142 : }
1143 :
1144 :
1145 : /*--------------------------------------------------------------------------*
1146 : * ivas_dec_get_md_map_even_spacing()
1147 : *
1148 : * Get an meta data map adapted to (time scale modified) IVAS frame.
1149 : * Distribute slots evenly across the (modified) frame.
1150 : *--------------------------------------------------------------------------*/
1151 :
1152 97021 : void ivas_dec_get_md_map_even_spacing(
1153 : const int16_t len, /* i : length of the modified frames in metadata slots */
1154 : const int16_t subframe_len, /* i : default length of a subframe */
1155 : const int16_t offset, /* i : current read offset into the MD buffer */
1156 : const int16_t buf_len, /* i : length of the metadata buffer */
1157 : int16_t *map /* o : metadata index map */
1158 : )
1159 : {
1160 : int16_t map_idx, sf_idx, sf_length, increment, subframes_written;
1161 : float decimal, decimal_sum, eps;
1162 : int16_t subframe_map_length[MAX_PARAM_SPATIAL_SUBFRAMES];
1163 :
1164 : /* subframe map length */
1165 97021 : sf_length = len / subframe_len;
1166 97021 : if ( len % subframe_len == 0 )
1167 : {
1168 : /* even subframes */
1169 484335 : for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
1170 : {
1171 387468 : subframe_map_length[sf_idx] = sf_length;
1172 : }
1173 : }
1174 : else
1175 : {
1176 : /* uneven subframes */
1177 154 : decimal = ( (float) len / (float) subframe_len ) - (float) sf_length;
1178 154 : decimal_sum = decimal;
1179 154 : eps = 0.001f;
1180 770 : for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
1181 : {
1182 616 : increment = (int16_t) floorf( decimal_sum + eps );
1183 616 : subframe_map_length[sf_idx] = sf_length + increment;
1184 616 : if ( increment > 0 )
1185 : {
1186 361 : decimal_sum -= 1.0f;
1187 : }
1188 616 : decimal_sum += decimal;
1189 : }
1190 : }
1191 :
1192 : /* map slots to subframes */
1193 97021 : sf_idx = 0;
1194 97021 : subframes_written = 0;
1195 1650966 : for ( map_idx = 0; map_idx < len; map_idx++ )
1196 : {
1197 1553945 : map[map_idx] = ( offset + sf_idx ) % buf_len;
1198 1553945 : if ( map_idx - subframes_written >= subframe_map_length[sf_idx] - 1 )
1199 : {
1200 388084 : subframes_written += subframe_map_length[sf_idx];
1201 388084 : ++sf_idx;
1202 : }
1203 : }
1204 :
1205 97021 : return;
1206 : }
1207 :
1208 :
1209 : /*--------------------------------------------------------------------------*
1210 : * ivas_dec_get_render_granularity()
1211 : *
1212 : * Get renderer granularity
1213 : *--------------------------------------------------------------------------*/
1214 :
1215 : /*! r: render granularity */
1216 15878 : int16_t ivas_dec_get_render_granularity(
1217 : const RENDERER_TYPE renderer_type, /* i : renderer type */
1218 : const RENDERER_TYPE renderer_type_sec, /* i : secondary renderer type */
1219 : const int32_t output_Fs /* i : sampling rate */
1220 : )
1221 : {
1222 : int16_t render_granularity;
1223 :
1224 15878 : if ( renderer_type == RENDERER_BINAURAL_OBJECTS_TD || /* TD renderer */
1225 14992 : renderer_type == RENDERER_BINAURAL_MIXER_CONV || renderer_type == RENDERER_BINAURAL_MIXER_CONV_ROOM || /* Crend */
1226 : renderer_type_sec == RENDERER_BINAURAL_OBJECTS_TD /* TD rend as a secondary renderer -> set the common granularity for both renderers */
1227 : )
1228 : {
1229 : /* 5 ms granularity */
1230 2841 : render_granularity = NS2SA( output_Fs, FRAME_SIZE_NS / MAX_PARAM_SPATIAL_SUBFRAMES );
1231 : }
1232 : else
1233 : {
1234 : /* 1.25 ms granularity */
1235 13037 : render_granularity = NS2SA( output_Fs, CLDFB_SLOT_NS );
1236 : }
1237 :
1238 15878 : return render_granularity;
1239 : }
1240 :
1241 :
1242 : /*--------------------------------------------------------------------------*
1243 : * ivas_dec_tc_buffer_playout()
1244 : *
1245 : * Get TC buffer playout
1246 : *--------------------------------------------------------------------------*/
1247 :
1248 153896 : static void ivas_dec_tc_buffer_playout(
1249 : Decoder_Struct *st_ivas,
1250 : const uint16_t nSamplesAsked,
1251 : uint16_t *nSamplesRendered,
1252 : float *output[] )
1253 : {
1254 : int16_t ch_idx, slot_size, slots_to_render, first_sf, last_sf;
1255 : DECODER_TC_BUFFER_HANDLE hTcBuffer;
1256 :
1257 153896 : hTcBuffer = st_ivas->hTcBuffer;
1258 153896 : slot_size = hTcBuffer->n_samples_granularity;
1259 :
1260 : /* loop for synthesis, assume we always have to render in multiples of 5ms subframes with spills */
1261 153896 : slots_to_render = min( hTcBuffer->num_slots - hTcBuffer->slots_rendered, nSamplesAsked / slot_size );
1262 153896 : hTcBuffer->slots_rendered += slots_to_render;
1263 153896 : *nSamplesRendered = (uint16_t) slots_to_render * slot_size;
1264 153896 : first_sf = hTcBuffer->subframes_rendered;
1265 153896 : last_sf = first_sf;
1266 :
1267 756368 : while ( slots_to_render > 0 )
1268 : {
1269 602472 : slots_to_render -= hTcBuffer->subframe_nbslots[last_sf];
1270 602472 : last_sf++;
1271 : }
1272 : #ifdef DEBUGGING
1273 : assert( slots_to_render == 0 );
1274 : #endif
1275 :
1276 460670 : for ( ch_idx = 0; ch_idx < hTcBuffer->nchan_transport_rend; ch_idx++ )
1277 : {
1278 306774 : output[ch_idx] = st_ivas->hTcBuffer->tc[ch_idx] + st_ivas->hTcBuffer->n_samples_rendered;
1279 : }
1280 :
1281 153896 : hTcBuffer->subframes_rendered = last_sf;
1282 :
1283 153896 : return;
1284 : }
1285 :
1286 :
1287 : /*--------------------------------------------------------------------------*
1288 : * ivas_dec_td_renderers_adapt_subframes()
1289 : *
1290 : * Adapt subframes for TD renderers
1291 : *--------------------------------------------------------------------------*/
1292 :
1293 391637 : void ivas_dec_td_renderers_adapt_subframes(
1294 : Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
1295 : )
1296 : {
1297 : int16_t nMaxSlotsPerSubframe, nSlotsAvailable;
1298 : uint16_t nSlotsInLastSubframe, nSlotsInFirstSubframe;
1299 : DECODER_TC_BUFFER_HANDLE hTcBuffer;
1300 :
1301 391637 : hTcBuffer = st_ivas->hTcBuffer;
1302 :
1303 391637 : nMaxSlotsPerSubframe = (int16_t) ( st_ivas->hDecoderConfig->output_Fs / ( FRAMES_PER_SEC * MAX_PARAM_SPATIAL_SUBFRAMES ) ) / hTcBuffer->n_samples_granularity;
1304 391637 : nSlotsAvailable = hTcBuffer->n_samples_available / hTcBuffer->n_samples_granularity;
1305 391637 : hTcBuffer->num_slots = nSlotsAvailable;
1306 391637 : hTcBuffer->n_samples_available = nSlotsAvailable * hTcBuffer->n_samples_granularity;
1307 391637 : nSlotsInFirstSubframe = nMaxSlotsPerSubframe - hTcBuffer->subframe_nbslots[hTcBuffer->nb_subframes - 1];
1308 391637 : hTcBuffer->nb_subframes = 0;
1309 :
1310 391637 : if ( nSlotsInFirstSubframe > 0 )
1311 : {
1312 10044 : hTcBuffer->nb_subframes = 1;
1313 10044 : nSlotsAvailable -= nSlotsInFirstSubframe;
1314 : }
1315 391637 : hTcBuffer->nb_subframes += (int16_t) ceilf( (float) nSlotsAvailable / (float) nMaxSlotsPerSubframe );
1316 391637 : nSlotsInLastSubframe = nSlotsAvailable % nMaxSlotsPerSubframe;
1317 391637 : set_s( hTcBuffer->subframe_nbslots, 0, MAX_JBM_SUBFRAMES_5MS );
1318 391637 : set_s( hTcBuffer->subframe_nbslots, nMaxSlotsPerSubframe, hTcBuffer->nb_subframes );
1319 :
1320 391637 : if ( nSlotsInFirstSubframe > 0 )
1321 : {
1322 10044 : hTcBuffer->subframe_nbslots[0] = nSlotsInFirstSubframe;
1323 : }
1324 :
1325 391637 : if ( nSlotsInLastSubframe > 0 )
1326 : {
1327 10069 : hTcBuffer->subframe_nbslots[hTcBuffer->nb_subframes - 1] = nSlotsInLastSubframe;
1328 : }
1329 :
1330 391637 : hTcBuffer->slots_rendered = 0;
1331 391637 : hTcBuffer->subframes_rendered = 0;
1332 :
1333 391637 : return;
1334 : }
1335 :
1336 :
1337 : /*--------------------------------------------------------------------------*
1338 : * ivas_jbm_dec_masa_metadata_open()
1339 : *
1340 : * Open structure for MASA metadata buffering in JBM processing
1341 : *--------------------------------------------------------------------------*/
1342 :
1343 3 : ivas_error ivas_jbm_dec_masa_metadata_open(
1344 : Decoder_Struct *st_ivas )
1345 : {
1346 : JBM_METADATA_HANDLE hJbmMetadata;
1347 :
1348 3 : if ( ( hJbmMetadata = (JBM_METADATA_HANDLE) malloc( sizeof( JBM_METADATA ) ) ) == NULL )
1349 : {
1350 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for JBM metadata handle\n" ) );
1351 : }
1352 :
1353 3 : hJbmMetadata->sf_write_idx = 0;
1354 3 : hJbmMetadata->sf_md_buffer_length = MASA_JBM_RINGBUFFER_FRAMES * MAX_PARAM_SPATIAL_SUBFRAMES;
1355 :
1356 3 : hJbmMetadata->slot_write_idx = 0;
1357 3 : hJbmMetadata->slot_read_idx = 0;
1358 3 : hJbmMetadata->slot_md_buffer_length = MASA_JBM_RINGBUFFER_FRAMES * MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME;
1359 :
1360 3 : st_ivas->hJbmMetadata = hJbmMetadata;
1361 :
1362 3 : return IVAS_ERR_OK;
1363 : }
1364 :
1365 :
1366 : /*--------------------------------------------------------------------------*
1367 : * ivas_jbm_dec_copy_masa_meta_to_buffer()
1368 : *
1369 : * Copy decoded MASA metadata to a ring buffer in JBM processing
1370 : *--------------------------------------------------------------------------*/
1371 :
1372 3012 : static void ivas_jbm_dec_copy_masa_meta_to_buffer(
1373 : Decoder_Struct *st_ivas )
1374 : {
1375 : int16_t sf, dir, band;
1376 : JBM_METADATA_HANDLE hJbmMetadata;
1377 : MASA_DECODER_EXT_OUT_META *extOutMeta;
1378 : int16_t write_idx;
1379 :
1380 3012 : hJbmMetadata = st_ivas->hJbmMetadata;
1381 3012 : extOutMeta = st_ivas->hMasa->data.extOutMeta;
1382 :
1383 15060 : for ( sf = 0; sf < MAX_PARAM_SPATIAL_SUBFRAMES; sf++ )
1384 : {
1385 12048 : write_idx = ( hJbmMetadata->sf_write_idx + sf ) % hJbmMetadata->sf_md_buffer_length;
1386 :
1387 36144 : for ( dir = 0; dir < MASA_MAXIMUM_DIRECTIONS; dir++ )
1388 : {
1389 602400 : for ( band = 0; band < MASA_FREQUENCY_BANDS; band++ )
1390 : {
1391 578304 : hJbmMetadata->directionIndexBuffer[dir][write_idx][band] = extOutMeta->directionIndex[dir][sf][band];
1392 578304 : hJbmMetadata->directToTotalRatioBuffer[dir][write_idx][band] = extOutMeta->directToTotalRatio[dir][sf][band];
1393 578304 : hJbmMetadata->spreadCoherenceBuffer[dir][write_idx][band] = extOutMeta->spreadCoherence[dir][sf][band];
1394 : }
1395 : }
1396 :
1397 301200 : for ( band = 0; band < MASA_FREQUENCY_BANDS; band++ )
1398 : {
1399 289152 : hJbmMetadata->diffuseToTotalRatioBuffer[write_idx][band] = extOutMeta->diffuseToTotalRatio[sf][band];
1400 289152 : hJbmMetadata->surroundCoherenceBuffer[write_idx][band] = extOutMeta->surroundCoherence[sf][band];
1401 : }
1402 :
1403 12048 : hJbmMetadata->numberOfDirections[write_idx] = extOutMeta->descriptiveMeta.numberOfDirections;
1404 : }
1405 :
1406 3012 : return;
1407 : }
1408 :
1409 :
1410 : /*--------------------------------------------------------------------------*
1411 : * ivas_jbm_masa_sf_to_slot_map()
1412 : *
1413 : * Map input MASA metadata subframes to slots in JBM processing
1414 : *--------------------------------------------------------------------------*/
1415 :
1416 3012 : static void ivas_jbm_masa_sf_to_slot_map(
1417 : Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
1418 : const int16_t nCldfbTs /* i : number of CLDFB time slots */
1419 : )
1420 : {
1421 : int16_t sf_to_slot_map[MAX_JBM_SUBFRAMES_5MS * JBM_CLDFB_SLOTS_IN_SUBFRAME];
1422 : int16_t num_slots_in_subfr;
1423 : JBM_METADATA_HANDLE hJbmMetadata;
1424 : int16_t slot_idx;
1425 : int16_t write_idx, sf_index;
1426 :
1427 3012 : ivas_jbm_dec_copy_masa_meta_to_buffer( st_ivas );
1428 :
1429 : /* Set values */
1430 3012 : hJbmMetadata = st_ivas->hJbmMetadata;
1431 3012 : num_slots_in_subfr = CLDFB_NO_COL_MAX / MAX_PARAM_SPATIAL_SUBFRAMES;
1432 :
1433 : /* Map input subframes to slots */
1434 3012 : ivas_dec_get_md_map_even_spacing( nCldfbTs, num_slots_in_subfr, 0, MAX_PARAM_SPATIAL_SUBFRAMES, sf_to_slot_map );
1435 :
1436 51227 : for ( slot_idx = 0; slot_idx < nCldfbTs; slot_idx++ )
1437 : {
1438 48215 : write_idx = ( hJbmMetadata->slot_write_idx + slot_idx ) % hJbmMetadata->slot_md_buffer_length;
1439 48215 : sf_index = ( hJbmMetadata->sf_write_idx + sf_to_slot_map[slot_idx] ) % hJbmMetadata->sf_md_buffer_length;
1440 :
1441 48215 : hJbmMetadata->sf_to_slot_map[write_idx] = sf_index;
1442 : }
1443 :
1444 3012 : hJbmMetadata->sf_write_idx = ( hJbmMetadata->sf_write_idx + MAX_PARAM_SPATIAL_SUBFRAMES ) % hJbmMetadata->sf_md_buffer_length;
1445 3012 : hJbmMetadata->slot_write_idx = ( hJbmMetadata->slot_write_idx + nCldfbTs ) % hJbmMetadata->slot_md_buffer_length;
1446 :
1447 3012 : return;
1448 : }
1449 :
1450 :
1451 : /*--------------------------------------------------------------------------*
1452 : * ivas_jbm_masa_sf_to_sf_map()
1453 : *
1454 : * Map input MASA metadata subframes to output subframes in JBM processing
1455 : *--------------------------------------------------------------------------*/
1456 :
1457 3012 : void ivas_jbm_masa_sf_to_sf_map(
1458 : Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
1459 : )
1460 : {
1461 : int16_t sf_to_sf_map[MAX_PARAM_SPATIAL_SUBFRAMES];
1462 : JBM_METADATA_HANDLE hJbmMetadata;
1463 : MASA_DECODER_EXT_OUT_META *extOutMeta;
1464 : int16_t slot_read_idx, sf_read_idx;
1465 : int16_t sf_idx;
1466 : int16_t dir, band;
1467 : uint8_t numberOfDirections;
1468 :
1469 : /* Set values */
1470 3012 : hJbmMetadata = st_ivas->hJbmMetadata;
1471 3012 : extOutMeta = st_ivas->hMasa->data.extOutMeta;
1472 :
1473 : /* Map slots to subframes */
1474 15060 : for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
1475 : {
1476 12048 : slot_read_idx = ( hJbmMetadata->slot_read_idx + 2 ) % hJbmMetadata->slot_md_buffer_length; /* Take the latter one of the middle slots of the output subframe */
1477 12048 : sf_to_sf_map[sf_idx] = hJbmMetadata->sf_to_slot_map[slot_read_idx];
1478 12048 : hJbmMetadata->slot_read_idx = ( hJbmMetadata->slot_read_idx + CLDFB_SLOTS_PER_SUBFRAME ) % hJbmMetadata->slot_md_buffer_length;
1479 : }
1480 :
1481 : /* Copy mapped metadata to the EXT meta buffer for writing */
1482 15060 : for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
1483 : {
1484 12048 : sf_read_idx = sf_to_sf_map[sf_idx];
1485 :
1486 36144 : for ( dir = 0; dir < MASA_MAXIMUM_DIRECTIONS; dir++ )
1487 : {
1488 602400 : for ( band = 0; band < MASA_FREQUENCY_BANDS; band++ )
1489 : {
1490 578304 : extOutMeta->directionIndex[dir][sf_idx][band] = hJbmMetadata->directionIndexBuffer[dir][sf_read_idx][band];
1491 578304 : extOutMeta->directToTotalRatio[dir][sf_idx][band] = hJbmMetadata->directToTotalRatioBuffer[dir][sf_read_idx][band];
1492 578304 : extOutMeta->spreadCoherence[dir][sf_idx][band] = hJbmMetadata->spreadCoherenceBuffer[dir][sf_read_idx][band];
1493 : }
1494 : }
1495 :
1496 301200 : for ( band = 0; band < MASA_FREQUENCY_BANDS; band++ )
1497 : {
1498 289152 : extOutMeta->diffuseToTotalRatio[sf_idx][band] = hJbmMetadata->diffuseToTotalRatioBuffer[sf_read_idx][band];
1499 289152 : extOutMeta->surroundCoherence[sf_idx][band] = hJbmMetadata->surroundCoherenceBuffer[sf_read_idx][band];
1500 : }
1501 : }
1502 :
1503 : /* Determine the number of directions for the frame to be written */
1504 3012 : numberOfDirections = 0;
1505 12344 : for ( sf_idx = 0; sf_idx < MAX_PARAM_SPATIAL_SUBFRAMES; sf_idx++ )
1506 : {
1507 10050 : sf_read_idx = sf_to_sf_map[sf_idx];
1508 :
1509 10050 : if ( hJbmMetadata->numberOfDirections[sf_read_idx] == 1 )
1510 : {
1511 718 : numberOfDirections = 1;
1512 718 : break;
1513 : }
1514 : }
1515 :
1516 3012 : extOutMeta->descriptiveMeta.numberOfDirections = numberOfDirections;
1517 :
1518 3012 : return;
1519 : }
1520 :
1521 :
1522 : /*--------------------------------------------------------------------------*
1523 : * ivas_dec_prepare_renderer()
1524 : *
1525 : * Prepare IVAS renderer routine
1526 : *--------------------------------------------------------------------------*/
1527 :
1528 716075 : void ivas_dec_prepare_renderer(
1529 : Decoder_Struct *st_ivas /* i/o: IVAS decoder structure */
1530 : )
1531 : {
1532 : int16_t n, n_render_timeslots, n_samples_available;
1533 : AUDIO_CONFIG output_config;
1534 : DECODER_TC_BUFFER_HANDLE hTcBuffer;
1535 :
1536 716075 : push_wmops( "ivas_dec_prepare_renderer" );
1537 :
1538 716075 : output_config = st_ivas->hDecoderConfig->output_config;
1539 716075 : hTcBuffer = st_ivas->hTcBuffer;
1540 716075 : n_samples_available = hTcBuffer->n_samples_available;
1541 716075 : n_render_timeslots = n_samples_available / hTcBuffer->n_samples_granularity;
1542 :
1543 716075 : if ( hTcBuffer->tc_buffer_mode == TC_BUFFER_MODE_BUFFER )
1544 : {
1545 149687 : ivas_dec_td_renderers_adapt_subframes( st_ivas );
1546 :
1547 149687 : if ( ( st_ivas->ivas_format == MASA_FORMAT || st_ivas->ivas_format == MASA_ISM_FORMAT ) && output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->hDecoderConfig->Opt_tsm )
1548 : {
1549 3012 : ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots );
1550 : }
1551 :
1552 : /* MASA transport gaining for edited disc OMASA EXT. For ISMs, only metadata is modified */
1553 149687 : if ( st_ivas->ivas_format == MASA_ISM_FORMAT && st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->hMasaIsmData->masa_gain_is_edited == 1 )
1554 : {
1555 0 : ivas_omasa_gain_masa_tc( st_ivas->hTcBuffer->tc, st_ivas->hMasaIsmData->gain_masa_edited, st_ivas->nchan_ism, st_ivas->hTcBuffer->n_samples_available );
1556 : }
1557 : }
1558 566388 : else if ( st_ivas->ivas_format == MONO_FORMAT || st_ivas->ivas_format == STEREO_FORMAT )
1559 : {
1560 2054 : ivas_dec_td_renderers_adapt_subframes( st_ivas );
1561 : }
1562 564334 : else if ( st_ivas->ivas_format == ISM_FORMAT )
1563 : {
1564 88762 : if ( st_ivas->ism_mode == ISM_MODE_PARAM )
1565 : {
1566 18013 : if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC )
1567 : {
1568 11255 : ivas_dirac_dec_set_md_map( st_ivas, n_render_timeslots );
1569 11255 : ivas_param_ism_params_to_masa_param_mapping( st_ivas );
1570 : }
1571 6758 : else if ( st_ivas->renderer_type == RENDERER_PARAM_ISM || st_ivas->renderer_type == RENDERER_SBA_LINEAR_ENC )
1572 : {
1573 6758 : ivas_param_ism_dec_prepare_renderer( st_ivas, n_render_timeslots );
1574 : }
1575 : }
1576 : else /* ISM_MODE_DISC */
1577 : {
1578 70749 : ivas_ism_dec_digest_tc( st_ivas );
1579 : }
1580 : }
1581 475572 : else if ( st_ivas->ivas_format == SBA_FORMAT || st_ivas->ivas_format == MASA_FORMAT )
1582 : {
1583 256456 : ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, n_samples_available );
1584 : }
1585 219116 : else if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
1586 : {
1587 68543 : if ( st_ivas->ism_mode == ISM_SBA_MODE_DISC )
1588 : {
1589 55618 : ivas_ism_dec_digest_tc( st_ivas );
1590 :
1591 : /* delay the objects here for all renderers where it is needed */
1592 55618 : if ( ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV ||
1593 11804 : st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV_ROOM ||
1594 7804 : st_ivas->renderer_type == RENDERER_OSBA_AMBI ||
1595 5800 : st_ivas->renderer_type == RENDERER_OSBA_LS ||
1596 54218 : output_config == IVAS_AUDIO_CONFIG_EXTERNAL ) &&
1597 20082 : ( output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ) )
1598 : {
1599 82046 : for ( n = 0; n < st_ivas->nchan_ism; n++ )
1600 : {
1601 61964 : delay_signal( hTcBuffer->tc[n], n_samples_available, st_ivas->hSbaIsmData->delayBuffer[n], st_ivas->hSbaIsmData->delayBuffer_size );
1602 : }
1603 : }
1604 :
1605 55618 : if ( !st_ivas->sba_dirac_stereo_flag )
1606 : {
1607 54218 : if ( st_ivas->renderer_type == RENDERER_BINAURAL_FASTCONV )
1608 : {
1609 43814 : n_render_timeslots *= ( hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size );
1610 : }
1611 :
1612 54218 : ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, n_samples_available );
1613 : }
1614 : }
1615 : else
1616 : {
1617 12925 : ivas_dec_td_renderers_adapt_subframes( st_ivas );
1618 :
1619 12925 : ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, n_samples_available );
1620 : }
1621 : }
1622 150573 : else if ( st_ivas->ivas_format == MASA_ISM_FORMAT )
1623 : {
1624 54619 : if ( st_ivas->renderer_type == RENDERER_OMASA_MIX_EXT || st_ivas->renderer_type == RENDERER_OMASA_OBJECT_EXT )
1625 : {
1626 502 : ivas_dec_td_renderers_adapt_subframes( st_ivas );
1627 :
1628 502 : if ( st_ivas->hDecoderConfig->Opt_tsm )
1629 : {
1630 0 : ivas_jbm_masa_sf_to_slot_map( st_ivas, n_render_timeslots );
1631 : }
1632 :
1633 : /* MASA transport gaining for edited param_one OMASA EXT. For ISMs, only metadata is modified. */
1634 502 : if ( st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ && st_ivas->hMasaIsmData->masa_gain_is_edited == 1 )
1635 : {
1636 0 : for ( n = 0; n < CPE_CHANNELS; n++ )
1637 : {
1638 0 : v_multc( st_ivas->hTcBuffer->tc[n], st_ivas->hMasaIsmData->gain_masa_edited, st_ivas->hTcBuffer->tc[n], st_ivas->hTcBuffer->n_samples_available );
1639 : }
1640 : }
1641 : }
1642 : else
1643 : {
1644 54117 : if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC && st_ivas->ism_mode == ISM_MASA_MODE_DISC )
1645 : {
1646 23193 : n_render_timeslots *= ( hTcBuffer->n_samples_granularity / st_ivas->hSpatParamRendCom->slot_size );
1647 : }
1648 :
1649 54117 : ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, n_samples_available );
1650 :
1651 54117 : if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC )
1652 : {
1653 29043 : ivas_ism_dec_digest_tc( st_ivas );
1654 : }
1655 :
1656 54117 : if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_DIRAC )
1657 : {
1658 : int16_t nchan_transport_ism;
1659 :
1660 : /* Delay the signal to match CLDFB delay. Delay the whole buffer. */
1661 44347 : nchan_transport_ism = 0;
1662 44347 : if ( ( st_ivas->ism_mode == ISM_MASA_MODE_MASA_ONE_OBJ || st_ivas->ism_mode == ISM_MASA_MODE_PARAM_ONE_OBJ ) && st_ivas->renderer_type != RENDERER_BINAURAL_PARAMETRIC )
1663 : {
1664 4808 : nchan_transport_ism = 1;
1665 : }
1666 39539 : else if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC )
1667 : {
1668 25786 : nchan_transport_ism = st_ivas->nchan_ism;
1669 : }
1670 :
1671 44347 : if ( st_ivas->hDecoderConfig->Opt_tsm && st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_DIRAC )
1672 : {
1673 : /* Gain MASA part, if edited */
1674 1670 : if ( st_ivas->hMasaIsmData->masa_gain_is_edited )
1675 : {
1676 2856 : for ( n = 0; n < CPE_CHANNELS; n++ )
1677 : {
1678 1904 : v_multc( st_ivas->hTcBuffer->tc[n], st_ivas->hMasaIsmData->gain_masa_edited, st_ivas->hTcBuffer->tc[n], st_ivas->hTcBuffer->n_samples_available );
1679 : }
1680 : }
1681 : }
1682 :
1683 101120 : for ( n = 0; n < nchan_transport_ism; n++ )
1684 : {
1685 56773 : if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC )
1686 : {
1687 : float gainIsm;
1688 45646 : gainIsm = OMASA_TDREND_MATCHING_GAIN;
1689 :
1690 45646 : if ( st_ivas->hMasaIsmData->ism_gain_is_edited[n] )
1691 : {
1692 4445 : gainIsm *= st_ivas->hMasaIsmData->gain_ism_edited[n];
1693 : }
1694 :
1695 45646 : v_multc( hTcBuffer->tc[CPE_CHANNELS + n], gainIsm, hTcBuffer->tc[CPE_CHANNELS + n], n_samples_available );
1696 : }
1697 :
1698 56773 : if ( output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED && output_config != IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
1699 : {
1700 19559 : delay_signal( hTcBuffer->tc[CPE_CHANNELS + n], n_samples_available, st_ivas->hMasaIsmData->delayBuffer[n], st_ivas->hMasaIsmData->delayBuffer_size );
1701 : }
1702 : }
1703 :
1704 44347 : if ( st_ivas->ism_mode == ISM_MASA_MODE_DISC && st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC )
1705 : {
1706 : int16_t tcBufferSize;
1707 23193 : tcBufferSize = st_ivas->hSpatParamRendCom->num_slots * st_ivas->hSpatParamRendCom->slot_size;
1708 :
1709 23193 : if ( st_ivas->hMasaIsmData->masa_gain_is_edited )
1710 : {
1711 3795 : for ( n = 0; n < BINAURAL_CHANNELS; n++ )
1712 : {
1713 2530 : v_multc( hTcBuffer->tc[n], st_ivas->hMasaIsmData->gain_masa_edited, hTcBuffer->tc[n], tcBufferSize );
1714 : }
1715 : }
1716 : }
1717 : }
1718 : }
1719 : }
1720 95954 : else if ( st_ivas->ivas_format == MC_FORMAT )
1721 : {
1722 95954 : if ( st_ivas->mc_mode == MC_MODE_MCT )
1723 : {
1724 65145 : ivas_dec_td_renderers_adapt_subframes( st_ivas );
1725 : }
1726 30809 : else if ( st_ivas->mc_mode == MC_MODE_PARAMUPMIX )
1727 : {
1728 5914 : ivas_mc_paramupmix_dec_digest_tc( st_ivas, (uint8_t) n_render_timeslots, n_samples_available );
1729 : }
1730 24895 : else if ( st_ivas->mc_mode == MC_MODE_PARAMMC )
1731 : {
1732 15707 : ivas_param_mc_dec_prepare_renderer( st_ivas, (uint8_t) n_render_timeslots );
1733 : }
1734 9188 : else if ( st_ivas->mc_mode == MC_MODE_MCMASA )
1735 : {
1736 9188 : ivas_sba_dec_digest_tc( st_ivas, n_render_timeslots, n_samples_available );
1737 : }
1738 : }
1739 :
1740 716075 : pop_wmops();
1741 716075 : return;
1742 : }
|