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 "ivas_cnst.h"
36 : #include "prot.h"
37 : #include "ivas_prot_rend.h"
38 : #include "ivas_rom_com.h"
39 : #include "ivas_prot.h"
40 : #include <string.h>
41 : #ifdef DEBUGGING
42 : #include "debug.h"
43 : #include <assert.h>
44 : #endif
45 : #include "wmc_auto.h"
46 :
47 : /*-------------------------------------------------------------------------*
48 : * audioCfg2channels()
49 : *
50 : * Map Audio configuration to number of channels
51 : *-------------------------------------------------------------------------*/
52 :
53 : /*! r: number of audio channels */
54 32517021 : int16_t audioCfg2channels(
55 : AUDIO_CONFIG output_config /* i : output audio configuration */
56 : )
57 : {
58 : int16_t nchan_out;
59 :
60 32517021 : switch ( output_config )
61 : {
62 501680 : case IVAS_AUDIO_CONFIG_MONO:
63 501680 : nchan_out = 1;
64 501680 : break;
65 873106 : case IVAS_AUDIO_CONFIG_STEREO:
66 873106 : nchan_out = 2;
67 873106 : break;
68 3647993 : case IVAS_AUDIO_CONFIG_5_1:
69 3647993 : nchan_out = 6;
70 3647993 : break;
71 592149 : case IVAS_AUDIO_CONFIG_7_1:
72 592149 : nchan_out = 8;
73 592149 : break;
74 188070 : case IVAS_AUDIO_CONFIG_5_1_2:
75 188070 : nchan_out = 8;
76 188070 : break;
77 293496 : case IVAS_AUDIO_CONFIG_5_1_4:
78 293496 : nchan_out = 10;
79 293496 : break;
80 3711760 : case IVAS_AUDIO_CONFIG_7_1_4:
81 3711760 : nchan_out = 12;
82 3711760 : break;
83 5607788 : case IVAS_AUDIO_CONFIG_FOA:
84 5607788 : nchan_out = 4;
85 5607788 : break;
86 970544 : case IVAS_AUDIO_CONFIG_HOA2:
87 970544 : nchan_out = 9;
88 970544 : break;
89 6823559 : case IVAS_AUDIO_CONFIG_HOA3:
90 6823559 : nchan_out = 16;
91 6823559 : break;
92 0 : case IVAS_AUDIO_CONFIG_OBA:
93 0 : nchan_out = 8;
94 0 : break;
95 6872931 : case IVAS_AUDIO_CONFIG_BINAURAL:
96 : case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED:
97 : case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM:
98 : case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR:
99 : case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB:
100 6872931 : nchan_out = 2;
101 6872931 : break;
102 746727 : case IVAS_AUDIO_CONFIG_ISM1:
103 746727 : nchan_out = 1;
104 746727 : break;
105 200658 : case IVAS_AUDIO_CONFIG_ISM2:
106 200658 : nchan_out = 2;
107 200658 : break;
108 321186 : case IVAS_AUDIO_CONFIG_ISM3:
109 321186 : nchan_out = 3;
110 321186 : break;
111 1165374 : case IVAS_AUDIO_CONFIG_ISM4:
112 1165374 : nchan_out = 4;
113 1165374 : break;
114 0 : default:
115 0 : IVAS_ERROR( IVAS_ERR_INTERNAL, "Error: illegal output configuration\n" );
116 0 : nchan_out = -1;
117 0 : break;
118 : }
119 :
120 32517021 : return ( nchan_out );
121 : }
122 :
123 :
124 : /*-------------------------------------------------------------------------*
125 : * ivas_output_init()
126 : *
127 : * Initialize and configure IVAS output parameters
128 : *-------------------------------------------------------------------------*/
129 :
130 18570 : void ivas_output_init(
131 : IVAS_OUTPUT_SETUP *hOutSetup, /* o : IVAS output setup structure */
132 : const AUDIO_CONFIG output_config /* i : output audio configuration */
133 : )
134 : {
135 : int16_t nchan_out;
136 :
137 : /* set general default values */
138 18570 : hOutSetup->output_config = output_config;
139 18570 : hOutSetup->is_loudspeaker_setup = 0;
140 18570 : hOutSetup->is_binaural_setup = 0;
141 18570 : hOutSetup->ambisonics_order = -1;
142 18570 : hOutSetup->separateChannelEnabled = 0;
143 18570 : hOutSetup->separateChannelIndex = 0;
144 :
145 18570 : if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM )
146 : {
147 15 : hOutSetup->is_loudspeaker_setup = 1;
148 : /* set in ivas_init_decoder: */
149 : /* hOutSetup->ls_azimuth */
150 : /* hOutSetup->ls_elevation */
151 : /* hOutSetup->num_lfe */
152 : /* hOutSetup->index_lfe[0] */
153 : /* hOutSetup->is_planar_setup */
154 : }
155 : else
156 : {
157 : /* Set default values for all other than custom LS setup */
158 18555 : hOutSetup->ls_azimuth = NULL;
159 18555 : hOutSetup->ls_elevation = NULL;
160 18555 : hOutSetup->num_lfe = 0;
161 18555 : hOutSetup->index_lfe[0] = -1;
162 18555 : hOutSetup->is_planar_setup = 0;
163 :
164 : /* set output setup specific values */
165 18555 : switch ( output_config )
166 : {
167 293 : case IVAS_AUDIO_CONFIG_MONO:
168 293 : hOutSetup->is_loudspeaker_setup = 1;
169 293 : break;
170 526 : case IVAS_AUDIO_CONFIG_STEREO:
171 526 : hOutSetup->is_loudspeaker_setup = 1;
172 526 : hOutSetup->ls_azimuth = ls_azimuth_CICP2;
173 526 : hOutSetup->ls_elevation = ls_elevation_CICP2;
174 526 : break;
175 5150 : case IVAS_AUDIO_CONFIG_FOA:
176 5150 : hOutSetup->ambisonics_order = SBA_FOA_ORDER;
177 5150 : break;
178 347 : case IVAS_AUDIO_CONFIG_HOA2:
179 347 : hOutSetup->ambisonics_order = SBA_HOA2_ORDER;
180 347 : break;
181 1538 : case IVAS_AUDIO_CONFIG_HOA3:
182 1538 : hOutSetup->ambisonics_order = SBA_HOA3_ORDER;
183 1538 : break;
184 2706 : case IVAS_AUDIO_CONFIG_5_1:
185 2706 : hOutSetup->num_lfe = 1;
186 2706 : hOutSetup->index_lfe[0] = 3;
187 2706 : hOutSetup->is_loudspeaker_setup = 1;
188 2706 : hOutSetup->ls_azimuth = ls_azimuth_CICP6;
189 2706 : hOutSetup->ls_elevation = ls_elevation_CICP6;
190 2706 : hOutSetup->is_planar_setup = 1;
191 2706 : break;
192 162 : case IVAS_AUDIO_CONFIG_7_1:
193 162 : hOutSetup->num_lfe = 1;
194 162 : hOutSetup->index_lfe[0] = 3;
195 162 : hOutSetup->is_loudspeaker_setup = 1;
196 162 : hOutSetup->ls_azimuth = ls_azimuth_CICP12;
197 162 : hOutSetup->ls_elevation = ls_elevation_CICP12;
198 162 : hOutSetup->is_planar_setup = 1;
199 162 : break;
200 147 : case IVAS_AUDIO_CONFIG_5_1_2:
201 147 : hOutSetup->num_lfe = 1;
202 147 : hOutSetup->index_lfe[0] = 3;
203 147 : hOutSetup->is_loudspeaker_setup = 1;
204 147 : hOutSetup->ls_azimuth = ls_azimuth_CICP14;
205 147 : hOutSetup->ls_elevation = ls_elevation_CICP14;
206 147 : hOutSetup->is_planar_setup = 0;
207 147 : break;
208 147 : case IVAS_AUDIO_CONFIG_5_1_4:
209 147 : hOutSetup->num_lfe = 1;
210 147 : hOutSetup->index_lfe[0] = 3;
211 147 : hOutSetup->is_loudspeaker_setup = 1;
212 147 : hOutSetup->ls_azimuth = ls_azimuth_CICP16;
213 147 : hOutSetup->ls_elevation = ls_elevation_CICP16;
214 147 : hOutSetup->is_planar_setup = 0;
215 147 : break;
216 2607 : case IVAS_AUDIO_CONFIG_7_1_4:
217 2607 : hOutSetup->num_lfe = 1;
218 2607 : hOutSetup->index_lfe[0] = 3;
219 2607 : hOutSetup->is_loudspeaker_setup = 1;
220 2607 : hOutSetup->ls_azimuth = ls_azimuth_CICP19;
221 2607 : hOutSetup->ls_elevation = ls_elevation_CICP19;
222 2607 : hOutSetup->is_planar_setup = 0;
223 2607 : break;
224 3312 : case IVAS_AUDIO_CONFIG_BINAURAL:
225 : case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED:
226 : case IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM:
227 : case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR:
228 : case IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB:
229 : case IVAS_AUDIO_CONFIG_ISM1:
230 : case IVAS_AUDIO_CONFIG_ISM2:
231 : case IVAS_AUDIO_CONFIG_ISM3:
232 : case IVAS_AUDIO_CONFIG_ISM4:
233 3312 : hOutSetup->is_binaural_setup = 1;
234 4932 : case IVAS_AUDIO_CONFIG_EXTERNAL:
235 : /* Default values are used */
236 4932 : break;
237 0 : default:
238 : #ifdef DEBUGGING
239 : /* error */
240 : assert( !"Error: Unknown output setup!\n" );
241 : #endif
242 0 : return;
243 : }
244 : }
245 :
246 18570 : if ( output_config != IVAS_AUDIO_CONFIG_EXTERNAL && output_config != IVAS_AUDIO_CONFIG_LS_CUSTOM )
247 : {
248 16935 : nchan_out = audioCfg2channels( output_config );
249 16935 : hOutSetup->nchan_out_woLFE = nchan_out - hOutSetup->num_lfe;
250 : }
251 :
252 18570 : return;
253 : }
254 :
255 :
256 : /*-----------------------------------------------------------------*
257 : * ivas_get_nchan_buffers_dec()
258 : *
259 : * Return number of decoder audio buffers
260 : *-----------------------------------------------------------------*/
261 :
262 : /*! r: number of decoder buffers */
263 9084261 : int16_t ivas_get_nchan_buffers_dec(
264 : Decoder_Struct *st_ivas, /* i/o: IVAS decoder structure */
265 : const int16_t sba_analysis_order, /* i : SBA order evaluated in SBA decoder */
266 : const int32_t ivas_total_brate /* i : total IVAS bitrate */
267 : )
268 : {
269 : int16_t nchan_out_buff;
270 : AUDIO_CONFIG output_config;
271 :
272 9084261 : output_config = st_ivas->hDecoderConfig->output_config;
273 :
274 9084261 : nchan_out_buff = MAX_OUTPUT_CHANNELS;
275 :
276 9084261 : if ( st_ivas->ivas_format == MONO_FORMAT )
277 : {
278 21621 : nchan_out_buff = st_ivas->hDecoderConfig->nchan_out;
279 : }
280 9062640 : else if ( st_ivas->ivas_format == STEREO_FORMAT )
281 : {
282 632916 : nchan_out_buff = max( st_ivas->hDecoderConfig->nchan_out, CPE_CHANNELS );
283 : }
284 8429724 : else if ( st_ivas->ivas_format == ISM_FORMAT )
285 : {
286 1778511 : nchan_out_buff = st_ivas->nchan_ism;
287 :
288 1778511 : if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM )
289 : {
290 76551 : nchan_out_buff = max( nchan_out_buff, st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe );
291 : }
292 1701960 : else if ( output_config != IVAS_AUDIO_CONFIG_EXTERNAL )
293 : {
294 1478586 : nchan_out_buff = max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) );
295 1478586 : nchan_out_buff = max( nchan_out_buff, audioCfg2channels( output_config ) );
296 : }
297 : }
298 6651213 : else if ( st_ivas->ivas_format == SBA_FORMAT )
299 : {
300 : int16_t nchan_internal;
301 2949438 : nchan_internal = ivas_sba_get_nchan_metadata( sba_analysis_order, ivas_total_brate );
302 2949438 : nchan_out_buff = st_ivas->hDecoderConfig->nchan_out;
303 :
304 2949438 : if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM )
305 : {
306 51051 : nchan_out_buff = max( nchan_out_buff, st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe );
307 : }
308 2898387 : else if ( output_config != IVAS_AUDIO_CONFIG_EXTERNAL )
309 : {
310 2776371 : nchan_out_buff = max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) );
311 2776371 : nchan_out_buff = max( nchan_out_buff, audioCfg2channels( output_config ) );
312 : }
313 2949438 : nchan_out_buff = max( nchan_out_buff, nchan_internal );
314 : }
315 3701775 : else if ( st_ivas->ivas_format == MASA_FORMAT )
316 : {
317 450930 : nchan_out_buff = CPE_CHANNELS;
318 :
319 450930 : if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM )
320 : {
321 0 : nchan_out_buff = max( nchan_out_buff, st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe );
322 : }
323 450930 : else if ( output_config == IVAS_AUDIO_CONFIG_STEREO || output_config == IVAS_AUDIO_CONFIG_BINAURAL || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR || output_config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
324 : {
325 170631 : nchan_out_buff = 2 * CPE_CHANNELS;
326 : }
327 280299 : else if ( output_config != IVAS_AUDIO_CONFIG_EXTERNAL )
328 : {
329 245907 : nchan_out_buff = max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) );
330 245907 : nchan_out_buff = max( nchan_out_buff, audioCfg2channels( output_config ) );
331 : }
332 :
333 450930 : if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL && st_ivas->nchan_ism > 0 )
334 : {
335 912 : nchan_out_buff = st_ivas->nchan_ism + CPE_CHANNELS;
336 : }
337 : }
338 3250845 : else if ( st_ivas->ivas_format == MASA_ISM_FORMAT )
339 : {
340 142224 : nchan_out_buff = st_ivas->nchan_ism + CPE_CHANNELS;
341 :
342 142224 : if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM )
343 : {
344 0 : nchan_out_buff = max( nchan_out_buff, st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe );
345 : }
346 142224 : else if ( st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC || st_ivas->renderer_type == RENDERER_BINAURAL_PARAMETRIC_ROOM || st_ivas->renderer_type == RENDERER_STEREO_PARAMETRIC )
347 : {
348 46677 : nchan_out_buff = max( nchan_out_buff, BINAURAL_CHANNELS + st_ivas->nchan_ism );
349 : }
350 95547 : else if ( output_config != IVAS_AUDIO_CONFIG_EXTERNAL )
351 : {
352 86040 : nchan_out_buff = max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) );
353 86040 : nchan_out_buff = max( nchan_out_buff, audioCfg2channels( output_config ) );
354 : }
355 : }
356 3108621 : else if ( st_ivas->ivas_format == SBA_ISM_FORMAT )
357 : {
358 : int16_t nchan_internal;
359 1541673 : nchan_internal = ivas_sba_get_nchan_metadata( sba_analysis_order, ivas_total_brate );
360 1541673 : nchan_out_buff = st_ivas->nchan_ism + st_ivas->nchan_transport;
361 :
362 1541673 : if ( st_ivas->hMCT != NULL )
363 : {
364 1161456 : nchan_out_buff = ( ( nchan_out_buff + 1 ) >> 1 ) << 1; /* ensure odd number of channels in MCT */
365 : }
366 :
367 1541673 : if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM )
368 : {
369 0 : nchan_out_buff = max( nchan_out_buff, st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe );
370 : }
371 1541673 : else if ( output_config != IVAS_AUDIO_CONFIG_EXTERNAL )
372 : {
373 1381968 : nchan_out_buff = max( nchan_out_buff, audioCfg2channels( st_ivas->intern_config ) );
374 1381968 : nchan_out_buff = max( nchan_out_buff, audioCfg2channels( output_config ) );
375 :
376 1381968 : if ( st_ivas->renderer_type == RENDERER_OSBA_AMBI || st_ivas->renderer_type == RENDERER_OSBA_LS )
377 : {
378 138168 : nchan_out_buff = max( nchan_out_buff + st_ivas->nchan_ism, audioCfg2channels( output_config ) ); /* needed for ivas_sba_upmixer_renderer() */
379 : }
380 : else
381 : {
382 1243800 : nchan_out_buff = max( nchan_out_buff + st_ivas->nchan_ism, audioCfg2channels( output_config ) ); /* needed for ivas_spar_dec_upmixer_sf() which is based on 'nchan_out' */
383 : }
384 : }
385 159705 : else if ( output_config == IVAS_AUDIO_CONFIG_EXTERNAL )
386 : {
387 159705 : nchan_out_buff = st_ivas->hDecoderConfig->nchan_out + st_ivas->nchan_ism; /*take into account sba_ch_idx' in ivas_dec() */
388 : }
389 :
390 1541673 : if ( !( output_config == IVAS_AUDIO_CONFIG_MONO || output_config == IVAS_AUDIO_CONFIG_STEREO ) )
391 : {
392 1386402 : nchan_out_buff = max( nchan_out_buff, nchan_internal + st_ivas->nchan_ism );
393 : }
394 1541673 : nchan_out_buff = min( nchan_out_buff, MAX_OUTPUT_CHANNELS + MAX_NUM_OBJECTS );
395 : }
396 1566948 : else if ( st_ivas->ivas_format == MC_FORMAT )
397 : {
398 1566948 : nchan_out_buff = st_ivas->hDecoderConfig->nchan_out;
399 :
400 1566948 : if ( output_config == IVAS_AUDIO_CONFIG_LS_CUSTOM )
401 : {
402 51051 : nchan_out_buff = max( nchan_out_buff, st_ivas->hOutSetup.nchan_out_woLFE + st_ivas->hOutSetup.num_lfe );
403 : }
404 1515897 : else if ( output_config != IVAS_AUDIO_CONFIG_EXTERNAL )
405 : {
406 1493331 : nchan_out_buff = max( audioCfg2channels( st_ivas->transport_config ), audioCfg2channels( st_ivas->intern_config ) );
407 1493331 : nchan_out_buff = max( nchan_out_buff, audioCfg2channels( output_config ) );
408 : }
409 : }
410 :
411 9084261 : if ( output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
412 : {
413 0 : nchan_out_buff = max( nchan_out_buff, st_ivas->hSplitBinRend->splitrend.multiBinPoseData.num_poses * BINAURAL_CHANNELS );
414 : }
415 :
416 9084261 : return nchan_out_buff;
417 : }
418 :
419 :
420 : /*-------------------------------------------------------------------*
421 : * ivas_output_buff_dec()
422 : *
423 : * Allocate/reallocate output audio buffers
424 : *-------------------------------------------------------------------*/
425 :
426 17001 : ivas_error ivas_output_buff_dec(
427 : float *p_output_f[], /* i/o: output audio buffers */
428 : const int16_t nchan_out_buff_old, /* i : previous frame number of output channels */
429 : const int16_t nchan_out_buff /* i : number of output channels */
430 : )
431 : {
432 : int16_t ch;
433 :
434 17001 : if ( nchan_out_buff > nchan_out_buff_old )
435 : {
436 11406 : for ( ch = nchan_out_buff_old; ch < nchan_out_buff; ch++ )
437 : {
438 : /* note: these are intra-frame heap memories */
439 9693 : if ( ( p_output_f[ch] = (float *) malloc( ( 48000 / FRAMES_PER_SEC ) * sizeof( float ) ) ) == NULL ) /* note: 32000 == max internal sampling rate */
440 : {
441 0 : return ( IVAS_ERROR( IVAS_ERR_FAILED_ALLOC, "Can not allocate memory for floating-point output audio buffer!\n" ) );
442 : }
443 : }
444 : }
445 : else
446 : {
447 24627 : for ( ch = nchan_out_buff; ch < nchan_out_buff_old; ch++ )
448 : {
449 9339 : free( p_output_f[ch] );
450 9339 : p_output_f[ch] = NULL;
451 : }
452 : }
453 :
454 17001 : return IVAS_ERR_OK;
455 : }
456 :
457 :
458 : /*---------------------------------------------------------------------*
459 : * is_split_rendering_enabled()
460 : *
461 : *
462 : *---------------------------------------------------------------------*/
463 :
464 : /*! r: flag to indicate if split rendering is enabled */
465 2885598 : int16_t is_split_rendering_enabled(
466 : const DECODER_CONFIG_HANDLE hDecoderConfig, /* i : configuration structure */
467 : const IVAS_RENDER_CONFIG_HANDLE hRenderConfig /* i : Render config data structure */
468 : )
469 : {
470 2885598 : if ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED || hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM ||
471 2885598 : ( hDecoderConfig->output_config == IVAS_AUDIO_CONFIG_STEREO && hDecoderConfig->Opt_non_diegetic_pan && hRenderConfig->split_rend_config.dof == 0 ) )
472 : {
473 0 : return 1;
474 : }
475 : else
476 : {
477 2885598 : return 0;
478 : }
479 : }
480 :
481 :
482 : /*---------------------------------------------------------------------*
483 : * get_channel_config()
484 : *
485 : * Gets a str related to input config
486 : *---------------------------------------------------------------------*/
487 :
488 4630 : ivas_error get_channel_config(
489 : const AUDIO_CONFIG config,
490 : char *str )
491 : {
492 4630 : if ( config == IVAS_AUDIO_CONFIG_MONO )
493 : {
494 272 : strcpy( str, "Mono" );
495 : }
496 4358 : else if ( config == IVAS_AUDIO_CONFIG_STEREO )
497 : {
498 418 : strcpy( str, "Stereo" );
499 : }
500 3940 : else if ( config == IVAS_AUDIO_CONFIG_ISM1 )
501 : {
502 74 : strcpy( str, "Object-based audio (1 object)" );
503 : }
504 3866 : else if ( config == IVAS_AUDIO_CONFIG_ISM2 )
505 : {
506 144 : strcpy( str, "Object-based audio (2 objects)" );
507 : }
508 3722 : else if ( config == IVAS_AUDIO_CONFIG_ISM3 )
509 : {
510 64 : strcpy( str, "Object-based audio (3 objects)" );
511 : }
512 3658 : else if ( config == IVAS_AUDIO_CONFIG_ISM4 )
513 : {
514 66 : strcpy( str, "Object-based audio (4 objects)" );
515 : }
516 3592 : else if ( config == IVAS_AUDIO_CONFIG_5_1 )
517 : {
518 214 : strcpy( str, "Multichannel 5.1 (CICP6)" );
519 : }
520 3378 : else if ( config == IVAS_AUDIO_CONFIG_7_1 )
521 : {
522 172 : strcpy( str, "Multichannel 7.1 (CICP12)" );
523 : }
524 3206 : else if ( config == IVAS_AUDIO_CONFIG_5_1_2 )
525 : {
526 166 : strcpy( str, "Multichannel 5.1+2 (CICP14)" );
527 : }
528 3040 : else if ( config == IVAS_AUDIO_CONFIG_5_1_4 )
529 : {
530 206 : strcpy( str, "Multichannel 5.1+4 (CICP16)" );
531 : }
532 2834 : else if ( config == IVAS_AUDIO_CONFIG_7_1_4 )
533 : {
534 198 : strcpy( str, "Multichannel 7.1+4 (CICP19)" );
535 : }
536 2636 : else if ( config == IVAS_AUDIO_CONFIG_LS_CUSTOM )
537 : {
538 297 : strcpy( str, "Multichannel (custom loudspeaker layout)" );
539 : }
540 2339 : else if ( config == IVAS_AUDIO_CONFIG_MASA1 )
541 : {
542 48 : strcpy( str, "Metadata-Assisted Spatial Audio mono (MASA1)" );
543 : }
544 2291 : else if ( config == IVAS_AUDIO_CONFIG_MASA2 )
545 : {
546 52 : strcpy( str, "Metadata-Assisted Spatial Audio stereo (MASA2)" );
547 : }
548 2239 : else if ( config == IVAS_AUDIO_CONFIG_FOA )
549 : {
550 697 : strcpy( str, "Ambisonics: First Order (FOA)" );
551 : }
552 1542 : else if ( config == IVAS_AUDIO_CONFIG_HOA2 )
553 : {
554 175 : strcpy( str, "Ambisonics: Second Order (HOA2)" );
555 : }
556 1367 : else if ( config == IVAS_AUDIO_CONFIG_HOA3 )
557 : {
558 208 : strcpy( str, "Ambisonics: Third Order (HOA3)" );
559 : }
560 1159 : else if ( config == IVAS_AUDIO_CONFIG_BINAURAL )
561 : {
562 448 : strcpy( str, "Binaural: no room" );
563 : }
564 711 : else if ( config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_IR )
565 : {
566 288 : strcpy( str, "Binaural: room with impulse responses" );
567 : }
568 423 : else if ( config == IVAS_AUDIO_CONFIG_BINAURAL_ROOM_REVERB )
569 : {
570 273 : strcpy( str, "Binaural: room with reverb" );
571 : }
572 150 : else if ( config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_CODED )
573 : {
574 0 : strcpy( str, "BINAURAL_SPLIT_CODED" );
575 : }
576 150 : else if ( config == IVAS_AUDIO_CONFIG_BINAURAL_SPLIT_PCM )
577 : {
578 0 : strcpy( str, "Binaural_Split_PCM" );
579 : }
580 150 : else if ( config == IVAS_AUDIO_CONFIG_EXTERNAL )
581 : {
582 150 : strcpy( str, "External renderer" );
583 : }
584 : else
585 : {
586 0 : return IVAS_ERROR( IVAS_ERR_INVALID_OUTPUT_FORMAT, "Error: Incorrect Input/Output Configuration" );
587 : }
588 :
589 4630 : return IVAS_ERR_OK;
590 : }
|